<commit_before>require "yaml"

require 'rubygems'

# LIB
require "couchrest"
require 'couchrest_model'
require "treedisha"
require "json"

# CLI
require "thor"
require "progressbar"

require File.join(File.dirname(__FILE__), "chillfile/config")
require File.join(File.dirname(__FILE__), "chillfile/cli")

require File.join(File.dirname(__FILE__), "chillfile/helper/sync_helper")

require File.join(File.dirname(__FILE__), "chillfile/database_server")
require File.join(File.dirname(__FILE__), "chillfile/sync")
require File.join(File.dirname(__FILE__), "chillfile/model")

module Chillfile
  get_version = lambda do
    v = YAML.parse_file(File.join(File.dirname(__FILE__), "../version.yml"))
    "#{v[:major].value}.#{v[:minor].value}.#{v[:patch].value}"
  end
  VERSION = get_version.call
  
  class << self
    def boot!(config = {})
      @@config = Chillfile::Config.new(config)
      @@dbserver = Chillfile::DatabaseServer.new
      Chillfile::Model.load!
      true
    end
        
    def config
      @@config
    end
    def db
      @@dbserver.default_database
    end
    
    def sync!(progressbar = nil)
      fs = fs_list
      db = db_list
      comparator = Treedisha::Comparator.new(fs_list, db_list)
      
      Chillfile::Sync.process!(comparator, progressbar)
    end
  
    # filesystem
    def fs_list
      Treedisha::Filesystem.all_files_with_sha1(config["path"])
    end
  
    # databse
    def db_list
      Chillfile::Asset.by_filesystem_raw
    end
  end
end<commit_msg>refactored version<commit_after>require "yaml"

require 'rubygems'

# LIB
require "couchrest"
require 'couchrest_model'
require "treedisha"
require "json"

# CLI
require "thor"
require "progressbar"

require File.join(File.dirname(__FILE__), "chillfile/config")
require File.join(File.dirname(__FILE__), "chillfile/cli")

require File.join(File.dirname(__FILE__), "chillfile/helper/sync_helper")

require File.join(File.dirname(__FILE__), "chillfile/database_server")
require File.join(File.dirname(__FILE__), "chillfile/sync")
require File.join(File.dirname(__FILE__), "chillfile/model")

module Chillfile
  get_version = lambda do
    v = YAML.load_file(File.join(File.dirname(__FILE__), "../version.yml"))
    "#{v[:major]}.#{v[:minor]}.#{v[:patch]}"
  end
  VERSION = get_version.call
  
  class << self
    def boot!(config = {})
      @@config = Chillfile::Config.new(config)
      @@dbserver = Chillfile::DatabaseServer.new
      Chillfile::Model.load!
      true
    end
        
    def config
      @@config
    end
    def db
      @@dbserver.default_database
    end
    
    def sync!(progressbar = nil)
      fs = fs_list
      db = db_list
      comparator = Treedisha::Comparator.new(fs_list, db_list)
      
      Chillfile::Sync.process!(comparator, progressbar)
    end
  
    # filesystem
    def fs_list
      Treedisha::Filesystem.all_files_with_sha1(config["path"])
    end
  
    # databse
    def db_list
      Chillfile::Asset.by_filesystem_raw
    end
  end
end
{'fraction_non_alphanumeric': 0.1274247491638796, 'fraction_numerical': 0.0006688963210702341, 'mean_word_length': 3.5386949924127467, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1018979', 'n_tokens_mistral': 1031, 'n_tokens_neox': 1020, 'n_words': 184}