copy_tuner_client 0.5.3 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,6 +1,4 @@
1
1
  require 'bundler/gem_tasks'
2
- require 'appraisal'
3
- require 'cucumber/rake/task'
4
2
  require 'rspec/core/rake_task'
5
3
  require 'yard'
6
4
 
@@ -13,14 +11,6 @@ RSpec::Core::RakeTask.new do |t|
13
11
  t.pattern = 'spec/copy_tuner_client/**/*_spec.rb'
14
12
  end
15
13
 
16
- desc 'Run cucumber features'
17
- Cucumber::Rake::Task.new do |t|
18
- t.cucumber_opts = [
19
- '--tags', '~@wip',
20
- '--format', (ENV['CUCUMBER_FORMAT'] || 'progress')
21
- ]
22
- end
23
-
24
14
  YARD::Rake::YardocTask.new do |t|
25
15
  t.files = ['lib/**/*.rb']
26
16
  end
@@ -3,15 +3,12 @@ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
3
  require 'copy_tuner_client/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.required_ruby_version = '>= 2.4.0'
6
+ s.required_ruby_version = '>= 2.5.0'
7
7
  s.add_dependency 'i18n', '>= 0.5.0'
8
8
  s.add_dependency 'json'
9
- s.add_development_dependency 'appraisal', '~> 2.1'
10
- s.add_development_dependency 'aruba', '~> 0.6.0'
11
- s.add_development_dependency 'cucumber', '~> 1.3.16'
12
- s.add_development_dependency 'rails', '~> 4.2.6'
9
+ s.add_development_dependency 'rails', '~> 5.2.4.2'
13
10
  s.add_development_dependency 'rake'
14
- s.add_development_dependency 'rspec'
11
+ s.add_development_dependency 'rspec', '3.8.0' # NOTE: 3.9.0だとundefined method `synchronize'でコケるテストがある
15
12
  s.add_development_dependency 'sham_rack'
16
13
  s.add_development_dependency 'sinatra'
17
14
  s.add_development_dependency 'sqlite3'
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "5.2.3"
5
+ gem "rails", "5.2.4.2"
6
6
 
7
7
  gemspec :path => "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "5.0.7.2"
5
+ gem "rails", "6.0.2.2"
6
6
 
7
7
  gemspec :path => "../"
@@ -19,12 +19,10 @@ module CopyTunerClient
19
19
  def self.install_hook
20
20
  I18n.class_eval do
21
21
  class << self
22
- def translate_with_copy_tuner_hook(*args)
23
- key = args[0]
24
- options = args.last.is_a?(Hash) ? args.last : {}
22
+ def translate_with_copy_tuner_hook(key, **options)
25
23
  scope = options[:scope]
26
24
  scope = scope.dup if scope.is_a?(Array) || scope.is_a?(String)
27
- result = translate_without_copy_tuner_hook(*args)
25
+ result = translate_without_copy_tuner_hook(key, **options)
28
26
 
29
27
  if key.is_a?(Array)
30
28
  key.zip(result).each { |k, v| CopyTunerClient::TranslationLog.add(I18n.normalize_keys(nil, k, scope).join('.'), v) unless v.is_a?(Array) }
@@ -33,6 +31,7 @@ module CopyTunerClient
33
31
  end
34
32
  result
35
33
  end
34
+
36
35
  if CopyTunerClient.configuration.enable_middleware?
37
36
  alias_method :translate_without_copy_tuner_hook, :translate
38
37
  alias_method :translate, :translate_with_copy_tuner_hook
@@ -1,6 +1,6 @@
1
1
  module CopyTunerClient
2
2
  # Client version
3
- VERSION = '0.5.3'.freeze
3
+ VERSION = '0.6.1'.freeze
4
4
 
5
5
  # API version being used to communicate with the server
6
6
  API_VERSION = '2.0'.freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copy_tuner_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SonicGarden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-11 00:00:00.000000000 Z
11
+ date: 2020-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -38,62 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: appraisal
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.1'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.1'
55
- - !ruby/object:Gem::Dependency
56
- name: aruba
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 0.6.0
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 0.6.0
69
- - !ruby/object:Gem::Dependency
70
- name: cucumber
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 1.3.16
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 1.3.16
83
41
  - !ruby/object:Gem::Dependency
84
42
  name: rails
85
43
  requirement: !ruby/object:Gem::Requirement
86
44
  requirements:
87
45
  - - "~>"
88
46
  - !ruby/object:Gem::Version
89
- version: 4.2.6
47
+ version: 5.2.4.2
90
48
  type: :development
91
49
  prerelease: false
92
50
  version_requirements: !ruby/object:Gem::Requirement
93
51
  requirements:
94
52
  - - "~>"
95
53
  - !ruby/object:Gem::Version
96
- version: 4.2.6
54
+ version: 5.2.4.2
97
55
  - !ruby/object:Gem::Dependency
98
56
  name: rake
99
57
  requirement: !ruby/object:Gem::Requirement
@@ -112,16 +70,16 @@ dependencies:
112
70
  name: rspec
113
71
  requirement: !ruby/object:Gem::Requirement
114
72
  requirements:
115
- - - ">="
73
+ - - '='
116
74
  - !ruby/object:Gem::Version
117
- version: '0'
75
+ version: 3.8.0
118
76
  type: :development
119
77
  prerelease: false
120
78
  version_requirements: !ruby/object:Gem::Requirement
121
79
  requirements:
122
- - - ">="
80
+ - - '='
123
81
  - !ruby/object:Gem::Version
124
- version: '0'
82
+ version: 3.8.0
125
83
  - !ruby/object:Gem::Dependency
126
84
  name: sham_rack
127
85
  requirement: !ruby/object:Gem::Requirement
@@ -214,12 +172,11 @@ extra_rdoc_files: []
214
172
  files:
215
173
  - ".babelrc"
216
174
  - ".eslintrc"
175
+ - ".github/workflows/rspec.yml"
217
176
  - ".gitignore"
218
177
  - ".rspec"
219
178
  - ".rubocop.yml"
220
179
  - ".ruby-version"
221
- - ".travis.yml"
222
- - Appraisals
223
180
  - CHANGELOG.md
224
181
  - Gemfile
225
182
  - Gemfile.lock
@@ -229,15 +186,8 @@ files:
229
186
  - app/assets/stylesheets/copyray.css
230
187
  - app/views/_copy_tuner_bar.html.erb
231
188
  - copy_tuner_client.gemspec
232
- - features/rails.feature
233
- - features/step_definitions/copycopter_server_steps.rb
234
- - features/step_definitions/rails_steps.rb
235
- - features/support/env.rb
236
- - features/support/rails_server.rb
237
- - gemfiles/5.0.gemfile
238
- - gemfiles/5.1.gemfile
239
189
  - gemfiles/5.2.gemfile
240
- - init.rb
190
+ - gemfiles/6.0.gemfile
241
191
  - lib/copy_tuner_client.rb
242
192
  - lib/copy_tuner_client/cache.rb
243
193
  - lib/copy_tuner_client/client.rb
@@ -302,23 +252,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
302
252
  requirements:
303
253
  - - ">="
304
254
  - !ruby/object:Gem::Version
305
- version: 2.4.0
255
+ version: 2.5.0
306
256
  required_rubygems_version: !ruby/object:Gem::Requirement
307
257
  requirements:
308
258
  - - ">="
309
259
  - !ruby/object:Gem::Version
310
260
  version: '0'
311
261
  requirements: []
312
- rubygems_version: 3.0.3
262
+ rubygems_version: 3.1.2
313
263
  signing_key:
314
264
  specification_version: 4
315
265
  summary: Client for the CopyTuner copy management service
316
266
  test_files:
317
- - features/rails.feature
318
- - features/step_definitions/copycopter_server_steps.rb
319
- - features/step_definitions/rails_steps.rb
320
- - features/support/env.rb
321
- - features/support/rails_server.rb
322
267
  - spec/copy_tuner_client/cache_spec.rb
323
268
  - spec/copy_tuner_client/client_spec.rb
324
269
  - spec/copy_tuner_client/configuration_spec.rb
@@ -1,19 +0,0 @@
1
- rvm:
2
- - 2.4.6
3
- - 2.5.5
4
- - 2.6.3
5
-
6
- gemfile:
7
- - gemfiles/5.0.gemfile
8
- - gemfiles/5.1.gemfile
9
- - gemfiles/5.2.gemfile
10
-
11
- matrix:
12
- exclude:
13
- - rvm: 2.6.3
14
- gemfile: gemfiles/5.0.gemfile
15
- - rvm: 2.6.3
16
- gemfile: gemfiles/5.1.gemfile
17
-
18
- before_install:
19
- - gem update bundler
data/Appraisals DELETED
@@ -1,11 +0,0 @@
1
- appraise '4.0' do
2
- gem 'rails', '4.0.13'
3
- end
4
-
5
- appraise '4.1' do
6
- gem 'rails', '4.1.16'
7
- end
8
-
9
- appraise '4.2' do
10
- gem 'rails', '4.2.8'
11
- end
@@ -1,284 +0,0 @@
1
- @disable-bundler
2
- Feature: Using copy_tuner in a rails app
3
-
4
- Background:
5
- Given I have a copy_tuner project with an api key of "abc123"
6
- When I generate a rails application
7
- And I configure the copy_tuner client with api key "abc123"
8
-
9
- Scenario: copy_tuner in the controller
10
- Given the "abc123" project has the following blurbs:
11
- | key | draft content |
12
- | en.users.index.controller-test | This is a test |
13
- When I write to "app/controllers/users_controller.rb" with:
14
- """
15
- class UsersController < ActionController::Base
16
- def index
17
- @text = t("users.index.controller-test", :default => "default")
18
- end
19
- end
20
- """
21
- When I route the "users" resource
22
- And I write to "app/views/users/index.html.erb" with:
23
- """
24
- <%= @text %>
25
- """
26
- When I start the application
27
- And I wait for changes to be synchronized
28
- Then the copy_tuner client version and environment should have been logged
29
- Then the log should contain "Downloaded translations"
30
- When I visit /users/
31
- Then the response should contain "This is a test"
32
- And I wait for changes to be synchronized
33
- And the log should not contain "DEPRECATION WARNING"
34
-
35
- Scenario: copy_tuner in the view
36
- Given the "abc123" project has the following blurbs:
37
- | key | draft content |
38
- | en.users.index.view-test | This is a test |
39
- When I write to "app/controllers/users_controller.rb" with:
40
- """
41
- class UsersController < ActionController::Base
42
- def index
43
- render
44
- end
45
- end
46
- """
47
- When I route the "users" resource
48
- And I write to "app/views/users/index.html.erb" with:
49
- """
50
- <%= t(".view-test", :default => "default") %>
51
- """
52
- When I start the application
53
- And I wait for changes to be synchronized
54
- And I visit /users/
55
- Then the response should contain "This is a test"
56
-
57
- Scenario: copy_tuner detects updates to copy
58
- Given the "abc123" project has the following blurbs:
59
- | key | draft content |
60
- | en.users.index.controller-test | Old content |
61
- When I write to "app/controllers/users_controller.rb" with:
62
- """
63
- class UsersController < ActionController::Base
64
- def index
65
- @text = t("users.index.controller-test", :default => "default")
66
- end
67
- end
68
- """
69
- When I route the "users" resource
70
- And I write to "app/views/users/index.html.erb" with:
71
- """
72
- <%= @text %>
73
- """
74
- When I start the application
75
- And I wait for changes to be synchronized
76
- And I visit /users/
77
- Then the response should contain "Old content"
78
- And I wait for changes to be synchronized
79
- When the the following blurbs are updated in the "abc123" project:
80
- | key | draft content |
81
- | en.users.index.controller-test | New content |
82
- And I wait for changes to be synchronized
83
- And I visit /users/
84
- Then the response should contain "New content"
85
-
86
- Scenario: missing key
87
- When I write to "app/controllers/users_controller.rb" with:
88
- """
89
- class UsersController < ActionController::Base
90
- def index
91
- render :action => "index"
92
- end
93
- end
94
- """
95
- When I route the "users" resource
96
- And I write to "app/views/users/index.html.erb" with:
97
- """
98
- <%= t(".404", :default => "not found") %>
99
- """
100
- When I start the application
101
- And I wait for changes to be synchronized
102
- And I visit /users/
103
- Then the response should contain "not found"
104
- And I wait for changes to be synchronized
105
- And the "abc123" project should have the following blurbs:
106
- | key | draft content |
107
- | en.users.index.404 | not found |
108
- And the log should contain "Uploaded missing translations"
109
-
110
- Scenario: copy_tuner in production
111
- Given the "abc123" project has the following blurbs:
112
- | key | published content | draft content |
113
- | en.users.index.controller-test | This is a test | Extra extra |
114
- | en.users.index.unpublished-test | | Extra extra |
115
- When I write to "app/controllers/users_controller.rb" with:
116
- """
117
- class UsersController < ActionController::Base
118
- def index
119
- @text = t("users.index.controller-test", :default => "default")
120
- @unpublished = t("users.index.unpublished-test", :default => "Unpublished")
121
- t("users.index.unknown-test", :default => "Unknown")
122
- end
123
- end
124
- """
125
- When I route the "users" resource
126
- And I write to "app/views/users/index.html.erb" with:
127
- """
128
- <%= @text %>
129
- <%= @unpublished %>
130
- """
131
- When I start the application in the "production" environment
132
- And I wait for changes to be synchronized
133
- And I visit /users/
134
- Then the response should contain "This is a test"
135
- And the response should contain "Unpublished"
136
- And I wait for changes to be synchronized
137
- And the "abc123" project should have the following blurbs:
138
- | key | draft content |
139
- | en.users.index.unknown-test | |
140
-
141
- Scenario: configure a bad api key
142
- When I configure the copy_tuner client with api key "bogus"
143
- And I start the application
144
- And I wait for changes to be synchronized
145
- Then the log should contain "Invalid API key: bogus"
146
-
147
- Scenario: deploy
148
- Given the "abc123" project has the following blurbs:
149
- | key | draft content | published content |
150
- | test.one | expected one | unexpected one |
151
- | test.two | expected two | unexpected two |
152
- When I successfully rake "copy_tuner:deploy"
153
- And I wait for changes to be synchronized
154
- And the output should contain "Successfully marked all blurbs as published"
155
- And I wait for changes to be synchronized
156
- Then the "abc123" project should have the following blurbs:
157
- | key | draft content | published content |
158
- | test.one | expected one | expected one |
159
- | test.two | expected two | expected two |
160
-
161
- Scenario: fallback on the simple I18n backend
162
- When I write to "config/locales/en.yml" with:
163
- """
164
- en:
165
- test:
166
- key: Hello, %{name}
167
- """
168
- When I write to "app/controllers/users_controller.rb" with:
169
- """
170
- class UsersController < ActionController::Base
171
- def index
172
- render :text => t("test.key", :name => 'Joe')
173
- end
174
- end
175
- """
176
- When I route the "users" resource
177
- And I start the application
178
- And I wait for changes to be synchronized
179
- And I visit /users/
180
- Then the response should contain "Hello, Joe"
181
- When I wait for changes to be synchronized
182
- Then the "abc123" project should have the following blurbs:
183
- | key | draft content |
184
- | en.test.key | Hello, %{name} |
185
-
186
- Scenario: preserve localization keys
187
- When I write to "app/controllers/users_controller.rb" with:
188
- """
189
- class UsersController < ActionController::Base
190
- def index
191
- render
192
- end
193
- end
194
- """
195
- When I route the "users" resource
196
- And I write to "app/views/users/index.html.erb" with:
197
- """
198
- <%= number_to_currency(2.5) %>
199
- """
200
- When I start the application
201
- And I wait for changes to be synchronized
202
- And I visit /users/
203
- Then the response should contain "$2.50"
204
- When I wait for changes to be synchronized
205
- Then the "abc123" project should not have the "en.number.format" blurb
206
-
207
- Scenario: view validation errors
208
- When I write to "app/models/user.rb" with:
209
- """
210
- class User < ActiveRecord::Base
211
- validates_presence_of :name
212
- end
213
- """
214
- When I write to "db/migrate/1_create_users.rb" with:
215
- """
216
- class CreateUsers < ActiveRecord::Migration
217
- def self.up
218
- create_table :users do |t|
219
- t.string :name
220
- end
221
- end
222
- end
223
- """
224
- When I write to "app/controllers/users_controller.rb" with:
225
- """
226
- class UsersController < ActionController::Base
227
- def index
228
- @user = User.new
229
- @user.valid?
230
- render
231
- end
232
- end
233
- """
234
- When I route the "users" resource
235
- And I write to "app/views/users/index.html.erb" with:
236
- """
237
- <%= @user.errors.full_messages.first %>
238
- """
239
- When I successfully rake "db:migrate RAILS_ENV=development"
240
- And I configure the copy_tuner client to use published data
241
- And I start the application
242
- And I wait for changes to be synchronized
243
- And I visit /users/
244
- Then the response should contain "Name can't be blank"
245
- When I wait for changes to be synchronized
246
- Then the "abc123" project should have the following error blurbs:
247
- | key | draft content |
248
- | user.attributes.name.blank | |
249
-
250
- Scenario: ensure keys are synced with short lived processes
251
- When I configure the copy_tuner client to have a polling delay of 86400 seconds
252
- And I start the application
253
- And I wait for changes to be synchronized
254
- And I run a short lived process that sets the key "threaded.key" to "all your base" in "development" environment
255
- And I wait for changes to be synchronized
256
- Then the "abc123" project should have the following blurbs:
257
- | key | draft content |
258
- | en.threaded.key | all your base |
259
-
260
- Scenario: support pluralization
261
- Given I write to "app/controllers/users_controller.rb" with:
262
- """
263
- class UsersController < ActionController::Base
264
- def index
265
- render
266
- end
267
- end
268
- """
269
- And I route the "users" resource
270
- And I write to "app/views/users/index.html.erb" with:
271
- """
272
- <%= time_ago_in_words(1.hour.ago) %> ago
273
- <%= time_ago_in_words(2.hours.ago) %> ago
274
- """
275
- When I start the application
276
- And I wait for changes to be synchronized
277
- And I visit /users/
278
- Then the response should contain "1 hour ago"
279
- And the response should contain "2 hours ago"
280
- When I wait for changes to be synchronized
281
- Then the "abc123" project should have the following blurbs:
282
- | key | draft content |
283
- | en.datetime.distance_in_words.about_x_hours.one | about 1 hour |
284
- | en.datetime.distance_in_words.about_x_hours.other | about %{count} hours |