Skip to content

Commit

Permalink
* Replaced all instances of 'locale_app' with 'localeapp' * Replaced …
Browse files Browse the repository at this point in the history
…all instances of 'LocaleApp' with 'Localeapp'
  • Loading branch information
tigrish committed Aug 23, 2011
1 parent 025ded8 commit a2ea2be
Show file tree
Hide file tree
Showing 45 changed files with 247 additions and 247 deletions.
2 changes: 1 addition & 1 deletion .rvmrc
@@ -1 +1 @@
rvm ruby-1.9.2@locale_app
rvm ruby-1.9.2@localeapp
18 changes: 9 additions & 9 deletions 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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -53,8 +53,8 @@ Usage: localeapp COMMAND [ARGS]
Commands:
install <api_key> - Creates new configuration files and confirms key works
pull - Pulls all translations from LocaleApp.com
push <file> - Pushes a translation file to LocaleApp.com
pull - Pulls all translations from localeapp.com
push <file> - 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
Expand Down
26 changes: 13 additions & 13 deletions features/localeapp_binary.feature
Expand Up @@ -9,7 +9,7 @@ Feature: localeapp executable
Commands:
install <api_key> - 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
Expand All @@ -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!
Expand All @@ -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
Expand All @@ -47,16 +47,16 @@ 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
"""
And a directory named "config/locales"
When I run `localeapp pull`
Then the output should contain:
"""
LocaleApp Pull
Localeapp Pull
Fetching translations:
Success!
Expand All @@ -70,16 +70,16 @@ 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 an empty file named "config/locales/en.yml"
When I run `localeapp push config/locales/en.yml`
Then the output should contain:
"""
LocaleApp Push
Localeapp Push
Pushing file:
Success!
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions 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']}"

Expand Down
2 changes: 1 addition & 1 deletion init.rb
@@ -1 +1 @@
require 'locale_app'
require 'localeapp'
44 changes: 22 additions & 22 deletions lib/localeapp.rb
Expand Up @@ -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
Expand All @@ -72,7 +72,7 @@ def logger
end

# @example Configuration
# LocaleApp.configure do |config|
# Localeapp.configure do |config|
# config.api_key = '1234567890abcdef'
# end
def configure
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions 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
Expand Down
16 changes: 8 additions & 8 deletions 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)

Expand All @@ -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
Expand All @@ -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)
Expand All @@ -61,15 +61,15 @@ 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

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
Expand Down
14 changes: 7 additions & 7 deletions 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?
Expand All @@ -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"
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions 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:"
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions 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
Expand Down

0 comments on commit a2ea2be

Please sign in to comment.