localeapp 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/bin/localeapp +4 -2
- data/features/pull.feature +21 -0
- data/lib/localeapp.rb +9 -0
- data/lib/localeapp/cli/pull.rb +5 -5
- data/lib/localeapp/configuration.rb +3 -1
- data/lib/localeapp/version.rb +1 -1
- data/spec/localeapp_spec.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49934a232ff496462c5acf3466e26a4c7e420fcd
|
4
|
+
data.tar.gz: 45b94a7e5ae24ef7d2d3bf75dca90f9dd121fd25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b852479fc11e37c471f74506fc9a4db112103c4235db72509bf9bdbf503780122d7450bccab5700653295e9abbb18a2f082cd0b6bd5d87f07ea38cee1f06ecf2
|
7
|
+
data.tar.gz: d0ab7261a4d75727089ac38d3713a6581a6f036f7e9cb11baed510b815f4b37a8191a93a490094822164855518e20ba12c6aa362fa8fab301b11e309db95d455
|
data/CHANGELOG.md
CHANGED
data/bin/localeapp
CHANGED
@@ -138,10 +138,12 @@ module LocaleappGLIWrapper
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
desc "Pulls all translations from localeapp.com"
|
141
|
+
desc "Pulls one or all translations from localeapp.com"
|
142
|
+
arg_name "<key> (optional)"
|
142
143
|
command :pull do |c|
|
143
144
|
c.action do |global_options, options, args|
|
144
|
-
|
145
|
+
locale_key = args[0]
|
146
|
+
Localeapp::CLI::Pull.new(global_options).execute(locale_key)
|
145
147
|
end
|
146
148
|
end
|
147
149
|
|
data/features/pull.feature
CHANGED
@@ -16,6 +16,27 @@ Feature: `pull' command
|
|
16
16
|
Success!
|
17
17
|
"""
|
18
18
|
And a file named "config/locales/en.yml" should exist
|
19
|
+
And a file named "config/locales/es.yml" should exist
|
20
|
+
|
21
|
+
Scenario: Pulls single translation
|
22
|
+
Given I have a translations on localeapp.com for the project with api key "MYAPIKEY"
|
23
|
+
And an initializer file
|
24
|
+
And a directory named "config/locales"
|
25
|
+
And a directory named "log"
|
26
|
+
When I successfully run `localeapp pull en`
|
27
|
+
Then the output should contain "Fetching en translations:"
|
28
|
+
And a file named "config/locales/en.yml" should exist
|
29
|
+
And a file named "config/locales/es.yml" should not exist
|
30
|
+
|
31
|
+
Scenario: Reports an error when a given locale is missing
|
32
|
+
Given I have a translations on localeapp.com for the project with api key "MYAPIKEY"
|
33
|
+
And an initializer file
|
34
|
+
When I run `localeapp pull err`
|
35
|
+
Then the exit status must be 1
|
36
|
+
And the output should contain:
|
37
|
+
"""
|
38
|
+
Could not find given locale
|
39
|
+
"""
|
19
40
|
|
20
41
|
Scenario: Reports an error when locales directory is missing
|
21
42
|
Given I have a translations on localeapp.com for the project with api key "MYAPIKEY"
|
data/lib/localeapp.rb
CHANGED
@@ -109,6 +109,15 @@ module Localeapp
|
|
109
109
|
load_yaml(File.read(filename))
|
110
110
|
end
|
111
111
|
|
112
|
+
def yaml_data(content, locale_key = nil)
|
113
|
+
yaml_data = Localeapp.load_yaml(content)
|
114
|
+
if locale_key
|
115
|
+
raise "Could not find given locale" unless yaml_data and yaml_data[locale_key]
|
116
|
+
yaml_data = {locale_key => yaml_data[locale_key]}
|
117
|
+
end
|
118
|
+
yaml_data
|
119
|
+
end
|
120
|
+
|
112
121
|
def env_file_path
|
113
122
|
ENV_FILE_PATH
|
114
123
|
end
|
data/lib/localeapp/cli/pull.rb
CHANGED
@@ -3,11 +3,11 @@ module Localeapp
|
|
3
3
|
class Pull < Command
|
4
4
|
include ::Localeapp::ApiCall
|
5
5
|
|
6
|
-
def execute
|
7
|
-
@
|
8
|
-
@output.puts ""
|
6
|
+
def execute(locale_key = nil)
|
7
|
+
@locale_key = locale_key
|
8
|
+
@output.puts "Localeapp Pull\n\n" \
|
9
|
+
"Fetching#{locale_key ? ' ' << locale_key : ''} translations:"
|
9
10
|
|
10
|
-
@output.puts "Fetching translations:"
|
11
11
|
api_call :export,
|
12
12
|
:success => :update_backend,
|
13
13
|
:failure => :report_failure,
|
@@ -17,7 +17,7 @@ module Localeapp
|
|
17
17
|
def update_backend(response)
|
18
18
|
@output.puts "Success!"
|
19
19
|
@output.puts "Updating backend:"
|
20
|
-
Localeapp.updater.dump(Localeapp.
|
20
|
+
Localeapp.updater.dump(Localeapp.yaml_data(response, @locale_key))
|
21
21
|
@output.puts "Success!"
|
22
22
|
Localeapp.poller.write_synchronization_data!(Time.now.to_i, Time.now.to_i)
|
23
23
|
end
|
@@ -46,7 +46,9 @@ module Localeapp
|
|
46
46
|
# (defaults to 'development')
|
47
47
|
attr_accessor :reloading_environments
|
48
48
|
|
49
|
-
# The names of environments where
|
49
|
+
# The names of environments where localeapp will poll for translations from
|
50
|
+
# Localeapp API (to check for new translations there) on every page request
|
51
|
+
# to your app's website.
|
50
52
|
# (defaults to 'development')
|
51
53
|
attr_accessor :polling_environments
|
52
54
|
|
data/lib/localeapp/version.rb
CHANGED
data/spec/localeapp_spec.rb
CHANGED
@@ -15,3 +15,20 @@ describe Localeapp, "#load_yaml(content)" do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
describe Localeapp, "#yaml_data(content, locale_key = nil)" do
|
20
|
+
let(:content) { "en:\n foo: bar" }
|
21
|
+
let(:locale_key) { "en" }
|
22
|
+
|
23
|
+
it "raises an exception if the given locale key is missing" do
|
24
|
+
with_configuration do
|
25
|
+
expect { Localeapp.yaml_data(content, "de") }.to raise_error("Could not find given locale")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "finds the given locale key" do
|
30
|
+
with_configuration do
|
31
|
+
expect(Localeapp.yaml_data(content, locale_key)).to eq({"en" => {"foo" => "bar"}})
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localeapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Dell
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-08-
|
13
|
+
date: 2017-08-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: i18n
|