localeapp 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -7
- data/Gemfile.github_project.rb +2 -2
- data/bin/localeapp +18 -51
- data/features/add.feature +46 -0
- data/features/bad_command.feature +8 -0
- data/features/help.feature +9 -0
- data/features/install.feature +70 -0
- data/features/pull.feature +46 -0
- data/features/push.feature +57 -0
- data/features/update.feature +44 -0
- data/lib/localeapp/cli/add.rb +1 -5
- data/lib/localeapp/cli/command.rb +34 -0
- data/lib/localeapp/cli/daemon.rb +54 -0
- data/lib/localeapp/cli/install.rb +16 -15
- data/lib/localeapp/cli/pull.rb +1 -5
- data/lib/localeapp/cli/push.rb +1 -5
- data/lib/localeapp/cli/update.rb +1 -5
- data/lib/localeapp/configuration.rb +23 -63
- data/lib/localeapp/default_value_handler.rb +1 -9
- data/lib/localeapp/version.rb +1 -1
- data/lib/localeapp.rb +12 -15
- data/spec/localeapp/cli/add_spec.rb +1 -1
- data/spec/localeapp/cli/daemon_spec.rb +38 -0
- data/spec/localeapp/cli/install_spec.rb +10 -10
- data/spec/localeapp/cli/pull_spec.rb +2 -2
- data/spec/localeapp/cli/push_spec.rb +2 -2
- data/spec/localeapp/cli/update_spec.rb +1 -1
- data/spec/localeapp/configuration_spec.rb +39 -186
- data/spec/localeapp/default_value_handler_spec.rb +4 -13
- data/spec/localeapp/sender_spec.rb +0 -21
- metadata +57 -41
- data/features/localeapp_binary.feature +0 -210
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# Version 0.6.0
|
2
|
+
|
3
|
+
* Support passing -k or --api-key option to commands
|
4
|
+
* Remove deprecated disabled_* configuration options
|
5
|
+
* Fix performance bug when :default specified in I18n.t call
|
6
|
+
|
1
7
|
# Version 0.5.2
|
2
8
|
|
3
9
|
* Fix bug with pulling translations changing file permissions
|
@@ -80,10 +86,3 @@
|
|
80
86
|
* Removed some unnecessary default options from config files generated with
|
81
87
|
`localeapp install`
|
82
88
|
* Fixed `localeapp push` with no arguments
|
83
|
-
|
84
|
-
## NOTICE
|
85
|
-
|
86
|
-
If you've added disabled_polling_environments,
|
87
|
-
disabled_reloading_environments or disabled_sending_environments to your
|
88
|
-
initializer you should change these to polling_environments,
|
89
|
-
reloading_environments and sending_environments and configure as per the README
|
data/Gemfile.github_project.rb
CHANGED
data/bin/localeapp
CHANGED
@@ -14,13 +14,6 @@ if ENV['FAKE_WEB_DURING_CUCUMBER_RUN'] && fake_data_as_json = ENV['FAKE_WEB_FAKE
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def initialize_config
|
18
|
-
unless Localeapp.initialize_config
|
19
|
-
puts "Could not load config file"
|
20
|
-
exit 1
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
17
|
require 'gli'
|
25
18
|
gli2 = GLI::VERSION >= '2.0.0'
|
26
19
|
|
@@ -30,9 +23,22 @@ else
|
|
30
23
|
include GLI
|
31
24
|
end
|
32
25
|
|
26
|
+
pre do |global_options, command, options, args|
|
27
|
+
if Localeapp.has_config_file? || !global_options[:k].nil?
|
28
|
+
true
|
29
|
+
else
|
30
|
+
puts "Could not load config file and no key specified"
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "API Key (for when there is no configuration file)"
|
36
|
+
flag [:k, 'api-key']
|
37
|
+
|
33
38
|
version Localeapp::VERSION
|
34
39
|
|
35
40
|
desc "Creates new configuration files and confirms key works"
|
41
|
+
skips_pre
|
36
42
|
arg_name "<api_key>"
|
37
43
|
command :install do |c|
|
38
44
|
c.desc "install configuration files in .localeapp/"
|
@@ -61,8 +67,7 @@ command :add do |c|
|
|
61
67
|
if key.nil? || args.size.zero?
|
62
68
|
exit_now! "localeapp add requires a key name and at least one translation", 1
|
63
69
|
else
|
64
|
-
|
65
|
-
Localeapp::CLI::Add.new.execute(key, *args)
|
70
|
+
Localeapp::CLI::Add.new(global_options).execute(key, *args)
|
66
71
|
end
|
67
72
|
end
|
68
73
|
end
|
@@ -70,8 +75,7 @@ end
|
|
70
75
|
desc "Pulls all translations from localeapp.com"
|
71
76
|
command :pull do |c|
|
72
77
|
c.action do |global_options, options, args|
|
73
|
-
|
74
|
-
Localeapp::CLI::Pull.new.execute
|
78
|
+
Localeapp::CLI::Pull.new(global_options).execute
|
75
79
|
end
|
76
80
|
end
|
77
81
|
|
@@ -83,8 +87,7 @@ command :push do |c|
|
|
83
87
|
exit_now! "localeapp push requires an file or directory to push", 1
|
84
88
|
else
|
85
89
|
path = args.first
|
86
|
-
|
87
|
-
pusher = Localeapp::CLI::Push.new
|
90
|
+
pusher = Localeapp::CLI::Push.new(global_options)
|
88
91
|
pusher.execute(path)
|
89
92
|
end
|
90
93
|
end
|
@@ -93,8 +96,7 @@ end
|
|
93
96
|
desc "Gets any changes since the last poll and updates the yml"
|
94
97
|
command :update do |c|
|
95
98
|
c.action do |global_options, options, args|
|
96
|
-
|
97
|
-
Localeapp::CLI::Update.new.execute
|
99
|
+
Localeapp::CLI::Update.new(global_options).execute
|
98
100
|
end
|
99
101
|
end
|
100
102
|
|
@@ -109,42 +111,7 @@ command :daemon do |c|
|
|
109
111
|
c.switch [:b, 'background']
|
110
112
|
|
111
113
|
c.action do |global_options, options, args|
|
112
|
-
|
113
|
-
|
114
|
-
interval = options[:interval].to_i
|
115
|
-
|
116
|
-
if interval <= 0
|
117
|
-
exit_now! "interval must be a positive integer greater than 0", 1
|
118
|
-
end
|
119
|
-
|
120
|
-
command = Proc.new do
|
121
|
-
loop do
|
122
|
-
Localeapp::CLI::Update.new.execute
|
123
|
-
sleep interval
|
124
|
-
end
|
125
|
-
end
|
126
|
-
if options[:background]
|
127
|
-
|
128
|
-
if File.exists? Localeapp.configuration.daemon_pid_file
|
129
|
-
begin
|
130
|
-
daemon_pid = File.read(Localeapp.configuration.daemon_pid_file)
|
131
|
-
Process.kill("QUIT", daemon_pid.to_i)
|
132
|
-
rescue Errno::ESRCH
|
133
|
-
File.delete(Localeapp.configuration.daemon_pid_file)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
STDOUT.reopen(File.open(Localeapp.configuration.daemon_log_file, 'a'))
|
138
|
-
pid = fork do
|
139
|
-
Signal.trap('HUP', 'IGNORE')
|
140
|
-
command.call
|
141
|
-
end
|
142
|
-
Process.detach(pid)
|
143
|
-
|
144
|
-
File.open(Localeapp.configuration.daemon_pid_file, 'w') {|f| f << pid}
|
145
|
-
else
|
146
|
-
command.call
|
147
|
-
end
|
114
|
+
Localeapp::CLI::Daemon.new(global_options).execute(options)
|
148
115
|
end
|
149
116
|
end
|
150
117
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
Feature: Adding a translation from the command line
|
2
|
+
|
3
|
+
Scenario: Running add
|
4
|
+
In order to add a key and translation content
|
5
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
6
|
+
And an initializer file
|
7
|
+
When I run `localeapp add foo.baz en:"test en content" es:"test es content"`
|
8
|
+
Then the output should contain:
|
9
|
+
"""
|
10
|
+
Localeapp Add
|
11
|
+
|
12
|
+
Sending key: foo.baz
|
13
|
+
Success!
|
14
|
+
"""
|
15
|
+
|
16
|
+
Scenario: Running add with no arguments
|
17
|
+
In order to add a key and translation content
|
18
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
19
|
+
And an initializer file
|
20
|
+
When I run `localeapp add`
|
21
|
+
Then the output should contain:
|
22
|
+
"""
|
23
|
+
localeapp add requires a key name and at least one translation
|
24
|
+
"""
|
25
|
+
|
26
|
+
Scenario: Running add with just a key name
|
27
|
+
In order to add a key and translation content
|
28
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
29
|
+
And an initializer file
|
30
|
+
When I run `localeapp add foo.bar`
|
31
|
+
Then the output should contain:
|
32
|
+
"""
|
33
|
+
localeapp add requires a key name and at least one translation
|
34
|
+
"""
|
35
|
+
|
36
|
+
Scenario: Running add with no initializer file, passing the key on the command line
|
37
|
+
In order to add a key and translation content
|
38
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
39
|
+
When I run `localeapp -k MYAPIKEY add foo.baz en:"test en content"`
|
40
|
+
Then the output should contain:
|
41
|
+
"""
|
42
|
+
Localeapp Add
|
43
|
+
|
44
|
+
Sending key: foo.baz
|
45
|
+
Success!
|
46
|
+
"""
|
@@ -0,0 +1,70 @@
|
|
1
|
+
Feature: Installation
|
2
|
+
|
3
|
+
Scenario: Running Rails install
|
4
|
+
In order to configure my project and check my api key is correct
|
5
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
6
|
+
And I run `localeapp install MYAPIKEY`
|
7
|
+
Then the output should contain:
|
8
|
+
"""
|
9
|
+
Localeapp Install
|
10
|
+
|
11
|
+
Checking API key: MYAPIKEY
|
12
|
+
Success!
|
13
|
+
Project: Test Project
|
14
|
+
Default Locale: en (English)
|
15
|
+
"""
|
16
|
+
And help should not be displayed
|
17
|
+
And a file named "config/initializers/localeapp.rb" should exist
|
18
|
+
And the exit status should be 0
|
19
|
+
|
20
|
+
Scenario: Running standalone install
|
21
|
+
In order to configure my non rails project and check my api key is correct
|
22
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
23
|
+
And I run `localeapp install --standalone MYAPIKEY`
|
24
|
+
Then the output should contain:
|
25
|
+
"""
|
26
|
+
Localeapp Install
|
27
|
+
|
28
|
+
Checking API key: MYAPIKEY
|
29
|
+
Success!
|
30
|
+
Project: Test Project
|
31
|
+
Default Locale: en (English)
|
32
|
+
"""
|
33
|
+
And help should not be displayed
|
34
|
+
And a file named ".localeapp/config.rb" should exist
|
35
|
+
And the exit status should be 0
|
36
|
+
|
37
|
+
Scenario: Running github install
|
38
|
+
In order to configure my public github project and check my api key is correct
|
39
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
40
|
+
And I run `localeapp install --github MYAPIKEY`
|
41
|
+
Then the output should contain:
|
42
|
+
"""
|
43
|
+
Localeapp Install
|
44
|
+
|
45
|
+
Checking API key: MYAPIKEY
|
46
|
+
Success!
|
47
|
+
Project: Test Project
|
48
|
+
Default Locale: en (English)
|
49
|
+
"""
|
50
|
+
And help should not be displayed
|
51
|
+
And a file named ".localeapp/config.rb" should exist
|
52
|
+
And a file named ".gitignore" should exist
|
53
|
+
And a file named "README.md" should exist
|
54
|
+
And the exit status should be 0
|
55
|
+
|
56
|
+
|
57
|
+
Scenario: Running install with bad api key
|
58
|
+
In order to configure my project and check my api key is correct
|
59
|
+
When I have a valid project on localeapp.com but an incorrect api key "BADAPIKEY"
|
60
|
+
And I run `localeapp install BADAPIKEY`
|
61
|
+
Then the output should contain:
|
62
|
+
"""
|
63
|
+
Localeapp Install
|
64
|
+
|
65
|
+
Checking API key: BADAPIKEY
|
66
|
+
ERROR: Project not found
|
67
|
+
"""
|
68
|
+
And help should not be displayed
|
69
|
+
And a file named "config/initializers/localeapp.rb" should not exist
|
70
|
+
And the exit status should not be 0
|
@@ -0,0 +1,46 @@
|
|
1
|
+
Feature: Pulling all translation
|
2
|
+
|
3
|
+
Scenario: Running pull
|
4
|
+
In order to retrieve my translations
|
5
|
+
Given I have a translations on localeapp.com for the project with api key "MYAPIKEY"
|
6
|
+
And an initializer file
|
7
|
+
And a directory named "config/locales"
|
8
|
+
When I run `localeapp pull`
|
9
|
+
Then the output should contain:
|
10
|
+
"""
|
11
|
+
Localeapp Pull
|
12
|
+
|
13
|
+
Fetching translations:
|
14
|
+
Success!
|
15
|
+
Updating backend:
|
16
|
+
Success!
|
17
|
+
"""
|
18
|
+
And help should not be displayed
|
19
|
+
And a file named "config/locales/en.yml" should exist
|
20
|
+
|
21
|
+
Scenario: Running pull without having a locales dir
|
22
|
+
In order to retreive my translations
|
23
|
+
Given I have a translations on localeapp.com for the project with api key "MYAPIKEY"
|
24
|
+
And an initializer file
|
25
|
+
When I run `localeapp pull`
|
26
|
+
Then the output should contain:
|
27
|
+
"""
|
28
|
+
Could not write locale file, please make sure that config/locales exists and is writeable
|
29
|
+
"""
|
30
|
+
|
31
|
+
Scenario: Running pull with no initializer file, passing the key on the command line
|
32
|
+
In order to retrieve my translations
|
33
|
+
Given I have a translations on localeapp.com for the project with api key "MYAPIKEY"
|
34
|
+
And a directory named "config/locales"
|
35
|
+
When I run `localeapp -k MYAPIKEY pull`
|
36
|
+
Then the output should contain:
|
37
|
+
"""
|
38
|
+
Localeapp Pull
|
39
|
+
|
40
|
+
Fetching translations:
|
41
|
+
Success!
|
42
|
+
Updating backend:
|
43
|
+
Success!
|
44
|
+
"""
|
45
|
+
And help should not be displayed
|
46
|
+
And a file named "config/locales/en.yml" should exist
|
@@ -0,0 +1,57 @@
|
|
1
|
+
Feature: Pushing existing translation to localeapp
|
2
|
+
|
3
|
+
Scenario: Running push on a file
|
4
|
+
In order to send my translations
|
5
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
6
|
+
And an initializer file
|
7
|
+
And an empty file named "config/locales/en.yml"
|
8
|
+
When I run `localeapp push config/locales/en.yml`
|
9
|
+
Then the output should contain:
|
10
|
+
"""
|
11
|
+
Localeapp Push
|
12
|
+
|
13
|
+
Pushing file en.yml:
|
14
|
+
Success!
|
15
|
+
|
16
|
+
config/locales/en.yml queued for processing.
|
17
|
+
"""
|
18
|
+
And help should not be displayed
|
19
|
+
|
20
|
+
Scenario: Running push on a directory
|
21
|
+
In order to send my translations
|
22
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
23
|
+
And an initializer file
|
24
|
+
And an empty file named "config/locales/en.yml"
|
25
|
+
And an empty file named "config/locales/es.yml"
|
26
|
+
When I run `localeapp push config/locales`
|
27
|
+
Then the output should contain:
|
28
|
+
"""
|
29
|
+
Localeapp Push
|
30
|
+
|
31
|
+
Pushing file en.yml:
|
32
|
+
Success!
|
33
|
+
|
34
|
+
config/locales/en.yml queued for processing.
|
35
|
+
|
36
|
+
Pushing file es.yml:
|
37
|
+
Success!
|
38
|
+
|
39
|
+
config/locales/es.yml queued for processing.
|
40
|
+
"""
|
41
|
+
And help should not be displayed
|
42
|
+
|
43
|
+
Scenario: Running push on a file with no initializer file, passing the key on the command line
|
44
|
+
In order to send my translations
|
45
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
46
|
+
And an empty file named "config/locales/en.yml"
|
47
|
+
When I run `localeapp -k MYAPIKEY push config/locales/en.yml`
|
48
|
+
Then the output should contain:
|
49
|
+
"""
|
50
|
+
Localeapp Push
|
51
|
+
|
52
|
+
Pushing file en.yml:
|
53
|
+
Success!
|
54
|
+
|
55
|
+
config/locales/en.yml queued for processing.
|
56
|
+
"""
|
57
|
+
And help should not be displayed
|
@@ -0,0 +1,44 @@
|
|
1
|
+
Feature: Getting new translations
|
2
|
+
|
3
|
+
Scenario: Running update
|
4
|
+
In order to receive the translations that have been updated since the last check
|
5
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
6
|
+
And an initializer file
|
7
|
+
And a file named "log/localeapp.yml" with:
|
8
|
+
"""
|
9
|
+
---
|
10
|
+
:updated_at: 120
|
11
|
+
:polled_at: 130
|
12
|
+
"""
|
13
|
+
And new translations for the api key "MYAPIKEY" since "120" with time "140"
|
14
|
+
And a directory named "config/locales"
|
15
|
+
When I run `localeapp update`
|
16
|
+
Then the output should contain:
|
17
|
+
"""
|
18
|
+
Localeapp update: checking for translations since 120
|
19
|
+
Found and updated new translations
|
20
|
+
"""
|
21
|
+
And help should not be displayed
|
22
|
+
And a file named "config/locales/en.yml" should exist
|
23
|
+
# check the content here
|
24
|
+
# and the localeapp.yml file
|
25
|
+
|
26
|
+
Scenario: Running update with no initializer file, passing the key on the command line
|
27
|
+
In order to receive the translations that have been updated since the last check
|
28
|
+
When I have a valid project on localeapp.com with api key "MYAPIKEY"
|
29
|
+
And a file named "log/localeapp.yml" with:
|
30
|
+
"""
|
31
|
+
---
|
32
|
+
:updated_at: 120
|
33
|
+
:polled_at: 130
|
34
|
+
"""
|
35
|
+
And new translations for the api key "MYAPIKEY" since "120" with time "140"
|
36
|
+
And a directory named "config/locales"
|
37
|
+
When I run `localeapp -k MYAPIKEY update`
|
38
|
+
Then the output should contain:
|
39
|
+
"""
|
40
|
+
Localeapp update: checking for translations since 120
|
41
|
+
Found and updated new translations
|
42
|
+
"""
|
43
|
+
And help should not be displayed
|
44
|
+
And a file named "config/locales/en.yml" should exist
|
data/lib/localeapp/cli/add.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Localeapp
|
2
|
+
module CLI
|
3
|
+
class Command
|
4
|
+
def initialize(args = {})
|
5
|
+
initialize_config(args)
|
6
|
+
@output = args[:output] || $stdout
|
7
|
+
end
|
8
|
+
|
9
|
+
# requires the Localeapp configuration
|
10
|
+
def initialize_config(args = {})
|
11
|
+
Localeapp.configure # load defaults
|
12
|
+
load_config_file
|
13
|
+
set_command_line_arguments(args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_command_line_arguments(args = {})
|
17
|
+
sanitized_args = {}
|
18
|
+
if args[:k]
|
19
|
+
sanitized_args[:api_key] = args[:k]
|
20
|
+
end
|
21
|
+
sanitized_args.each do |setting, value|
|
22
|
+
Localeapp.configuration.send("#{setting}=", value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def load_config_file
|
27
|
+
Localeapp.default_config_file_paths.each do |path|
|
28
|
+
next unless File.exists? path
|
29
|
+
require path
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Localeapp
|
2
|
+
module CLI
|
3
|
+
class Daemon < Command
|
4
|
+
def execute(options)
|
5
|
+
interval = options[:interval].to_i
|
6
|
+
|
7
|
+
if interval <= 0
|
8
|
+
exit_now! "interval must be a positive integer greater than 0", 1
|
9
|
+
end
|
10
|
+
|
11
|
+
if options[:background]
|
12
|
+
run_in_background(interval)
|
13
|
+
else
|
14
|
+
update_loop(interval)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def update_loop(interval)
|
19
|
+
loop do
|
20
|
+
do_update
|
21
|
+
sleep interval
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def do_update
|
26
|
+
Localeapp::CLI::Update.new.execute
|
27
|
+
end
|
28
|
+
|
29
|
+
def run_in_background(interval)
|
30
|
+
kill_existing
|
31
|
+
|
32
|
+
STDOUT.reopen(File.open(Localeapp.configuration.daemon_log_file, 'a'))
|
33
|
+
pid = fork do
|
34
|
+
Signal.trap('HUP', 'IGNORE')
|
35
|
+
update_loop(interval)
|
36
|
+
end
|
37
|
+
Process.detach(pid)
|
38
|
+
|
39
|
+
File.open(Localeapp.configuration.daemon_pid_file, 'w') {|f| f << pid}
|
40
|
+
end
|
41
|
+
|
42
|
+
def kill_existing
|
43
|
+
if File.exists? Localeapp.configuration.daemon_pid_file
|
44
|
+
begin
|
45
|
+
daemon_pid = File.read(Localeapp.configuration.daemon_pid_file)
|
46
|
+
Process.kill("QUIT", daemon_pid.to_i)
|
47
|
+
rescue Errno::ESRCH
|
48
|
+
File.delete(Localeapp.configuration.daemon_pid_file)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,42 +1,43 @@
|
|
1
1
|
module Localeapp
|
2
2
|
module CLI
|
3
|
-
class Install
|
3
|
+
class Install < Command
|
4
4
|
attr_accessor :config_type
|
5
5
|
|
6
|
-
def initialize
|
6
|
+
def initialize(args = {})
|
7
|
+
super
|
7
8
|
@config_type = :rails
|
8
9
|
end
|
9
10
|
|
10
|
-
def execute(key
|
11
|
-
output.puts "Localeapp Install"
|
12
|
-
output.puts ""
|
13
|
-
output.puts "Checking API key: #{key}"
|
11
|
+
def execute(key)
|
12
|
+
@output.puts "Localeapp Install"
|
13
|
+
@output.puts ""
|
14
|
+
@output.puts "Checking API key: #{key}"
|
14
15
|
if key.nil?
|
15
|
-
output.puts "ERROR: You must supply an API key"
|
16
|
+
@output.puts "ERROR: You must supply an API key"
|
16
17
|
return
|
17
18
|
end
|
18
19
|
valid_key, project_data = check_key(key)
|
19
20
|
if valid_key
|
20
|
-
output.puts "Success!"
|
21
|
-
output.puts "Project: #{project_data['name']}"
|
21
|
+
@output.puts "Success!"
|
22
|
+
@output.puts "Project: #{project_data['name']}"
|
22
23
|
localeapp_default_code = project_data['default_locale']['code']
|
23
|
-
output.puts "Default Locale: #{localeapp_default_code} (#{project_data['default_locale']['name']})"
|
24
|
+
@output.puts "Default Locale: #{localeapp_default_code} (#{project_data['default_locale']['name']})"
|
24
25
|
|
25
26
|
if config_type == :rails
|
26
27
|
if I18n.default_locale.to_s != localeapp_default_code
|
27
|
-
output.puts "WARNING: I18n.default_locale is #{I18n.default_locale}, change in config/environment.rb (Rails 2) or config/application.rb (Rails 3)"
|
28
|
+
@output.puts "WARNING: I18n.default_locale is #{I18n.default_locale}, change in config/environment.rb (Rails 2) or config/application.rb (Rails 3)"
|
28
29
|
end
|
29
30
|
config_file_path = "config/initializers/localeapp.rb"
|
30
31
|
data_directory = "config/locales"
|
31
32
|
else
|
32
33
|
if config_type == :standalone
|
33
|
-
output.puts "NOTICE: you probably want to add .localeapp to your .gitignore file"
|
34
|
+
@output.puts "NOTICE: you probably want to add .localeapp to your .gitignore file"
|
34
35
|
end
|
35
36
|
config_file_path = ".localeapp/config.rb"
|
36
37
|
data_directory = "locales"
|
37
38
|
end
|
38
39
|
|
39
|
-
output.puts "Writing configuration file to #{config_file_path}"
|
40
|
+
@output.puts "Writing configuration file to #{config_file_path}"
|
40
41
|
if config_type == :github
|
41
42
|
write_github_configuration_file config_file_path, project_data
|
42
43
|
else
|
@@ -44,11 +45,11 @@ module Localeapp
|
|
44
45
|
end
|
45
46
|
|
46
47
|
unless File.directory?(data_directory)
|
47
|
-
output.puts "WARNING: please create the #{data_directory} directory. Your translation data will be stored there."
|
48
|
+
@output.puts "WARNING: please create the #{data_directory} directory. Your translation data will be stored there."
|
48
49
|
end
|
49
50
|
true
|
50
51
|
else
|
51
|
-
output.puts "ERROR: Project not found"
|
52
|
+
@output.puts "ERROR: Project not found"
|
52
53
|
false
|
53
54
|
end
|
54
55
|
end
|
data/lib/localeapp/cli/pull.rb
CHANGED
data/lib/localeapp/cli/push.rb
CHANGED
data/lib/localeapp/cli/update.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
module Localeapp
|
2
2
|
module CLI
|
3
|
-
class Update
|
4
|
-
def initialize(output = $stdout)
|
5
|
-
@output = output
|
6
|
-
end
|
7
|
-
|
3
|
+
class Update < Command
|
8
4
|
def execute
|
9
5
|
poller = Localeapp::Poller.new
|
10
6
|
@output.puts("Localeapp update: checking for translations since #{poller.updated_at}")
|