<commit_before>module QriousDevops
  class Environments

    def self.development_mongodb_uri
      "mongodb://localhost:27017/qrious_development"
    end

    def self.development_redis_uri
      "redis://redis@localhost/"
    end

    def self.new_backup_dir
      "db/backups/production/#{Time.now.strftime("%Y%m%d_%H%M%S")}"
    end

    def self.latest_backup_dir
      Dir["db/backups/production/*/*"].sort.last
    end

    def self.mongo_url(env)
      `heroku config --app #{heroku_app(env)}`
      `heroku config --app #{heroku_app(env)}`.scan(/^MONGODB_URL\s*:\s*(.+)$/).flatten.first
    end

    def self.redis_url(env)
      `heroku config --app #{heroku_app(env)}`.scan(/^REDISTOGO_URL\s*:\s*(.+)$/).flatten.first
    end

    def self.can_deploy?
      environments.keys.include?(target_environment)
    end

    def self.target_environment
      current_git_branch.to_sym
    end

    def self.target_app
      heroku_app(target_environment)
    end

    def self.heroku_app(env)
      environments[env.to_sym][:heroku_app]
    end

    def self.environments
      @env
    end

    def self.environments=(hash)
      @env = hash
    end

    def self.current_git_branch
      @current_git_branch ||= `git symbolic-ref HEAD 2>/dev/null`.chomp.gsub("refs/heads/", "")
    end

  end
end
<commit_msg>Readin mongoid.yaml for local db info and changed latest_backup_dir<commit_after>module QriousDevops
  class Environments

    def self.development_mongodb_uri
      yaml = YAML.load(ERB.new(File.read("#{Rails.root}/config/mongoid.yml")).result)
      pp yaml
      db = yaml['development']['sessions']['default']['database']
      host = yaml['development']['sessions']['default']['hosts'].first
      "mongodb://#{host}/#{db}"
    end

    def self.development_redis_uri
      "redis://redis@localhost/"
    end

    def self.new_backup_dir
      "db/backups/production/#{Time.now.strftime("%Y%m%d_%H%M%S")}"
    end

    def self.latest_backup_dir
      # note the trailing / which returns only directories
      Dir["db/backups/*/*/"].sort.last
    end

    def self.mongo_url(env)
      `heroku config --app #{heroku_app(env)}`
      `heroku config --app #{heroku_app(env)}`.scan(/^MONGODB_URL\s*:\s*(.+)$/).flatten.first
    end

    def self.redis_url(env)
      `heroku config --app #{heroku_app(env)}`.scan(/^REDISTOGO_URL\s*:\s*(.+)$/).flatten.first
    end

    def self.can_deploy?
      environments.keys.include?(target_environment)
    end

    def self.target_environment
      current_git_branch.to_sym
    end

    def self.target_app
      heroku_app(target_environment)
    end

    def self.heroku_app(env)
      environments[env.to_sym][:heroku_app]
    end

    def self.environments
      @env
    end

    def self.environments=(hash)
      @env = hash
    end

    def self.current_git_branch
      @current_git_branch ||= `git symbolic-ref HEAD 2>/dev/null`.chomp.gsub("refs/heads/", "")
    end

  end
end

{'fraction_non_alphanumeric': 0.13869108172261785, 'fraction_numerical': 0.002373685995252628, 'mean_word_length': 2.8815789473684212, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7200269', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1017, 'n_words': 169}