copy_tuner_client 0.3.2 → 0.3.3
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/Gemfile.lock +3 -3
- data/app/assets/stylesheets/copyray.css +3 -1
- data/copy_tuner_client.gemspec +1 -1
- data/lib/copy_tuner_client/cache.rb +2 -0
- data/lib/copy_tuner_client/configuration.rb +14 -1
- data/lib/copy_tuner_client/engine.rb +4 -0
- data/lib/copy_tuner_client/rails.rb +0 -1
- data/lib/copy_tuner_client/request_sync.rb +4 -1
- data/lib/copy_tuner_client/version.rb +1 -1
- data/spec/copy_tuner_client/cache_spec.rb +20 -0
- data/spec/copy_tuner_client/configuration_spec.rb +65 -1
- data/spec/spec_helper.rb +2 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de79b5861cd1aafdf13952a2cfe8ac8a24784646
|
4
|
+
data.tar.gz: 31d8084e19e0e46852360a0e594b6876285ed739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e971aa783b8e8522b2db81c5d78b369908697d0101d1b2d412c9af52f73063de5b8c26fdaae676efdf5e1f0454e0e0c468129d08e65471571438f8756634c2db
|
7
|
+
data.tar.gz: 1d3a227b8566d7e58d33268f80ce44f91ccf1b5415ea4d3a07d3d77b856261d1707998c4a1e0eca609bb374c1f869f17f1ab7ac51fa5867aeae84f326fb863d1
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
copy_tuner_client (0.3.
|
4
|
+
copy_tuner_client (0.3.3)
|
5
5
|
i18n (>= 0.5.0)
|
6
6
|
json
|
7
7
|
|
@@ -176,7 +176,7 @@ DEPENDENCIES
|
|
176
176
|
cucumber (~> 1.3.16)
|
177
177
|
rails (~> 4.2.6)
|
178
178
|
rake
|
179
|
-
rspec (~> 2.
|
179
|
+
rspec (~> 2.99)
|
180
180
|
sham_rack
|
181
181
|
sinatra
|
182
182
|
sqlite3
|
@@ -185,4 +185,4 @@ DEPENDENCIES
|
|
185
185
|
yard
|
186
186
|
|
187
187
|
BUNDLED WITH
|
188
|
-
1.
|
188
|
+
1.14.3
|
@@ -171,7 +171,7 @@ a.copyray-toggle-button:hover {
|
|
171
171
|
background-color: #555;
|
172
172
|
}
|
173
173
|
|
174
|
-
.copy-tuner-bar__search {
|
174
|
+
input[type="text"].copy-tuner-bar__search {
|
175
175
|
-webkit-appearance: none;
|
176
176
|
-moz-appearance: none;
|
177
177
|
appearance: none;
|
@@ -180,6 +180,8 @@ a.copyray-toggle-button:hover {
|
|
180
180
|
background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0));
|
181
181
|
box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.2), inset 0 0 2px rgba(0, 0, 0, 0.2);
|
182
182
|
padding: 2px 8px;
|
183
|
+
margin: 0;
|
184
|
+
line-height: 20px;
|
183
185
|
vertical-align: middle;
|
184
186
|
color: black;
|
185
187
|
}
|
data/copy_tuner_client.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.add_development_dependency 'cucumber', '~> 1.3.16'
|
12
12
|
s.add_development_dependency 'rails', '~> 4.2.6'
|
13
13
|
s.add_development_dependency 'rake'
|
14
|
-
s.add_development_dependency 'rspec', '~> 2.
|
14
|
+
s.add_development_dependency 'rspec', '~> 2.99'
|
15
15
|
s.add_development_dependency 'sham_rack'
|
16
16
|
s.add_development_dependency 'sinatra'
|
17
17
|
s.add_development_dependency 'sqlite3'
|
@@ -21,6 +21,7 @@ module CopyTunerClient
|
|
21
21
|
@queued = {}
|
22
22
|
@started = false
|
23
23
|
@exclude_key_regexp = options[:exclude_key_regexp]
|
24
|
+
@locales = Array(options[:locales]).map(&:to_s)
|
24
25
|
end
|
25
26
|
|
26
27
|
# Returns content for the given blurb.
|
@@ -36,6 +37,7 @@ module CopyTunerClient
|
|
36
37
|
# @param value [String] the new contents of the blurb
|
37
38
|
def []=(key, value)
|
38
39
|
return if key =~ @exclude_key_regexp
|
40
|
+
return if @locales.present? && !@locales.member?(key.split('.').first)
|
39
41
|
lock { @queued[key] = value }
|
40
42
|
end
|
41
43
|
|
@@ -18,7 +18,8 @@ module CopyTunerClient
|
|
18
18
|
:client_version, :port, :protocol, :proxy_host, :proxy_pass,
|
19
19
|
:proxy_port, :proxy_user, :secure, :polling_delay, :sync_interval,
|
20
20
|
:sync_interval_staging, :sync_ignore_path_regex, :logger,
|
21
|
-
:framework, :middleware, :disable_middleware, :disable_test_translation,
|
21
|
+
:framework, :middleware, :disable_middleware, :disable_test_translation,
|
22
|
+
:ca_file, :exclude_key_regexp, :s3_host, :locales].freeze
|
22
23
|
|
23
24
|
# @return [String] The API key for your project, found on the project edit form.
|
24
25
|
attr_accessor :api_key
|
@@ -122,6 +123,9 @@ module CopyTunerClient
|
|
122
123
|
# @return [Boolean] To disable Copyray comment injection, set true
|
123
124
|
attr_accessor :disable_copyray_comment_injection
|
124
125
|
|
126
|
+
# @return [Array<Symbol>] Restrict blurb locales to upload
|
127
|
+
attr_accessor :locales
|
128
|
+
|
125
129
|
alias_method :secure?, :secure
|
126
130
|
|
127
131
|
# Instantiated from {CopyTunerClient.configure}. Sets defaults.
|
@@ -222,6 +226,14 @@ module CopyTunerClient
|
|
222
226
|
#
|
223
227
|
# When {#test?} returns +false+, the poller will be started.
|
224
228
|
def apply
|
229
|
+
self.locales ||= begin
|
230
|
+
if defined?(::Rails)
|
231
|
+
self.locales = ::Rails.application.config.i18n.available_locales.presence || Array(::Rails.application.config.i18n.default_locale)
|
232
|
+
else
|
233
|
+
self.locales = [:en]
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
225
237
|
self.client ||= Client.new(to_hash)
|
226
238
|
self.cache ||= Cache.new(client, to_hash)
|
227
239
|
poller = Poller.new(cache, to_hash)
|
@@ -239,6 +251,7 @@ module CopyTunerClient
|
|
239
251
|
@applied = true
|
240
252
|
logger.info "Client #{VERSION} ready (s3_download)"
|
241
253
|
logger.info "Environment Info: #{environment_info}"
|
254
|
+
logger.info "Available locales: #{self.locales.join(' ')}"
|
242
255
|
|
243
256
|
unless test?
|
244
257
|
process_guard.start
|
@@ -6,7 +6,9 @@ module CopyTunerClient
|
|
6
6
|
class Engine < ::Rails::Engine
|
7
7
|
initializer :initialize_copy_tuner_rails, :before => :load_config_initializers do |app|
|
8
8
|
CopyTunerClient::Rails.initialize
|
9
|
+
end
|
9
10
|
|
11
|
+
initializer :initialize_copy_tuner_hook_methods, :after => :load_config_initializers do |app|
|
10
12
|
ActiveSupport.on_load(:action_view) do
|
11
13
|
ActionView::Helpers::TranslationHelper.class_eval do
|
12
14
|
def translate_with_copyray_comment(key, options = {})
|
@@ -27,6 +29,8 @@ module CopyTunerClient
|
|
27
29
|
if CopyTunerClient.configuration.enable_middleware?
|
28
30
|
CopyTunerClient::TranslationLog.install_hook
|
29
31
|
end
|
32
|
+
|
33
|
+
require 'copy_tuner_client/simple_form_extention'
|
30
34
|
end
|
31
35
|
|
32
36
|
initializer "copy_tuner.assets.precompile", group: :all do |app|
|
@@ -93,7 +93,10 @@ module CopyTunerClient
|
|
93
93
|
body = render_without_layout(view, binding)
|
94
94
|
end
|
95
95
|
if add_rack_array
|
96
|
-
::Rack::Response.new(
|
96
|
+
::Rack::Response.new(
|
97
|
+
body, 200,
|
98
|
+
::Rack::CONTENT_TYPE => 'text/html; charset=utf-8'
|
99
|
+
).finish
|
97
100
|
else
|
98
101
|
body
|
99
102
|
end
|
@@ -46,6 +46,26 @@ describe CopyTunerClient::Cache do
|
|
46
46
|
client.uploaded.should == { 'test.key' => 'test value' }
|
47
47
|
end
|
48
48
|
|
49
|
+
it 'upload without locale filter' do
|
50
|
+
cache = build_cache
|
51
|
+
cache['en.test.key'] = 'uploaded en'
|
52
|
+
cache['ja.test.key'] = 'uploaded ja'
|
53
|
+
|
54
|
+
cache.flush
|
55
|
+
|
56
|
+
expect(client.uploaded).to eq({'en.test.key' => 'uploaded en', 'ja.test.key' => 'uploaded ja'})
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'upload with locale filter' do
|
60
|
+
cache = build_cache(locales: %(en))
|
61
|
+
cache['en.test.key'] = 'uploaded'
|
62
|
+
cache['ja.test.key'] = 'not uploaded'
|
63
|
+
|
64
|
+
cache.flush
|
65
|
+
|
66
|
+
expect(client.uploaded).to eq({'en.test.key' => 'uploaded'})
|
67
|
+
end
|
68
|
+
|
49
69
|
it "downloads changes" do
|
50
70
|
client['test.key'] = 'test value'
|
51
71
|
cache = build_cache
|
@@ -204,7 +204,7 @@ describe CopyTunerClient::Configuration do
|
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
|
-
|
207
|
+
shared_context 'stubbed configuration' do
|
208
208
|
subject { CopyTunerClient::Configuration.new }
|
209
209
|
let(:backend) { stub('i18n-backend') }
|
210
210
|
let(:cache) { stub('cache', :download => "download") }
|
@@ -222,6 +222,10 @@ shared_examples_for 'applied configuration' do
|
|
222
222
|
subject.logger = logger
|
223
223
|
apply
|
224
224
|
end
|
225
|
+
end
|
226
|
+
|
227
|
+
shared_examples_for 'applied configuration' do
|
228
|
+
include_context 'stubbed configuration'
|
225
229
|
|
226
230
|
it { should be_applied }
|
227
231
|
|
@@ -315,3 +319,63 @@ describe CopyTunerClient::Configuration, 'applied with middleware when not devel
|
|
315
319
|
middleware.should_not include(CopyTunerClient::RequestSync)
|
316
320
|
end
|
317
321
|
end
|
322
|
+
|
323
|
+
describe CopyTunerClient::Configuration, 'applied without locale filter' do
|
324
|
+
include_context 'stubbed configuration'
|
325
|
+
|
326
|
+
def apply
|
327
|
+
subject.apply
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'should have locales [:en]' do
|
331
|
+
expect(subject.locales).to eq [:en]
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
describe CopyTunerClient::Configuration, 'applied with locale filter' do
|
336
|
+
include_context 'stubbed configuration'
|
337
|
+
|
338
|
+
def apply
|
339
|
+
subject.locales = %i(en ja)
|
340
|
+
subject.apply
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'should have locales %i(en ja)' do
|
344
|
+
expect(subject.locales).to eq %i(en ja)
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
describe CopyTunerClient::Configuration, 'applied with Rails i18n config' do
|
349
|
+
def self.with_config(i18n_options)
|
350
|
+
around do |ex|
|
351
|
+
rails_defined = Object.const_defined?(:Rails)
|
352
|
+
Object.const_set :Rails, Module.new unless rails_defined
|
353
|
+
i18n = stub(i18n_options)
|
354
|
+
Rails.stubs application: stub(config: stub(i18n: i18n))
|
355
|
+
ex.run
|
356
|
+
Object.send(:remove_const, :Rails) unless rails_defined
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
def apply
|
361
|
+
subject.apply
|
362
|
+
end
|
363
|
+
|
364
|
+
context 'with available_locales' do
|
365
|
+
with_config(available_locales: %i(en ja))
|
366
|
+
include_context 'stubbed configuration'
|
367
|
+
|
368
|
+
it 'should have locales %i(en ja)' do
|
369
|
+
expect(subject.locales).to eq %i(en ja)
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
context 'with default_locale' do
|
374
|
+
with_config(available_locales: %i(ja))
|
375
|
+
include_context 'stubbed configuration'
|
376
|
+
|
377
|
+
it 'should have locales %i(ja)' do
|
378
|
+
expect(subject.locales).to eq %i(ja)
|
379
|
+
end
|
380
|
+
end
|
381
|
+
end
|
data/spec/spec_helper.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SonicGarden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '2.
|
131
|
+
version: '2.99'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '2.
|
138
|
+
version: '2.99'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: sham_rack
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|