localeapp 3.0.1 → 3.1.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
  SHA256:
3
- metadata.gz: 187204f032c72f78eb45ace5926a7291cb493cf3b5912deb9c94a1625044127b
4
- data.tar.gz: aa94e545971bc4cd66007f20f0c488808774f3280857264e79190192a366cc1f
3
+ metadata.gz: 632b3673659bb3b1e1cebf5d869db6d95464806fc302c286390c242749d9373a
4
+ data.tar.gz: 41d594f0e6adbfc5cc24d38c5b322edc9d0edb81266c821605267f7baa5e210e
5
5
  SHA512:
6
- metadata.gz: 9c6d8ed04be34b75f34b83d517ce8dd16c4d436b1b03bdd7cfd73414f89677b75de47ec5df3e4eb842557aebd882bc81b905d5aeffae983f69ccc8e932d11e0b
7
- data.tar.gz: 6ac0d69eff3a388880ca32e03de49d0ef4030bee7af8d402e1aba40ffa69cf5dea1924e9548dc68f89a4a67f397e27e31dc8f13fec6eebfe265f570c54c46b9f
6
+ metadata.gz: da419ba0f426a9c254f1df74e0dd33d6052cbe7764f212fe0888763ccd0419d4506db36ebe4697174253de63f22c4c3317f6f6ec9e925807fcd878bb8e445958
7
+ data.tar.gz: bc93854b79aa5660c54ea412c46bd5105da8046820242b294e0c3f80e018c409d0613329fb18b921cbb7639d7b90702f3808fd209e6100813b42ddc616bf7842
@@ -1,5 +1,9 @@
1
1
  # master
2
2
 
3
+ # Version 3.1.0
4
+
5
+ * add `localeapp cp`
6
+
3
7
  # Version 3.0.1
4
8
 
5
9
  * actually prevent `CVE-2013-0269 / OSVDB-101137` (3.0.0 was supposed to)
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Locale
2
2
 
3
- [![Build status](https://secure.travis-ci.org/Locale/localeapp.png)](http://travis-ci.org/Locale/localeapp)
4
- [![Code Climate](https://codeclimate.com/github/Locale/localeapp.png)](https://codeclimate.com/github/Locale/localeapp)
5
- [![Gem Version](https://badge.fury.io/rb/localeapp.png)](http://badge.fury.io/rb/localeapp)
3
+ [![Build status](https://secure.travis-ci.org/Locale/localeapp.svg)](http://travis-ci.org/Locale/localeapp)
4
+ [![Code Climate](https://codeclimate.com/github/Locale/localeapp.svg)](https://codeclimate.com/github/Locale/localeapp)
5
+ [![Security](https://hakiri.io/github/Locale/localeapp/master.svg)](https://hakiri.io/github/Locale/localeapp/master)
6
+ [![Gem Version](https://badge.fury.io/rb/localeapp.svg)](http://badge.fury.io/rb/localeapp)
6
7
 
7
- The localeapp gem connects your rails app to the Locale service on http://www.localeapp.com. Locale makes hand editing translation files something you don't have to do.
8
+ The `localeapp` gem connects your Rails app to the Locale service on https://www.localeapp.com. Locale makes hand editing translation files something you don't have to do.
8
9
 
9
10
  The gem hooks into the i18n exception mechanism to send missing translations to the app. When translated content has been added it's automatically pulled down so you can see it straight away.
10
11
 
@@ -91,6 +92,14 @@ You can create translations on the command line by running:
91
92
 
92
93
  You must provide at least one translation and the locale code must already exist in the project.
93
94
 
95
+ ## Copy a translation
96
+
97
+ You can copy a translation on the command line by running:
98
+
99
+ localeapp cp key.source_name key.destination_name
100
+
101
+ If the destination key name exists in the project the content is overwritten, otherwise a new key is created.
102
+
94
103
  ## Automatically pulling translations
95
104
 
96
105
  There are two ways to do this, one that suits a single developer working the code locally and one where the translations are being pulled down to a staging (or live) server.
@@ -138,6 +138,20 @@ module LocaleappGLIWrapper
138
138
  end
139
139
  end
140
140
 
141
+ desc "copies a key in the project"
142
+ arg_name "<source key name> <dest key name>"
143
+ command :cp do |c|
144
+ c.action do |global_options, options, args|
145
+ source_name = args.shift
146
+ dest_name = args.shift
147
+ if source_name.nil? || dest_name.nil?
148
+ exit_now! "localeapp cp requires a source key name and a destination key name", 1
149
+ else
150
+ Localeapp::CLI::Copy.new(global_options).execute(source_name, dest_name, *args)
151
+ end
152
+ end
153
+ end
154
+
141
155
  desc "Pulls one or all translations from localeapp.com"
142
156
  arg_name "<key> (optional)"
143
157
  command :pull do |c|
@@ -0,0 +1,19 @@
1
+ Feature: `cp' command
2
+
3
+ Scenario: Copies the given translation
4
+ Given I have a valid project on localeapp.com with api key "MYAPIKEY" and the translation key "foo.bar"
5
+ And an initializer file
6
+ When I successfully run `localeapp cp foo.bar foo.baz`
7
+ Then the output should contain:
8
+ """
9
+ Localeapp cp
10
+
11
+ Copying key: foo.bar to foo.baz
12
+ Success!
13
+ """
14
+
15
+ Scenario: Reports an error when the given API key is incorrect
16
+ Given no project exist on localeapp.com with API key "MYAPIKEY"
17
+ When I run `localeapp -k MYAPIKEY cp foo.bar foo.baz`
18
+ Then the exit status must be 70
19
+ And the output must match /error.+404/i
@@ -56,6 +56,7 @@ When /^I have a valid project on localeapp\.com with api key "([^"]*)" and the t
56
56
  uri = "https://api.localeapp.com/v1/projects/#{api_key}/translations/#{key_name.gsub(/\./, '%2E')}"
57
57
  add_fake_web_uri(:delete, uri, ['200', 'OK'], '')
58
58
  add_fake_web_uri(:post, uri + '/rename', ['200', 'OK'], '')
59
+ add_fake_web_uri(:post, uri + '/copy', ['200', 'OK'], '')
59
60
  end
60
61
 
61
62
  When /^I have a LOCALEAPP_API_KEY env variable set to "(.*?)"$/ do |api_key|
@@ -24,6 +24,7 @@ require 'localeapp/cli/update'
24
24
  require 'localeapp/cli/add'
25
25
  require 'localeapp/cli/remove'
26
26
  require 'localeapp/cli/rename'
27
+ require 'localeapp/cli/copy'
27
28
  require 'localeapp/cli/daemon'
28
29
 
29
30
  module Localeapp
@@ -0,0 +1,28 @@
1
+ module Localeapp
2
+ module CLI
3
+ class Copy < Command
4
+ include ::Localeapp::ApiCall
5
+
6
+ def execute(source_name, dest_name, *rest)
7
+ @output.puts "Localeapp cp"
8
+ @output.puts ""
9
+ @output.puts "Copying key: #{source_name} to #{dest_name}"
10
+ api_call :copy,
11
+ :url_options => { :source_name => source_name },
12
+ :payload => { :dest_name => dest_name },
13
+ :success => :report_success,
14
+ :failure => :report_failure,
15
+ :max_connection_attempts => 1
16
+ end
17
+
18
+ def report_success(response)
19
+ @output.puts "Success!"
20
+ end
21
+
22
+ def report_failure(response)
23
+ @output.puts "Failed!"
24
+ fail APIResponseError, "API returned #{response.code} status code"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -6,6 +6,7 @@ require "localeapp/routes/remove"
6
6
  require "localeapp/routes/rename"
7
7
  require "localeapp/routes/missing_translations"
8
8
  require "localeapp/routes/import"
9
+ require "localeapp/routes/copy"
9
10
 
10
11
  module Localeapp
11
12
  module Routes
@@ -19,5 +20,6 @@ module Localeapp
19
20
  include Rename
20
21
  include MissingTranslations
21
22
  include Import
23
+ include Copy
22
24
  end
23
25
  end
@@ -0,0 +1,24 @@
1
+ module Localeapp
2
+ module Routes
3
+ module Copy
4
+ def copy_endpoint(options = {})
5
+ [:post, copy_url(options)]
6
+ end
7
+
8
+ def copy_url(options = {})
9
+ url = http_scheme.build(base_options.merge(:path => copy_path(options[:source_name], options[:format])))
10
+ url.to_s
11
+ end
12
+
13
+ private
14
+
15
+ def copy_path(source_name, format = nil)
16
+ raise "copy_path requires source name" if source_name.nil?
17
+ path = translations_path << "/#{escape_key(source_name)}" << "/copy"
18
+ path << ".#{format}" if format
19
+ path
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module Localeapp
2
- VERSION = "3.0.1"
2
+ VERSION = "3.1.0"
3
3
  end
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  s.name = "localeapp"
7
7
  s.version = Localeapp::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Christopher Dell", "Chris McGrath", "Michael Baudino"]
10
- s.email = ["chris@tigrish.com", "chris@octopod.info", "michael.baudino@alpine-lab.com"]
9
+ s.authors = ["Christopher Dell", "Chris McGrath", "Michael Baudino", "Thibault Dalban"]
10
+ s.email = ["chris@tigrish.com", "chris@octopod.info", "michael.baudino@alpine-lab.com", "thibault.dalban@alpine-lab.com"]
11
11
  s.homepage = "http://www.localeapp.com"
12
12
  s.summary = %q{Easy i18n translation management with localeapp.com}
13
13
  s.description = %q{Synchronizes i18n translation keys and content with localeapp.com so you don't have to manage translations by hand.}
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe Localeapp::CLI::Copy, "#execute(source_name, dest_name, *rest)" do
4
+ def do_action(source_name = "test.source_name", dest_name = "test.dest_name")
5
+ @command.execute(source_name, dest_name)
6
+ end
7
+
8
+ before(:each) do
9
+ @output = StringIO.new
10
+ @command = Localeapp::CLI::Copy.new(:output => @output)
11
+ end
12
+
13
+ it "makes the api call to the translations endpoint with the destination name as the post body" do
14
+ with_configuration do
15
+ expect(@command).to receive(:api_call).with(
16
+ :copy,
17
+ :url_options => { :source_name => "test.source_name" },
18
+ :payload => { :dest_name => "test.dest_name" },
19
+ :success => :report_success,
20
+ :failure => :report_failure,
21
+ :max_connection_attempts => anything
22
+ )
23
+ do_action
24
+ end
25
+ end
26
+ end
@@ -124,6 +124,24 @@ describe Localeapp::Routes do
124
124
  end
125
125
  end
126
126
 
127
+ describe "#copy_endpoint(options = {})" do
128
+ it "returns :post and the copy url for the options" do
129
+ with_configuration(@config) do
130
+ options = { :source_name => "foo.bar" }
131
+ expect(@routes).to receive(:copy_url).with(options).and_return("url")
132
+ expect(@routes.copy_endpoint(options)).to eq([:post, "url"])
133
+ end
134
+ end
135
+ end
136
+
137
+ describe "#copy_url(options = {})" do
138
+ it "extends the project_url and includes the escaped key name" do
139
+ with_configuration(@config) do
140
+ expect(@routes.copy_url(:source_name => "test.key")).to eq("https://test.host/v1/projects/API_KEY/translations/test%2Ekey/copy")
141
+ end
142
+ end
143
+ end
144
+
127
145
  describe "#export_url" do
128
146
  it "it extends the project_url and defaults to yml" do
129
147
  with_configuration(@config) do
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localeapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Dell
8
8
  - Chris McGrath
9
9
  - Michael Baudino
10
+ - Thibault Dalban
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2018-03-12 00:00:00.000000000 Z
14
+ date: 2018-04-06 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: i18n
@@ -164,6 +165,7 @@ email:
164
165
  - chris@tigrish.com
165
166
  - chris@octopod.info
166
167
  - michael.baudino@alpine-lab.com
168
+ - thibault.dalban@alpine-lab.com
167
169
  executables:
168
170
  - localeapp
169
171
  extensions: []
@@ -181,6 +183,7 @@ files:
181
183
  - cucumber.yml
182
184
  - features/add.feature
183
185
  - features/bad_command.feature
186
+ - features/cp.feature
184
187
  - features/env_file.feature
185
188
  - features/environment.feature
186
189
  - features/help.feature
@@ -203,6 +206,7 @@ files:
203
206
  - lib/localeapp/api_caller.rb
204
207
  - lib/localeapp/cli/add.rb
205
208
  - lib/localeapp/cli/command.rb
209
+ - lib/localeapp/cli/copy.rb
206
210
  - lib/localeapp/cli/daemon.rb
207
211
  - lib/localeapp/cli/install.rb
208
212
  - lib/localeapp/cli/pull.rb
@@ -225,6 +229,7 @@ files:
225
229
  - lib/localeapp/rails/mimic_rails_missing_translation_display.rb
226
230
  - lib/localeapp/routes.rb
227
231
  - lib/localeapp/routes/base.rb
232
+ - lib/localeapp/routes/copy.rb
228
233
  - lib/localeapp/routes/export.rb
229
234
  - lib/localeapp/routes/import.rb
230
235
  - lib/localeapp/routes/missing_translations.rb
@@ -250,6 +255,7 @@ files:
250
255
  - spec/localeapp/api_call_spec.rb
251
256
  - spec/localeapp/api_caller_spec.rb
252
257
  - spec/localeapp/cli/add_spec.rb
258
+ - spec/localeapp/cli/copy_spec.rb
253
259
  - spec/localeapp/cli/daemon_spec.rb
254
260
  - spec/localeapp/cli/install_spec.rb
255
261
  - spec/localeapp/cli/pull_spec.rb