onesky-rails 1.3.1 → 1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98c442ba47c28237b26cb4eeff0937fcf0356d1e
|
4
|
+
data.tar.gz: 290c1c4ef1fbc4e11f11c1dab1eb6fa5873f5fd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6560820aa8c5646dfd01deb01cafba66674f9bd5e776b0c8bdc2d4a79ea22f81c2667d6c696bcdf3c6d91b254aad805397c93fd4f371fe8033df0247fc61fff1
|
7
|
+
data.tar.gz: cdbac164fda226f0d1cef2caf7115c79fb7f247116ad6e66ca0d37c4d3ccdfc553f68eedbf1dd1c3a74253f89c151fc40a82ede666ac202331367616f7ab232c
|
@@ -87,7 +87,11 @@ NOTICE
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def get_default_locale_files(string_path)
|
90
|
+
string_path = Pathname.new(string_path)
|
91
|
+
locale_files_filter = generate_locale_files_filter
|
90
92
|
Dir.glob("#{string_path}/**/*.yml").map do |path|
|
93
|
+
relative_path = Pathname.new(path).relative_path_from(string_path).to_s
|
94
|
+
next if locale_files_filter && !locale_files_filter.call(relative_path)
|
91
95
|
content_hash = YAML.load_file(path)
|
92
96
|
path if content_hash && content_hash.has_key?(@base_locale.to_s)
|
93
97
|
end.compact
|
@@ -104,9 +108,28 @@ NOTICE
|
|
104
108
|
end
|
105
109
|
|
106
110
|
def is_keep_strings?
|
107
|
-
return true unless
|
111
|
+
return true unless upload_config.has_key?('is_keeping_all_strings')
|
108
112
|
|
109
|
-
|
113
|
+
!!upload_config['is_keeping_all_strings']
|
114
|
+
end
|
115
|
+
|
116
|
+
def generate_locale_files_filter
|
117
|
+
only = Array(upload_config['only'])
|
118
|
+
except = Array(upload_config['except'])
|
119
|
+
|
120
|
+
if only.any? && except.any?
|
121
|
+
raise ArgumentError, "Invalid config. Can't use both `only` and `except` options."
|
122
|
+
end
|
123
|
+
|
124
|
+
if only.any?
|
125
|
+
->(path) { only.include?(path) }
|
126
|
+
elsif except.any?
|
127
|
+
->(path) { !except.include?(path) }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def upload_config
|
132
|
+
@config['upload'] ||= {}
|
110
133
|
end
|
111
134
|
|
112
135
|
end
|
data/lib/onesky/rails/version.rb
CHANGED
@@ -19,13 +19,37 @@ describe Onesky::Rails::FileClient do
|
|
19
19
|
FileUtils.remove_dir(file_path) if File.directory?(file_path)
|
20
20
|
end
|
21
21
|
|
22
|
+
def create_config_hash_with_upload_options(upload_options)
|
23
|
+
create_config_hash.tap do |config|
|
24
|
+
config['upload'].merge!(upload_options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
22
28
|
context '#upload' do
|
23
|
-
|
29
|
+
before(:each) do
|
24
30
|
stub_request(:post, full_path_with_auth_hash("/projects/#{config_hash['project_id']}/files", config_hash['api_key'], config_hash['api_secret']))
|
25
31
|
.to_return(status: 201)
|
32
|
+
end
|
26
33
|
|
34
|
+
it 'all translation files to onesky' do
|
27
35
|
expect(client.upload(file_path)).to match_array(["#{file_path}/en.yml","#{file_path}/menu.yml"])
|
28
36
|
end
|
37
|
+
|
38
|
+
context 'with `only` option' do
|
39
|
+
let(:config_hash) { create_config_hash_with_upload_options('only' => 'menu.yml') }
|
40
|
+
|
41
|
+
it 'matching translation files to onesky' do
|
42
|
+
expect(client.upload(file_path)).to match_array(["#{file_path}/menu.yml"])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'with `except` option' do
|
47
|
+
let(:config_hash) { create_config_hash_with_upload_options('except' => 'menu.yml') }
|
48
|
+
|
49
|
+
it 'matching translation files to onesky' do
|
50
|
+
expect(client.upload(file_path)).to match_array(["#{file_path}/en.yml"])
|
51
|
+
end
|
52
|
+
end
|
29
53
|
end
|
30
54
|
|
31
55
|
context 'download' do
|
@@ -93,6 +117,32 @@ describe Onesky::Rails::FileClient do
|
|
93
117
|
end
|
94
118
|
end
|
95
119
|
|
120
|
+
context 'with `only` option' do
|
121
|
+
let(:config_hash) { create_config_hash_with_upload_options('only' => 'menu.yml') }
|
122
|
+
let(:expected_locale_files) { ["#{locale_dir(locale)}/menu.yml"] }
|
123
|
+
let(:locale) { 'ja' }
|
124
|
+
|
125
|
+
it 'downloads matching translation from OneSky and save as YAML files' do
|
126
|
+
prepare_download_requests!(locale)
|
127
|
+
expect(locale_files(locale)).to be_empty
|
128
|
+
client.download(file_path)
|
129
|
+
expect(locale_files(locale)).to match_array(expected_locale_files)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'with `except` option' do
|
134
|
+
let(:config_hash) { create_config_hash_with_upload_options('except' => 'menu.yml') }
|
135
|
+
let(:expected_locale_files) { ["#{locale_dir(locale)}/ja.yml"] }
|
136
|
+
let(:locale) { 'ja' }
|
137
|
+
|
138
|
+
it 'downloads matching translation from OneSky and save as YAML files' do
|
139
|
+
prepare_download_requests!(locale)
|
140
|
+
expect(locale_files(locale)).to be_empty
|
141
|
+
client.download(file_path)
|
142
|
+
expect(locale_files(locale)).to match_array(expected_locale_files)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
96
146
|
def prepare_download_requests!(locale)
|
97
147
|
Timecop.freeze
|
98
148
|
file_names.keys.each do |file_name|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onesky-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Lam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
version: '0'
|
163
163
|
requirements: []
|
164
164
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.5.1
|
166
166
|
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: Rails plugin to sync string files with OneSky
|