Sha256: 41d04905dca0363b8efc145ae1543095a023ac8816afc495462c6d0c96d240f4

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

module LocaleApp
  module CLI
    class Install
      def execute(key, output = $stdout)
        output.puts "LocaleApp Install"
        output.puts ""
        output.puts "Checking API key: #{key}"
        if key.nil?
          output.puts "ERROR: You must supply an API key"
          return
        end
        valid_key, project_data = check_key(key)
        if valid_key
          output.puts "Success!"
          output.puts "Project: #{project_data['name']}"
          locale_app_default_code = project_data['default_locale']['code']
          output.puts "Default Locale: #{locale_app_default_code} (#{project_data['default_locale']['name']})"
          if I18n.default_locale.to_s != locale_app_default_code
            output.puts "WARNING: I18n.default_locale is #{I18n.default_locale}, change in config/environment.rb (Rails 2) or config/application.rb (Rails 3)"
          end
          config_file_path = "config/initializers/localeapp.rb"
          output.puts "Writing configuration file to #{config_file_path}"
          write_configuration_file config_file_path
          true
        else
          output.puts "ERROR: Project not found"
          false
        end
      end

      private
      def check_key(key)
        LocaleApp::KeyChecker.new.check(key)
      end

      def write_configuration_file(path)
        LocaleApp.configuration.write_initial(path)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
localeapp-0.0.7 lib/locale_app/cli/install.rb