<commit_before>module OpsWorks
  module RailsConfiguration
    def self.determine_database_adapter(app_name, app_config, app_root_path, options = {})
      options = {
        :consult_gemfile => true,
        :force => false
      }.update(options)
      if options[:force] || app_config[:database][:adapter].blank?
        Chef::Log.info("No database adapter specified for #{app_name}, guessing")
        adapter = ''

        if options[:consult_gemfile] and File.exists?("#{app_root_path}/Gemfile")
          bundle_list = `cd #{app_root_path}; /usr/local/bin/bundle list`
          adapter = if bundle_list.include?('mysql2')
            Chef::Log.info("Looks like #{app_name} uses mysql2 in its Gemfile")
            'mysql2'
          else
            Chef::Log.info("Gem mysql2 not found in the Gemfile of #{app_name}, defaulting to mysql")
            'mysql'
          end
        else # no Gemfile - guess adapter by Rails version
          adapter = if File.exists?("#{app_root_path}/config/application.rb")
            Chef::Log.info("Looks like #{app_name} is a Rails 3 application, defaulting to mysql2")
            'mysql2'
          else
            Chef::Log.info("No config/application.rb found, assuming #{app_name} is a Rails 2 application, defaulting to mysql")
            'mysql'
          end
        end

        adapter
      else
        app_config[:database][:adapter]
      end
    end

    def self.bundle(app_name, app_config, app_root_path)
      if File.exists?("#{app_root_path}/Gemfile")
        Chef::Log.info("Gemfile detected. Running bundle install.")
        Chef::Log.info("sudo su deploy -c 'cd #{app_root_path} && /usr/local/bin/bundle install --path #{app_config[:home]}/.bundler/#{app_name} --without=#{app_config[:ignore_bundler_groups].join(' ')}'")
        Chef::Log.info(`sudo su deploy -c 'cd #{app_root_path} && /usr/local/bin/bundle install --path #{app_config[:home]}/.bundler/#{app_name} --without=#{app_config[:ignore_bundler_groups].join(' ')} 2>&1'`)
      end
    end
  end
end<commit_msg>modified rails config<commit_after>module OpsWorks
  module RailsConfiguration
    def self.determine_database_adapter(app_name, app_config, app_root_path, options = {})
      options = {
        :consult_gemfile => true,
        :force => false
      }.update(options)
      if options[:force] || app_config[:database][:adapter].blank?
        Chef::Log.info("No database adapter specified for #{app_name}, guessing")
        adapter = ''

        if options[:consult_gemfile] and File.exists?("#{app_root_path}/Gemfile")
          bundle_list = `cd #{app_root_path}; /usr/local/bin/bundle list`
          adapter = if bundle_list.include?('mysql2')
            Chef::Log.info("Looks like #{app_name} uses mysql2 in its Gemfile")
            'mysql2'
          else
            Chef::Log.info("Gem mysql2 not found in the Gemfile of #{app_name}, defaulting to mysql")
            'mysql'
          end
        else # no Gemfile - guess adapter by Rails version
          adapter = if File.exists?("#{app_root_path}/config/application.rb")
            Chef::Log.info("Looks like #{app_name} is a Rails 3 application, defaulting to mysql2")
            'mysql2'
          else
            Chef::Log.info("No config/application.rb found, assuming #{app_name} is a Rails 2 application, defaulting to mysql")
            'mysql'
          end
        end

        adapter
      else
        app_config[:database][:adapter]
      end
    end

    def self.bundle(app_name, app_config, app_root_path)
      if File.exists?("#{app_root_path}/Gemfile")
        Chef::Log.info("Gemfile detected. Running bundle install.")
        Chef::Log.info("sudo su deploy -c 'cd #{app_root_path} && /usr/local/bin/bundle install --path #{app_config[:home]}/.bundler/#{app_name} --without=#{app_config[:ignore_bundler_groups].join(' ')}'")
        Chef::Log.info(`sudo su deploy -c 'cd #{app_root_path} && /usr/local/bin/bundle install --path #{app_config[:home]}/.bundler/#{app_name} --without=#{app_config[:ignore_bundler_groups].join(' ')} 2>&1'`)
      end
    end

    def self.precompile_assets(app_root_path, rails_env)
      if system("cd #{app_root_path} && /usr/local/bin/rake -T | grep assets:precompile 1>/dev/null")
        Chef::Log.info("Assets detected. Running assets precompile.")
        Chef::Log.info("sudo su deploy -c 'cd #{app_root_path} && RAILS_ENV=#{rails_env} /usr/local/bin/bundle exec rake assets:precompile'")
        Chef::Log.info(`sudo su deploy -c 'cd #{app_root_path} && RAILS_ENV=#{rails_env} /usr/local/bin/bundle exec rake assets:precompile 2>&1'`)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13741115657979755, 'fraction_numerical': 0.004953693732500539, 'mean_word_length': 2.8507462686567164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5549063', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1435, 'n_words': 332}