localeapp 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e980b2b5650345f5dd313cc10d90565c933c80d
4
- data.tar.gz: 71fb78f68e8ba17a77f455959e5ae93afba5b167
3
+ metadata.gz: 49934a232ff496462c5acf3466e26a4c7e420fcd
4
+ data.tar.gz: 45b94a7e5ae24ef7d2d3bf75dca90f9dd121fd25
5
5
  SHA512:
6
- metadata.gz: 1a250730215706813c93ec256abc58726f1174e21cc13a9a3cb8579c6abf7a4718c2b055102ab989c82a83bf7f770a6016e7f5230aec7467b206db8ef3856495
7
- data.tar.gz: abbc4fdb58a0b443242893e96857ecee7630832e269244158354c99ea3cb231ffb5eda4bbd8bc1112070e0e944417e91d5ac28e085751dc3d16014aedc854393
6
+ metadata.gz: b852479fc11e37c471f74506fc9a4db112103c4235db72509bf9bdbf503780122d7450bccab5700653295e9abbb18a2f082cd0b6bd5d87f07ea38cee1f06ecf2
7
+ data.tar.gz: d0ab7261a4d75727089ac38d3713a6581a6f036f7e9cb11baed510b815f4b37a8191a93a490094822164855518e20ba12c6aa362fa8fab301b11e309db95d455
@@ -1,5 +1,9 @@
1
1
  # master
2
2
 
3
+ # Version 2.4.0
4
+
5
+ * Support pulling of single locales
6
+
3
7
  # Version 2.3.0
4
8
 
5
9
  * Report import identifier on push success
@@ -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
- Localeapp::CLI::Pull.new(global_options).execute
145
+ locale_key = args[0]
146
+ Localeapp::CLI::Pull.new(global_options).execute(locale_key)
145
147
  end
146
148
  end
147
149
 
@@ -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"
@@ -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
@@ -3,11 +3,11 @@ module Localeapp
3
3
  class Pull < Command
4
4
  include ::Localeapp::ApiCall
5
5
 
6
- def execute
7
- @output.puts "Localeapp Pull"
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.load_yaml(response))
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 updates aren't pulled
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
 
@@ -1,3 +1,3 @@
1
1
  module Localeapp
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
@@ -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.3.0
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-23 00:00:00.000000000 Z
13
+ date: 2017-08-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: i18n