From a2ea2be43a14fe6a27473aea4f358d52a9e951f6 Mon Sep 17 00:00:00 2001 From: Christopher Dell Date: Tue, 23 Aug 2011 18:29:38 +0200 Subject: [PATCH] * Replaced all instances of 'locale_app' with 'localeapp' * Replaced all instances of 'LocaleApp' with 'Localeapp' --- .rvmrc | 2 +- bin/localeapp | 18 +++--- features/localeapp_binary.feature | 26 ++++----- features/support/env.rb | 4 +- init.rb | 2 +- lib/localeapp.rb | 44 +++++++-------- lib/localeapp/api_call.rb | 4 +- lib/localeapp/api_caller.rb | 16 +++--- lib/localeapp/cli/install.rb | 14 ++--- lib/localeapp/cli/pull.rb | 10 ++-- lib/localeapp/cli/push.rb | 6 +- lib/localeapp/cli/update.rb | 6 +- lib/localeapp/configuration.rb | 14 ++--- lib/localeapp/exception_handler.rb | 12 ++-- lib/localeapp/key_checker.rb | 12 ++-- lib/localeapp/missing_translations.rb | 2 +- lib/localeapp/poller.rb | 14 ++--- lib/localeapp/rails.rb | 22 ++++---- .../2_3_translation_helper_monkeypatch.rb | 4 +- lib/localeapp/rails/controller.rb | 24 ++++---- lib/localeapp/routes.rb | 10 ++-- lib/localeapp/sender.rb | 16 +++--- lib/localeapp/tasks/localeapp.rake | 4 +- lib/localeapp/updater.rb | 4 +- lib/localeapp/version.rb | 2 +- localeapp.gemspec | 4 +- run_ci | 2 +- spec/localeapp/api_call_spec.rb | 6 +- spec/localeapp/api_caller_spec.rb | 8 +-- spec/localeapp/cli/install_spec.rb | 6 +- spec/localeapp/cli/pull_spec.rb | 18 +++--- spec/localeapp/cli/push_spec.rb | 4 +- spec/localeapp/cli/update_spec.rb | 10 ++-- spec/localeapp/configuration_spec.rb | 12 ++-- spec/localeapp/exception_handler_spec.rb | 12 ++-- spec/localeapp/key_checker_spec.rb | 6 +- spec/localeapp/missing_translations_spec.rb | 10 ++-- spec/localeapp/poller_spec.rb | 10 ++-- spec/localeapp/rails/controller_spec.rb | 56 +++++++++---------- spec/localeapp/routes_spec.rb | 4 +- spec/localeapp/sender_spec.rb | 12 ++-- spec/localeapp/updater_spec.rb | 4 +- spec/spec_helper.rb | 14 ++--- spec/support/localeapp_integration_data.rb | 2 +- .../support/localeapp_synchronization_data.rb | 2 +- 45 files changed, 247 insertions(+), 247 deletions(-) diff --git a/.rvmrc b/.rvmrc index 1cfb09a..9f510d3 100644 --- a/.rvmrc +++ b/.rvmrc @@ -1 +1 @@ -rvm ruby-1.9.2@locale_app +rvm ruby-1.9.2@localeapp diff --git a/bin/localeapp b/bin/localeapp index 796f612..5b79490 100755 --- a/bin/localeapp +++ b/bin/localeapp @@ -1,7 +1,7 @@ #!/usr/bin/env ruby $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))) -require 'locale_app' +require 'localeapp' # Don't connect to the net if we're running under cucumber for testing # Use FakeWeb to simulate api.localeapp.com @@ -19,7 +19,7 @@ args = ARGV.dup command = args.shift.strip rescue nil unless %w{help install}.include?(command) - unless LocaleApp.include_config_file + unless Localeapp.include_config_file puts "Could not load config file" exit end @@ -28,23 +28,23 @@ end case command when 'install' key = args.shift.strip rescue nil - installer = LocaleApp::CLI::Install.new + installer = Localeapp::CLI::Install.new if installer.execute(key) exit 0 else exit 1 end when 'pull' - LocaleApp::CLI::Pull.new.execute + Localeapp::CLI::Pull.new.execute when 'push' file = args.shift.strip rescue nil - pusher = LocaleApp::CLI::Push.new + pusher = Localeapp::CLI::Push.new pusher.execute(file) when 'update' - LocaleApp::CLI::Update.new.execute + Localeapp::CLI::Update.new.execute when 'daemon' while true do - LocaleApp::CLI::Update.new.execute + Localeapp::CLI::Update.new.execute sleep 5 end else @@ -53,8 +53,8 @@ Usage: localeapp COMMAND [ARGS] Commands: install - Creates new configuration files and confirms key works - pull - Pulls all translations from LocaleApp.com - push - Pushes a translation file to LocaleApp.com + pull - Pulls all translations from localeapp.com + push - Pushes a translation file to localeapp.com update - Gets any changes since the last poll and updates the yml files daemon - Simple daemon that checks every 5 seconds for new translations HELP diff --git a/features/localeapp_binary.feature b/features/localeapp_binary.feature index 0931930..7136f3e 100644 --- a/features/localeapp_binary.feature +++ b/features/localeapp_binary.feature @@ -9,7 +9,7 @@ Feature: localeapp executable Commands: install - Creates new configuration files and confirms key works - pull - Pulls all translations from LocaleApp.com + pull - Pulls all translations from localeapp.com """ Scenario: Running install @@ -18,7 +18,7 @@ Feature: localeapp executable And I run `localeapp install MYAPIKEY` Then the output should contain: """ - LocaleApp Install + Localeapp Install Checking API key: MYAPIKEY Success! @@ -34,7 +34,7 @@ Feature: localeapp executable And I run `localeapp install BADAPIKEY` Then the output should contain: """ - LocaleApp Install + Localeapp Install Checking API key: BADAPIKEY ERROR: Project not found @@ -47,8 +47,8 @@ Feature: localeapp executable Given I have a translations on localeapp.com for the project with api key "MYAPIKEY" And a file named "config/initializers/localeapp.rb" with: """ - require 'locale_app/rails' - LocaleApp.configure do |config| + require 'localeapp/rails' + Localeapp.configure do |config| config.api_key = 'MYAPIKEY' end """ @@ -56,7 +56,7 @@ Feature: localeapp executable When I run `localeapp pull` Then the output should contain: """ - LocaleApp Pull + Localeapp Pull Fetching translations: Success! @@ -70,8 +70,8 @@ Feature: localeapp executable When I have a valid project on localeapp.com with api key "MYAPIKEY" And a file named "config/initializers/localeapp.rb" with: """ - require 'locale_app/rails' - LocaleApp.configure do |config| + require 'localeapp/rails' + Localeapp.configure do |config| config.api_key = 'MYAPIKEY' end """ @@ -79,7 +79,7 @@ Feature: localeapp executable When I run `localeapp push config/locales/en.yml` Then the output should contain: """ - LocaleApp Push + Localeapp Push Pushing file: Success! @@ -92,12 +92,12 @@ Feature: localeapp executable When I have a valid project on localeapp.com with api key "MYAPIKEY" And a file named "config/initializers/localeapp.rb" with: """ - require 'locale_app/rails' - LocaleApp.configure do |config| + require 'localeapp/rails' + Localeapp.configure do |config| config.api_key = 'MYAPIKEY' end """ - And a file named "log/locale_app.yml" with: + And a file named "log/localeapp.yml" with: """ --- :updated_at: 120 @@ -108,7 +108,7 @@ Feature: localeapp executable When I run `localeapp update` Then the output should contain: """ - LocaleApp update: checking for translations since 120 + Localeapp update: checking for translations since 120 Found and updated new translations """ And a file named "config/locales/en.yml" should exist diff --git a/features/support/env.rb b/features/support/env.rb index 7903fb7..9584a1c 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,6 +1,6 @@ require 'aruba/cucumber' -require File.expand_path(File.join(File.dirname(__FILE__), '../../spec/support/locale_app_integration_data')) -World(LocaleAppIntegrationData) +require File.expand_path(File.join(File.dirname(__FILE__), '../../spec/support/localeapp_integration_data')) +World(LocaleappIntegrationData) ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}" diff --git a/init.rb b/init.rb index fadbeaa..3f05981 100644 --- a/init.rb +++ b/init.rb @@ -1 +1 @@ -require 'locale_app' +require 'localeapp' \ No newline at end of file diff --git a/lib/localeapp.rb b/lib/localeapp.rb index ee17537..1a12347 100644 --- a/lib/localeapp.rb +++ b/lib/localeapp.rb @@ -14,39 +14,39 @@ end -require 'locale_app/version' -require 'locale_app/configuration' -require 'locale_app/routes' -require 'locale_app/api_call' -require 'locale_app/api_caller' -require 'locale_app/sender' -require 'locale_app/poller' -require 'locale_app/updater' -require 'locale_app/key_checker' -require 'locale_app/missing_translations' +require 'localeapp/version' +require 'localeapp/configuration' +require 'localeapp/routes' +require 'localeapp/api_call' +require 'localeapp/api_caller' +require 'localeapp/sender' +require 'localeapp/poller' +require 'localeapp/updater' +require 'localeapp/key_checker' +require 'localeapp/missing_translations' -require 'locale_app/cli/install' -require 'locale_app/cli/pull' -require 'locale_app/cli/push' -require 'locale_app/cli/update' +require 'localeapp/cli/install' +require 'localeapp/cli/pull' +require 'localeapp/cli/push' +require 'localeapp/cli/update' # AUDIT: Will this work on ruby 1.9.x $KCODE="UTF8" if RUBY_VERSION < '1.9' require 'ya2yaml' -module LocaleApp +module Localeapp API_VERSION = "1" - LOG_PREFIX = "** [LocaleApp] " + LOG_PREFIX = "** [Localeapp] " class << self - # An LocaleApp configuration object. + # An Localeapp configuration object. attr_accessor :configuration - # The sender object is responsible for delivering formatted data to the LocaleApp server. + # The sender object is responsible for delivering formatted data to the Localeapp server. attr_accessor :sender - # The poller object is responsible for retrieving data for the LocaleApp server + # The poller object is responsible for retrieving data for the Localeapp server attr_accessor :poller # The updater object is responsible for merging translations into the i18n backend @@ -72,7 +72,7 @@ def logger end # @example Configuration - # LocaleApp.configure do |config| + # Localeapp.configure do |config| # config.api_key = '1234567890abcdef' # end def configure @@ -84,9 +84,9 @@ def configure @missing_translations = MissingTranslations.new end - # requires the LocaleApp configuration + # requires the Localeapp configuration def include_config_file(file_path=nil) - file_path ||= File.join(Dir.pwd, 'config', 'initializers', 'locale_app') + file_path ||= File.join(Dir.pwd, 'config', 'initializers', 'localeapp') begin require file_path true diff --git a/lib/localeapp/api_call.rb b/lib/localeapp/api_call.rb index a8f83fb..83e7447 100644 --- a/lib/localeapp/api_call.rb +++ b/lib/localeapp/api_call.rb @@ -1,8 +1,8 @@ -module LocaleApp +module Localeapp module ApiCall # creates an object to perform the call def api_call(endpoint, options = {}) - api_caller = LocaleApp::ApiCaller.new(endpoint, options) + api_caller = Localeapp::ApiCaller.new(endpoint, options) api_caller.call(self) end end diff --git a/lib/localeapp/api_caller.rb b/lib/localeapp/api_caller.rb index c6dbeed..a5a0917 100644 --- a/lib/localeapp/api_caller.rb +++ b/lib/localeapp/api_caller.rb @@ -1,6 +1,6 @@ -module LocaleApp +module Localeapp class ApiCaller - include ::LocaleApp::Routes + include ::Localeapp::Routes NonHTTPResponse = Struct.new(:code) @@ -20,16 +20,16 @@ def initialize(endpoint, options = {}) def call(obj) method, url = send("#{endpoint}_endpoint", options[:url_options] || {}) - LocaleApp.debug("API CALL: #{method} #{url}") + Localeapp.debug("API CALL: #{method} #{url}") success = false while connection_attempts < max_connection_attempts sleep_if_retrying response = make_call(method, url) - LocaleApp.debug("RESPONSE: #{response.code}") + Localeapp.debug("RESPONSE: #{response.code}") valid_response_codes = (200..207).to_a if valid_response_codes.include?(response.code.to_i) if options[:success] - LocaleApp.debug("CALLING SUCCESS HANDLER: #{options[:success]}") + Localeapp.debug("CALLING SUCCESS HANDLER: #{options[:success]}") obj.send(options[:success], response) end success = true @@ -46,7 +46,7 @@ def call(obj) def make_call(method, url) begin @connection_attempts += 1 - LocaleApp.debug("ATTEMPT #{@connection_attempts}") + Localeapp.debug("ATTEMPT #{@connection_attempts}") request_options = options[:request_options] || {} if method == :post RestClient.send(method, url, options[:payload], request_options) @@ -61,7 +61,7 @@ def make_call(method, url) RestClient::GatewayTimeout => error return error.response rescue Errno::ECONNREFUSED => error - LocaleApp.debug("ERROR: Connection Refused") + Localeapp.debug("ERROR: Connection Refused") return NonHTTPResponse.new(-1) end end @@ -69,7 +69,7 @@ def make_call(method, url) def sleep_if_retrying if @connection_attempts > 0 time = @connection_attempts * 5 - LocaleApp.debug("Sleeping for #{time} before retrying") + Localeapp.debug("Sleeping for #{time} before retrying") sleep time end end diff --git a/lib/localeapp/cli/install.rb b/lib/localeapp/cli/install.rb index 055cbf9..929b067 100644 --- a/lib/localeapp/cli/install.rb +++ b/lib/localeapp/cli/install.rb @@ -1,8 +1,8 @@ -module LocaleApp +module Localeapp module CLI class Install def execute(key, output = $stdout) - output.puts "LocaleApp Install" + output.puts "Localeapp Install" output.puts "" output.puts "Checking API key: #{key}" if key.nil? @@ -13,9 +13,9 @@ def execute(key, output = $stdout) 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 + localeapp_default_code = project_data['default_locale']['code'] + output.puts "Default Locale: #{localeapp_default_code} (#{project_data['default_locale']['name']})" + if I18n.default_locale.to_s != localeapp_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" @@ -30,11 +30,11 @@ def execute(key, output = $stdout) private def check_key(key) - LocaleApp::KeyChecker.new.check(key) + Localeapp::KeyChecker.new.check(key) end def write_configuration_file(path) - LocaleApp.configuration.write_initial(path) + Localeapp.configuration.write_initial(path) end end end diff --git a/lib/localeapp/cli/pull.rb b/lib/localeapp/cli/pull.rb index ddc6d54..8620072 100644 --- a/lib/localeapp/cli/pull.rb +++ b/lib/localeapp/cli/pull.rb @@ -1,14 +1,14 @@ -module LocaleApp +module Localeapp module CLI class Pull - include ::LocaleApp::ApiCall + include ::Localeapp::ApiCall def initialize(output = $stdout) @output = output end def execute - @output.puts "LocaleApp Pull" + @output.puts "Localeapp Pull" @output.puts "" @output.puts "Fetching translations:" @@ -21,9 +21,9 @@ def execute def update_backend(response) @output.puts "Success!" @output.puts "Updating backend:" - LocaleApp.updater.update(JSON.parse(response)) + Localeapp.updater.update(JSON.parse(response)) @output.puts "Success!" - LocaleApp.poller.write_synchronization_data!(Time.now.to_i, Time.now.to_i) + Localeapp.poller.write_synchronization_data!(Time.now.to_i, Time.now.to_i) end def report_failure(response) diff --git a/lib/localeapp/cli/push.rb b/lib/localeapp/cli/push.rb index cac0c22..928a0cc 100644 --- a/lib/localeapp/cli/push.rb +++ b/lib/localeapp/cli/push.rb @@ -1,14 +1,14 @@ -module LocaleApp +module Localeapp module CLI class Push - include ::LocaleApp::ApiCall + include ::Localeapp::ApiCall def initialize(output = $stdout) @output = output end def execute(file_path = nil) - @output.puts "LocaleApp Push" + @output.puts "Localeapp Push" @output.puts "" @file_path = file_path diff --git a/lib/localeapp/cli/update.rb b/lib/localeapp/cli/update.rb index e94cf7d..ae61b4d 100644 --- a/lib/localeapp/cli/update.rb +++ b/lib/localeapp/cli/update.rb @@ -1,4 +1,4 @@ -module LocaleApp +module Localeapp module CLI class Update def initialize(output = $stdout) @@ -6,8 +6,8 @@ def initialize(output = $stdout) end def execute - poller = LocaleApp::Poller.new - @output.puts("LocaleApp update: checking for translations since #{poller.updated_at}") + poller = Localeapp::Poller.new + @output.puts("Localeapp update: checking for translations since #{poller.updated_at}") if poller.poll! @output.puts "Found and updated new translations" else diff --git a/lib/localeapp/configuration.rb b/lib/localeapp/configuration.rb index 6500f2a..62dd0cc 100644 --- a/lib/localeapp/configuration.rb +++ b/lib/localeapp/configuration.rb @@ -1,4 +1,4 @@ -module LocaleApp +module Localeapp class Configuration # The API key for your project, found on the project edit form @@ -32,7 +32,7 @@ class Configuration # 'test', 'cucumber', 'production') attr_accessor :disabled_polling_environments - # The logger used by LocaleApp + # The logger used by Localeapp attr_accessor :logger # The number of seconds to wait before asking the service for new @@ -40,8 +40,8 @@ class Configuration attr_accessor :poll_interval # The complete path to the data file where we store synchronization - # information (defaults to ./locale_app.yml) local_app/rails overwrites - # this to RAILS_ROOT/log/locale_app.yml + # information (defaults to ./localeapp.yml) local_app/rails overwrites + # this to RAILS_ROOT/log/localeapp.yml attr_accessor :synchronization_data_file # The complete path to the directory where translations are stored @@ -54,7 +54,7 @@ def initialize @disabled_reloading_environments = %w(test cucumber production) @disabled_polling_environments = %w(test cucumber production) @poll_interval = 0 - @synchronization_data_file = File.join('log', 'locale_app.yml') + @synchronization_data_file = File.join('log', 'localeapp.yml') @translation_data_directory = File.join('config', 'locales') if ENV['DEBUG'] require 'logger' @@ -79,9 +79,9 @@ def write_initial(path) FileUtils.mkdir_p(dir) File.open(path, 'w+') do |file| file.write <<-CONTENT -require 'locale_app/rails' +require 'localeapp/rails' -LocaleApp.configure do |config| +Localeapp.configure do |config| config.api_key = '#{@api_key}' config.host = '#{@host}' config.port = #{@port} diff --git a/lib/localeapp/exception_handler.rb b/lib/localeapp/exception_handler.rb index 42cad30..c400fc4 100644 --- a/lib/localeapp/exception_handler.rb +++ b/lib/localeapp/exception_handler.rb @@ -1,21 +1,21 @@ -module LocaleApp +module Localeapp class ExceptionHandler def self.call(exception, locale, key, options) - LocaleApp.log(exception.message) + Localeapp.log(exception.message) if I18n::MissingTranslationData === exception - LocaleApp.log("Detected missing translation for key(s) #{key.inspect}") + Localeapp.log("Detected missing translation for key(s) #{key.inspect}") [*key].each do |key| - LocaleApp.missing_translations.add(locale, key, options) + Localeapp.missing_translations.add(locale, key, options) end [locale, key].join(', ') else - LocaleApp.log('Raising exception') + Localeapp.log('Raising exception') raise end end end end -I18n.exception_handler = LocaleApp::ExceptionHandler +I18n.exception_handler = Localeapp::ExceptionHandler diff --git a/lib/localeapp/key_checker.rb b/lib/localeapp/key_checker.rb index 8d37902..6846669 100644 --- a/lib/localeapp/key_checker.rb +++ b/lib/localeapp/key_checker.rb @@ -2,16 +2,16 @@ require 'rest-client' require 'time' -module LocaleApp +module Localeapp class KeyChecker - include ::LocaleApp::ApiCall + include ::Localeapp::ApiCall def check(key) - if LocaleApp.configuration.nil? # no config file yet - LocaleApp.configuration = LocaleApp::Configuration.new - LocaleApp.configuration.host = ENV['LA_TEST_HOST'] if ENV['LA_TEST_HOST'] + if Localeapp.configuration.nil? # no config file yet + Localeapp.configuration = Localeapp::Configuration.new + Localeapp.configuration.host = ENV['LA_TEST_HOST'] if ENV['LA_TEST_HOST'] end - LocaleApp.configuration.api_key = key + Localeapp.configuration.api_key = key api_call :project, :success => :handle_success, :failure => :handle_failure, diff --git a/lib/localeapp/missing_translations.rb b/lib/localeapp/missing_translations.rb index 5ce2c4a..570cf25 100644 --- a/lib/localeapp/missing_translations.rb +++ b/lib/localeapp/missing_translations.rb @@ -1,4 +1,4 @@ -module LocaleApp +module Localeapp MissingTranslationRecord = Struct.new(:key, :locale, :options) class MissingTranslations diff --git a/lib/localeapp/poller.rb b/lib/localeapp/poller.rb index 6a48edd..79c4cac 100644 --- a/lib/localeapp/poller.rb +++ b/lib/localeapp/poller.rb @@ -2,9 +2,9 @@ require 'rest-client' require 'time' -module LocaleApp +module Localeapp class Poller - include ::LocaleApp::ApiCall + include ::Localeapp::ApiCall # when we last asked the service for updates attr_accessor :polled_at @@ -18,21 +18,21 @@ def initialize end def synchronization_data - if File.exists?(LocaleApp.configuration.synchronization_data_file) - YAML.load_file(LocaleApp.configuration.synchronization_data_file) + if File.exists?(Localeapp.configuration.synchronization_data_file) + YAML.load_file(Localeapp.configuration.synchronization_data_file) else {} end end def write_synchronization_data!(polled_at, updated_at) - File.open(LocaleApp.configuration.synchronization_data_file, 'w+') do |f| + File.open(Localeapp.configuration.synchronization_data_file, 'w+') do |f| f.write({:polled_at => polled_at, :updated_at => updated_at}.to_yaml) end end def needs_polling? - synchronization_data[:polled_at] < (Time.now.to_i - LocaleApp.configuration.poll_interval) + synchronization_data[:polled_at] < (Time.now.to_i - Localeapp.configuration.poll_interval) end def needs_reloading? @@ -50,7 +50,7 @@ def poll! def handle_success(response) @success = true - LocaleApp.updater.update(JSON.parse(response)) + Localeapp.updater.update(JSON.parse(response)) write_synchronization_data!(Time.now.to_i, Time.parse(response.headers[:date]).to_i) end diff --git a/lib/localeapp/rails.rb b/lib/localeapp/rails.rb index 4a70786..ee73e2d 100644 --- a/lib/localeapp/rails.rb +++ b/lib/localeapp/rails.rb @@ -1,4 +1,4 @@ -module LocaleApp +module Localeapp module Rails def self.initialize if defined?(::Rails.logger) @@ -19,25 +19,25 @@ def self.initialize rails_root = RAILS_ROOT end - ActionController::Base.send(:include, LocaleApp::Rails::Controller) + ActionController::Base.send(:include, Localeapp::Rails::Controller) if ::Rails::VERSION::MAJOR == 2 && ::Rails::VERSION::MINOR >= 3 # TODO: Check previous rails versions if required - require 'locale_app/rails/2_3_translation_helper_monkeypatch' + require 'localeapp/rails/2_3_translation_helper_monkeypatch' end - LocaleApp.configure do |config| + Localeapp.configure do |config| config.logger = rails_logger config.environment_name = rails_env config.project_root = rails_root - config.synchronization_data_file = File.join([rails_root, 'log', 'locale_app.yml']) + config.synchronization_data_file = File.join([rails_root, 'log', 'localeapp.yml']) config.translation_data_directory = File.join([rails_root, 'config', 'locales']) end initialize_synchronization_data_file end def self.initialize_synchronization_data_file - if !File.exists?(LocaleApp.configuration.synchronization_data_file) - File.open(LocaleApp.configuration.synchronization_data_file, 'w') do |f| + if !File.exists?(Localeapp.configuration.synchronization_data_file) + File.open(Localeapp.configuration.synchronization_data_file, 'w') do |f| f.write({:polled_at => Time.now.to_i, :updated_at => Time.now.to_i}.to_yaml) end end @@ -46,8 +46,8 @@ def self.initialize_synchronization_data_file end if defined?(Rails) - require 'locale_app/rails/controller' - require 'locale_app/exception_handler' - LocaleApp::Rails.initialize - LocaleApp.log('Loaded locale_app/rails') + require 'localeapp/rails/controller' + require 'localeapp/exception_handler' + Localeapp::Rails.initialize + Localeapp.log('Loaded localeapp/rails') end diff --git a/lib/localeapp/rails/2_3_translation_helper_monkeypatch.rb b/lib/localeapp/rails/2_3_translation_helper_monkeypatch.rb index 42ab63a..b63c0d7 100644 --- a/lib/localeapp/rails/2_3_translation_helper_monkeypatch.rb +++ b/lib/localeapp/rails/2_3_translation_helper_monkeypatch.rb @@ -2,7 +2,7 @@ # This means the exception handler will be called and missing translations get sent to # localeapp. It's ugly but there's no other way to do it :( -module LocaleApp::TranslationHelperMonkeyPatch +module Localeapp::TranslationHelperMonkeyPatch # Delegates to I18n#translate but also performs two additional functions. First, it'll catch MissingTranslationData exceptions # and turn them into inline spans that contains the missing key, such that you can see in a view what is missing where. # @@ -33,4 +33,4 @@ def translate(keys, options = {}) alias :t :translate end -ActionView::Base.send(:include, ::LocaleApp::TranslationHelperMonkeyPatch) +ActionView::Base.send(:include, ::Localeapp::TranslationHelperMonkeyPatch) diff --git a/lib/localeapp/rails/controller.rb b/lib/localeapp/rails/controller.rb index 03f8e6e..adcf5ca 100644 --- a/lib/localeapp/rails/controller.rb +++ b/lib/localeapp/rails/controller.rb @@ -1,4 +1,4 @@ -module LocaleApp +module Localeapp module Rails module Controller def self.included(base) @@ -7,27 +7,27 @@ def self.included(base) end def handle_translation_updates - unless ::LocaleApp.configuration.polling_disabled? - ::LocaleApp.log Time.now.to_i.to_s << '-- Handling translation updates' - if ::LocaleApp.poller.needs_polling? - ::LocaleApp.log Time.now.to_i.to_s << ' - polling' - ::LocaleApp.poller.poll! + unless ::Localeapp.configuration.polling_disabled? + ::Localeapp.log Time.now.to_i.to_s << '-- Handling translation updates' + if ::Localeapp.poller.needs_polling? + ::Localeapp.log Time.now.to_i.to_s << ' - polling' + ::Localeapp.poller.poll! end end - unless ::LocaleApp.configuration.reloading_disabled? - if ::LocaleApp.poller.needs_reloading? - ::LocaleApp.log Time.now.to_i.to_s << '- reloading I18n' + unless ::Localeapp.configuration.reloading_disabled? + if ::Localeapp.poller.needs_reloading? + ::Localeapp.log Time.now.to_i.to_s << '- reloading I18n' I18n.reload! - ::LocaleApp.poller.updated_at = ::LocaleApp.poller.synchronization_data[:updated_at] + ::Localeapp.poller.updated_at = ::Localeapp.poller.synchronization_data[:updated_at] end end end def send_missing_translations - return if ::LocaleApp.configuration.sending_disabled? + return if ::Localeapp.configuration.sending_disabled? - ::LocaleApp.sender.post_missing_translations + ::Localeapp.sender.post_missing_translations end end end diff --git a/lib/localeapp/routes.rb b/lib/localeapp/routes.rb index 79dbb34..951ec7e 100644 --- a/lib/localeapp/routes.rb +++ b/lib/localeapp/routes.rb @@ -1,4 +1,4 @@ -module LocaleApp +module Localeapp module Routes VERSION = 'v1' @@ -48,15 +48,15 @@ def import_url(options={}) private def base_options - options = {:host => LocaleApp.configuration.host, :port => LocaleApp.configuration.port} - if LocaleApp.configuration.http_auth_username - options[:userinfo] = "#{LocaleApp.configuration.http_auth_username}:#{LocaleApp.configuration.http_auth_password}" + options = {:host => Localeapp.configuration.host, :port => Localeapp.configuration.port} + if Localeapp.configuration.http_auth_username + options[:userinfo] = "#{Localeapp.configuration.http_auth_username}:#{Localeapp.configuration.http_auth_password}" end options end def project_path(format = nil) - path = "/#{VERSION}/projects/#{LocaleApp.configuration.api_key}" + path = "/#{VERSION}/projects/#{Localeapp.configuration.api_key}" path << ".#{format}" if format path end diff --git a/lib/localeapp/sender.rb b/lib/localeapp/sender.rb index c3df53f..4087790 100644 --- a/lib/localeapp/sender.rb +++ b/lib/localeapp/sender.rb @@ -1,10 +1,10 @@ require 'rest-client' require 'json' -module LocaleApp +module Localeapp class Sender - include ::LocaleApp::ApiCall - include ::LocaleApp::Routes + include ::Localeapp::ApiCall + include ::Localeapp::Routes def post_translation(locale, key, options, value = nil) options ||= {} @@ -19,15 +19,15 @@ def post_translation(locale, key, options, value = nil) end def handle_single_translation_success(response) - LocaleApp.log([translations_url, response.code, @data.inspect].join(' - ')) + Localeapp.log([translations_url, response.code, @data.inspect].join(' - ')) end def handle_single_translation_failure(response) - LocaleApp.log([translations_url, response.code, @data.inspect].join(' - ')) + Localeapp.log([translations_url, response.code, @data.inspect].join(' - ')) end def post_missing_translations - to_send = LocaleApp.missing_translations.to_send + to_send = Localeapp.missing_translations.to_send return if to_send.empty? @data = { :translations => to_send } api_call :missing_translations, @@ -39,11 +39,11 @@ def post_missing_translations end def handle_missing_translation_success(response) - LocaleApp.log([translations_url, response.code, @data.inspect].join(' - ')) + Localeapp.log([translations_url, response.code, @data.inspect].join(' - ')) end def handle_missing_translation_failure(response) - LocaleApp.log([translations_url, response.code, @data.inspect].join(' - ')) + Localeapp.log([translations_url, response.code, @data.inspect].join(' - ')) end end end diff --git a/lib/localeapp/tasks/localeapp.rake b/lib/localeapp/tasks/localeapp.rake index ee6cab9..39cfcf0 100644 --- a/lib/localeapp/tasks/localeapp.rake +++ b/lib/localeapp/tasks/localeapp.rake @@ -1,4 +1,4 @@ -namespace :locale_app do +namespace :localeapp do desc 'Imports the en.yml file to the LocaleServer' task :import => :environment do require 'flatten' @@ -13,7 +13,7 @@ namespace :locale_app do nil ).each do |key, value| puts "#{key} => #{value}" - LocaleApp.sender.post_translation(locale, key, {}, value) + Localeapp.sender.post_translation(locale, key, {}, value) end end end diff --git a/lib/localeapp/updater.rb b/lib/localeapp/updater.rb index 906d7bf..d7a3516 100644 --- a/lib/localeapp/updater.rb +++ b/lib/localeapp/updater.rb @@ -1,9 +1,9 @@ -module LocaleApp +module Localeapp class Updater def update(data) data['locales'].each do |short_code| - filename = File.join(LocaleApp.configuration.translation_data_directory, "#{short_code}.yml") + filename = File.join(Localeapp.configuration.translation_data_directory, "#{short_code}.yml") if File.exist?(filename) translations = YAML.load(File.read(filename)) diff --git a/lib/localeapp/version.rb b/lib/localeapp/version.rb index a1b5f27..89147b0 100644 --- a/lib/localeapp/version.rb +++ b/lib/localeapp/version.rb @@ -1,3 +1,3 @@ -module LocaleApp +module Localeapp VERSION = "0.0.7" end diff --git a/localeapp.gemspec b/localeapp.gemspec index 93ef9f6..a30ea08 100644 --- a/localeapp.gemspec +++ b/localeapp.gemspec @@ -1,10 +1,10 @@ # -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) -require "locale_app/version" +require "localeapp/version" Gem::Specification.new do |s| s.name = "localeapp" - s.version = LocaleApp::VERSION + s.version = Localeapp::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Christopher Dell", "Chris McGrath"] s.email = ["chris@tigrish.com", "chris@octopod.info"] diff --git a/run_ci b/run_ci index 53d544a..962620a 100755 --- a/run_ci +++ b/run_ci @@ -1,5 +1,5 @@ #!/bin/sh source "$HOME/.rvm/scripts/rvm" -rvm gemset use $BUILD_RUBY_VERSION@locale_app +rvm gemset use $BUILD_RUBY_VERSION@localeapp bundle install rake diff --git a/spec/localeapp/api_call_spec.rb b/spec/localeapp/api_call_spec.rb index 1b90948..9efee64 100644 --- a/spec/localeapp/api_call_spec.rb +++ b/spec/localeapp/api_call_spec.rb @@ -1,15 +1,15 @@ require 'spec_helper' class ApiCallTest - include LocaleApp::ApiCall + include Localeapp::ApiCall end -describe LocaleApp::ApiCall, "#api_call(endpoint, options = {})" do +describe Localeapp::ApiCall, "#api_call(endpoint, options = {})" do it "creates an ApiCaller object and tells it to make the call" do api_call_test = ApiCallTest.new api_call = double('api_call') api_call.should_receive(:call).with(api_call_test) - LocaleApp::ApiCaller.should_receive(:new).with(:endpoint, { :foo => :bar }).and_return(api_call) + Localeapp::ApiCaller.should_receive(:new).with(:endpoint, { :foo => :bar }).and_return(api_call) api_call_test.api_call(:endpoint, { :foo => :bar }) end end diff --git a/spec/localeapp/api_caller_spec.rb b/spec/localeapp/api_caller_spec.rb index ec0b10a..ed55ee3 100644 --- a/spec/localeapp/api_caller_spec.rb +++ b/spec/localeapp/api_caller_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' -describe LocaleApp::ApiCaller, ".new(endpoint, options = {})" do +describe Localeapp::ApiCaller, ".new(endpoint, options = {})" do it "stores the endpoint and options" do - api_caller = LocaleApp::ApiCaller.new(:endpoint, :foo => :bar) + api_caller = Localeapp::ApiCaller.new(:endpoint, :foo => :bar) api_caller.endpoint.should == :endpoint api_caller.options.should == { :foo => :bar } end end -describe LocaleApp::ApiCaller, "#call(object)" do +describe Localeapp::ApiCaller, "#call(object)" do before do - @api_caller = LocaleApp::ApiCaller.new(:test) + @api_caller = Localeapp::ApiCaller.new(:test) @url = 'http://example.com/test' @api_caller.stub!(:test_endpoint).and_return([:get, @url]) @api_caller.stub!(:sleep_if_retrying) diff --git a/spec/localeapp/cli/install_spec.rb b/spec/localeapp/cli/install_spec.rb index a95be3a..d3096fa 100644 --- a/spec/localeapp/cli/install_spec.rb +++ b/spec/localeapp/cli/install_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -require 'locale_app/cli/install' +require 'localeapp/cli/install' -describe LocaleApp::CLI::Install, '.execute(key, output = $stdout)' do +describe Localeapp::CLI::Install, '.execute(key, output = $stdout)' do before(:each) do @output = StringIO.new - @command = LocaleApp::CLI::Install.new + @command = Localeapp::CLI::Install.new end it "displays error if key is nil" do diff --git a/spec/localeapp/cli/pull_spec.rb b/spec/localeapp/cli/pull_spec.rb index 70702a4..2bb0376 100644 --- a/spec/localeapp/cli/pull_spec.rb +++ b/spec/localeapp/cli/pull_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -require 'locale_app/cli/pull' +require 'localeapp/cli/pull' -describe LocaleApp::CLI::Pull, "#execute" do +describe Localeapp::CLI::Pull, "#execute" do before do @output = StringIO.new - @puller = LocaleApp::CLI::Pull.new(@output) + @puller = Localeapp::CLI::Pull.new(@output) end it "makes the api call to the translations endpoint" do @@ -20,25 +20,25 @@ end end -describe LocaleApp::CLI::Pull, "#update_backend(response)" do +describe Localeapp::CLI::Pull, "#update_backend(response)" do before do @test_data = ['test data'].to_json @output = StringIO.new - @puller = LocaleApp::CLI::Pull.new(@output) + @puller = Localeapp::CLI::Pull.new(@output) end it "calls the updater" do with_configuration do - LocaleApp.poller.stub!(:write_synchronization_data!) - LocaleApp.updater.should_receive(:update).with(['test data']) + Localeapp.poller.stub!(:write_synchronization_data!) + Localeapp.updater.should_receive(:update).with(['test data']) @puller.update_backend(@test_data) end end it "writes the synchronization data" do with_configuration do - LocaleApp.updater.stub!(:update) - LocaleApp.poller.should_receive(:write_synchronization_data!) + Localeapp.updater.stub!(:update) + Localeapp.poller.should_receive(:write_synchronization_data!) @puller.update_backend(@test_data) end end diff --git a/spec/localeapp/cli/push_spec.rb b/spec/localeapp/cli/push_spec.rb index 970129e..29991b4 100644 --- a/spec/localeapp/cli/push_spec.rb +++ b/spec/localeapp/cli/push_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe LocaleApp::CLI::Push, "#execute(file)" do +describe Localeapp::CLI::Push, "#execute(file)" do before do @output = StringIO.new - @pusher = LocaleApp::CLI::Push.new(@output) + @pusher = Localeapp::CLI::Push.new(@output) end it "creates a new file object and makes the api call to the translations endpoint" do diff --git a/spec/localeapp/cli/update_spec.rb b/spec/localeapp/cli/update_spec.rb index e0d43d8..6acc53c 100644 --- a/spec/localeapp/cli/update_spec.rb +++ b/spec/localeapp/cli/update_spec.rb @@ -1,17 +1,17 @@ require 'spec_helper' -require 'locale_app/cli/update' +require 'localeapp/cli/update' -describe LocaleApp::CLI::Update, "#execute" do +describe Localeapp::CLI::Update, "#execute" do before do @output = StringIO.new - @updater = LocaleApp::CLI::Update.new(@output) + @updater = Localeapp::CLI::Update.new(@output) end it "creates a Poller and calls poll! on it" do with_configuration do - poller = LocaleApp::Poller.new + poller = Localeapp::Poller.new poller.should_receive(:poll!) - LocaleApp::Poller.should_receive(:new).and_return(poller) + Localeapp::Poller.should_receive(:new).and_return(poller) @updater.execute end end diff --git a/spec/localeapp/configuration_spec.rb b/spec/localeapp/configuration_spec.rb index 7d8c3fd..dfb3bb4 100644 --- a/spec/localeapp/configuration_spec.rb +++ b/spec/localeapp/configuration_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe LocaleApp::Configuration do +describe Localeapp::Configuration do before(:each) do - @configuration = LocaleApp::Configuration.new + @configuration = Localeapp::Configuration.new end it "sets the host by default" do @@ -98,16 +98,16 @@ end end -describe LocaleApp::Configuration, "#write_initial(path)" do +describe Localeapp::Configuration, "#write_initial(path)" do it "creates a configuration file containing just the api key at the given path" do - configuration = LocaleApp::Configuration.new + configuration = Localeapp::Configuration.new configuration.api_key = "APIKEY" path = 'test_path' file = stub('file') file.should_receive(:write).with <<-CONTENT -require 'locale_app/rails' +require 'localeapp/rails' -LocaleApp.configure do |config| +Localeapp.configure do |config| config.api_key = 'APIKEY' config.host = 'api.localeapp.com' config.port = 80 diff --git a/spec/localeapp/exception_handler_spec.rb b/spec/localeapp/exception_handler_spec.rb index bb28368..f3a9fb8 100644 --- a/spec/localeapp/exception_handler_spec.rb +++ b/spec/localeapp/exception_handler_spec.rb @@ -1,21 +1,21 @@ require 'spec_helper' -require 'locale_app/exception_handler' +require 'localeapp/exception_handler' -describe LocaleApp::ExceptionHandler, '#call(exception, locale, key, options)' do +describe Localeapp::ExceptionHandler, '#call(exception, locale, key, options)' do before(:each) do - LocaleApp.configure do |config| + Localeapp.configure do |config| config.api_key = 'abcdef' end end it "adds the missing translation to the missing translation list" do - LocaleApp.missing_translations.should_receive(:add).with(:en, 'foo', { :baz => 'bam' }) + Localeapp.missing_translations.should_receive(:add).with(:en, 'foo', { :baz => 'bam' }) I18n.t('foo', :baz => 'bam') end it "handles when the key is an array of keys" do - LocaleApp.missing_translations.should_receive(:add).with(:en, 'foo', {}) - LocaleApp.missing_translations.should_receive(:add).with(:en, 'bar', {}) + Localeapp.missing_translations.should_receive(:add).with(:en, 'foo', {}) + Localeapp.missing_translations.should_receive(:add).with(:en, 'bar', {}) I18n.t(['foo', 'bar']) end end diff --git a/spec/localeapp/key_checker_spec.rb b/spec/localeapp/key_checker_spec.rb index cffc412..fcdb4b2 100644 --- a/spec/localeapp/key_checker_spec.rb +++ b/spec/localeapp/key_checker_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' -describe LocaleApp::KeyChecker, "#check(key)" do +describe Localeapp::KeyChecker, "#check(key)" do it "returns false and an empty hash if the response from locale app is a 404" do FakeWeb.register_uri(:get, 'http://api.localeapp.com/v1/projects/TEST_KEY.json', :body => "", :status => ['404', 'Not Found']) with_configuration do - @checker = LocaleApp::KeyChecker.new + @checker = Localeapp::KeyChecker.new end @checker.check('TEST_KEY').should == [false, {}] end @@ -12,7 +12,7 @@ it "returns true and and the parsed json hash if the response from locale app is a 200" do FakeWeb.register_uri(:get, 'http://api.localeapp.com/v1/projects/TEST_KEY.json', :body => valid_project_data.to_json, :status => ['200', 'OK']) with_configuration do - @checker = LocaleApp::KeyChecker.new + @checker = Localeapp::KeyChecker.new end @checker.check('TEST_KEY').should == [true, valid_project_data] end diff --git a/spec/localeapp/missing_translations_spec.rb b/spec/localeapp/missing_translations_spec.rb index 0b492e1..1a69eca 100644 --- a/spec/localeapp/missing_translations_spec.rb +++ b/spec/localeapp/missing_translations_spec.rb @@ -1,18 +1,18 @@ require 'spec_helper' -require 'locale_app/missing_translations' +require 'localeapp/missing_translations' -describe LocaleApp::MissingTranslations, "#add(locale, key, options = {})" do +describe Localeapp::MissingTranslations, "#add(locale, key, options = {})" do it "stores the missing translation data" do - translations = LocaleApp::MissingTranslations.new + translations = Localeapp::MissingTranslations.new translations.add(:en, 'foo', { :baz => 'bam' }) translations[:en].should include('foo') translations[:en]['foo'].options.should == { :baz => 'bam' } end end -describe LocaleApp::MissingTranslations, "#to_send" do +describe Localeapp::MissingTranslations, "#to_send" do it "returns an array of missing translation data that needs to be sent to localeapp.com" do - translations = LocaleApp::MissingTranslations.new + translations = Localeapp::MissingTranslations.new translations.add(:en, 'foo', { :baz => 'bam' }) translations.add(:es, 'bar') diff --git a/spec/localeapp/poller_spec.rb b/spec/localeapp/poller_spec.rb index 7733518..2b5e224 100644 --- a/spec/localeapp/poller_spec.rb +++ b/spec/localeapp/poller_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' -describe LocaleApp::Poller do +describe Localeapp::Poller do before do @updated_at = Time.now.to_i - with_configuration(:synchronization_data_file => LocaleAppSynchronizationData::setup(nil, @updated_at), :api_key => 'TEST_KEY') do - @poller = LocaleApp::Poller.new + with_configuration(:synchronization_data_file => LocaleappSynchronizationData::setup(nil, @updated_at), :api_key => 'TEST_KEY') do + @poller = Localeapp::Poller.new end @hash = { 'translations' => {}, 'deleted' => [], 'locales' => [] } end after do - LocaleAppSynchronizationData::destroy + LocaleappSynchronizationData::destroy end describe "#needs_reloading?" do @@ -54,7 +54,7 @@ it "passes the data through to the Updater" do FakeWeb.register_uri(:get, "http://api.localeapp.com/v1/projects/TEST_KEY/translations.json?updated_at=#{@updated_at}", :body => @hash.to_json, :status => ['200', 'OK'], :date => Time.now.httpdate) - LocaleApp.updater.should_receive(:update).with(@hash) + Localeapp.updater.should_receive(:update).with(@hash) @poller.poll! end end diff --git a/spec/localeapp/rails/controller_spec.rb b/spec/localeapp/rails/controller_spec.rb index 37de7ca..f2fcb50 100644 --- a/spec/localeapp/rails/controller_spec.rb +++ b/spec/localeapp/rails/controller_spec.rb @@ -7,64 +7,64 @@ def self.after_filter(*options) end end -require 'locale_app/rails/controller' +require 'localeapp/rails/controller' -describe LocaleApp::Rails::Controller, '#handle_translation_updates' do +describe Localeapp::Rails::Controller, '#handle_translation_updates' do before do - TestController.send(:include, LocaleApp::Rails::Controller) - with_configuration(:synchronization_data_file => LocaleAppSynchronizationData::setup) do + TestController.send(:include, Localeapp::Rails::Controller) + with_configuration(:synchronization_data_file => LocaleappSynchronizationData::setup) do @controller = TestController.new end end after do - LocaleAppSynchronizationData::destroy + LocaleappSynchronizationData::destroy end context "when polling is enabled" do before do - LocaleApp.configuration.environment_name = 'development' # reloading enabled - LocaleApp.configuration.disabled_reloading_environments << 'development' + Localeapp.configuration.environment_name = 'development' # reloading enabled + Localeapp.configuration.disabled_reloading_environments << 'development' end it "calls poller.poll! when the synchronization file's polled_at has changed" do - LocaleApp.poller.write_synchronization_data!(01234, 56789) - LocaleApp.poller.should_receive(:poll!) + Localeapp.poller.write_synchronization_data!(01234, 56789) + Localeapp.poller.should_receive(:poll!) @controller.handle_translation_updates end it "doesn't call poller.poll! when the synchronization file's polled_at is the same" do - LocaleApp.poller.should_not_receive(:poll!) + Localeapp.poller.should_not_receive(:poll!) @controller.handle_translation_updates end end context "when polling is disabled" do before do - LocaleApp.configuration.environment_name = 'production' # reloading disabled - LocaleApp.configuration.disabled_reloading_environments << 'production' + Localeapp.configuration.environment_name = 'production' # reloading disabled + Localeapp.configuration.disabled_reloading_environments << 'production' end it "doesn't poller.poll! when the synchronization file's polled_at has changed" do - LocaleApp.poller.write_synchronization_data!(01234, 56789) - LocaleApp.poller.should_not_receive(:poll!) + Localeapp.poller.write_synchronization_data!(01234, 56789) + Localeapp.poller.should_not_receive(:poll!) @controller.handle_translation_updates end it "doesn't poller.poll! when the synchronization file's polled_at is the same" do - LocaleApp.poller.should_not_receive(:poll!) + Localeapp.poller.should_not_receive(:poll!) @controller.handle_translation_updates end end context "when reloading is enabled" do before do - LocaleApp.configuration.environment_name = 'development' # reloading enabled - LocaleApp.configuration.disabled_polling_environments << 'development' + Localeapp.configuration.environment_name = 'development' # reloading enabled + Localeapp.configuration.disabled_polling_environments << 'development' end it "calls I18n.reload! when the synchronization file's updated_at has changed" do - LocaleApp.poller.write_synchronization_data!(01234, 56789) + Localeapp.poller.write_synchronization_data!(01234, 56789) I18n.should_receive(:reload!) @controller.handle_translation_updates end @@ -77,12 +77,12 @@ def self.after_filter(*options) context "when reloading is disabled" do before do - LocaleApp.configuration.environment_name = 'production' # reloading disabled - LocaleApp.configuration.disabled_polling_environments << 'production' + Localeapp.configuration.environment_name = 'production' # reloading disabled + Localeapp.configuration.disabled_polling_environments << 'production' end it "doesn't call I18n.reload! when the synchronization file's updated_at has changed" do - LocaleApp.poller.write_synchronization_data!(01234, 56789) + Localeapp.poller.write_synchronization_data!(01234, 56789) I18n.should_not_receive(:reload!) @controller.handle_translation_updates end @@ -94,24 +94,24 @@ def self.after_filter(*options) end end -describe LocaleApp::Rails::Controller, '#send_missing_translations' do +describe Localeapp::Rails::Controller, '#send_missing_translations' do before(:each) do - LocaleApp.configure do |config| + Localeapp.configure do |config| config.api_key = 'abcdef' end - TestController.send(:include, LocaleApp::Rails::Controller) + TestController.send(:include, Localeapp::Rails::Controller) @controller = TestController.new end it "does nothing when sending is disabled" do - LocaleApp.configuration.environment_name = 'test' - LocaleApp.sender.should_not_receive(:post_missing_translations) + Localeapp.configuration.environment_name = 'test' + Localeapp.sender.should_not_receive(:post_missing_translations) @controller.send_missing_translations end it "proceeds when configuration is enabled" do - LocaleApp.configuration.environment_name = 'development' - LocaleApp.sender.should_receive(:post_missing_translations) + Localeapp.configuration.environment_name = 'development' + Localeapp.sender.should_receive(:post_missing_translations) @controller.send_missing_translations end end diff --git a/spec/localeapp/routes_spec.rb b/spec/localeapp/routes_spec.rb index 9a68790..7f653dc 100644 --- a/spec/localeapp/routes_spec.rb +++ b/spec/localeapp/routes_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' class TestRoutes - include LocaleApp::Routes + include Localeapp::Routes end -describe LocaleApp::Routes do +describe Localeapp::Routes do before(:each) do @routes = TestRoutes.new @config = {:host => 'test.host', :api_key => 'API_KEY'} diff --git a/spec/localeapp/sender_spec.rb b/spec/localeapp/sender_spec.rb index b6b1ff3..65da932 100644 --- a/spec/localeapp/sender_spec.rb +++ b/spec/localeapp/sender_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' -describe LocaleApp::Sender, "#post_translation(locale, key, options, value = nil)" do +describe Localeapp::Sender, "#post_translation(locale, key, options, value = nil)" do before(:each) do with_configuration(:api_key => "TEST_KEY") do - @sender = LocaleApp::Sender.new + @sender = Localeapp::Sender.new end end @@ -22,10 +22,10 @@ end end -describe LocaleApp::Sender, "#post_missing_translations" do +describe Localeapp::Sender, "#post_missing_translations" do before(:each) do with_configuration(:api_key => 'TEST_KEY') do - @sender = LocaleApp::Sender.new + @sender = Localeapp::Sender.new end end @@ -34,7 +34,7 @@ { :key => "test.key", :locale => "en" }, { :key => "test.key2", :locale => "en" } ] - LocaleApp.missing_translations.should_receive(:to_send).and_return(missing_to_send) + Localeapp.missing_translations.should_receive(:to_send).and_return(missing_to_send) data = { :translations => missing_to_send } # have to stub RestClient here as FakeWeb doesn't support looking at the post body yet RestClient.should_receive(:post).with(@sender.missing_translations_url, data.to_json, :content_type => :json).and_return(double('response', :code => 200)) @@ -42,7 +42,7 @@ end it "does nothing if there are no missing translations to send" do - LocaleApp.missing_translations.should_receive(:to_send).and_return([]) + Localeapp.missing_translations.should_receive(:to_send).and_return([]) RestClient.should_not_receive(:post) @sender.post_missing_translations end diff --git a/spec/localeapp/updater_spec.rb b/spec/localeapp/updater_spec.rb index 46608dc..baa3642 100644 --- a/spec/localeapp/updater_spec.rb +++ b/spec/localeapp/updater_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' -describe LocaleApp::Updater, ".update(data)" do +describe Localeapp::Updater, ".update(data)" do before(:each) do @yml_dir = Dir.mktmpdir Dir.glob(File.join(File.dirname(__FILE__), '..', 'fixtures', '*.yml')).each { |f| FileUtils.cp f, @yml_dir } with_configuration(:translation_data_directory => @yml_dir) do - @updater = LocaleApp::Updater.new + @updater = Localeapp::Updater.new end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 86a7425..67f0cf3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,13 +1,13 @@ require 'i18n' -require 'locale_app' +require 'localeapp' require 'fakeweb' -require 'support/locale_app_integration_data' -require 'support/locale_app_synchronization_data' +require 'support/localeapp_integration_data' +require 'support/localeapp_synchronization_data' require 'logger' def with_configuration(options = {}) - LocaleApp.configuration = nil - LocaleApp.configure do |configuration| + Localeapp.configuration = nil + Localeapp.configure do |configuration| options.each do |option, value| configuration.send("#{option}=", value) end @@ -16,8 +16,8 @@ def with_configuration(options = {}) end RSpec.configure do |config| - config.include(LocaleAppIntegrationData) - config.include(LocaleAppSynchronizationData) + config.include(LocaleappIntegrationData) + config.include(LocaleappSynchronizationData) config.before(:each) do FakeWeb.allow_net_connect = false end diff --git a/spec/support/localeapp_integration_data.rb b/spec/support/localeapp_integration_data.rb index f404ded..050c7dd 100644 --- a/spec/support/localeapp_integration_data.rb +++ b/spec/support/localeapp_integration_data.rb @@ -1,7 +1,7 @@ # This module is the source for all data that simulates what the real app would return. # It's included in the specs and cucumber tests, so if our format changes we # should only have to change here -module LocaleAppIntegrationData +module LocaleappIntegrationData def valid_project_data { 'name' => "Test Project", diff --git a/spec/support/localeapp_synchronization_data.rb b/spec/support/localeapp_synchronization_data.rb index 3719b49..de6bf63 100644 --- a/spec/support/localeapp_synchronization_data.rb +++ b/spec/support/localeapp_synchronization_data.rb @@ -1,4 +1,4 @@ -module LocaleAppSynchronizationData +module LocaleappSynchronizationData def self.file(dir) File.join(dir, 'test_sync.yml') end