web_translate_it 2.1.6 → 2.1.7
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/bin/wti +1 -1
- data/history.md +7 -0
- data/lib/web_translate_it/auto_fetch.rb +12 -2
- data/lib/web_translate_it/command_line.rb +5 -1
- data/lib/web_translate_it.rb +1 -1
- data/spec/spec_helper.rb +5 -0
- data/spec/web_translate_it/auto_fetch_spec.rb +48 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 997264353b0b8bb1bc5b8f92833a32de153cb2b9
|
4
|
+
data.tar.gz: eef60ff25069f6ebc2567548c6f5a98b81891979
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1323c017acac6ff9daaf763667c3816e8cc0589369db420f8f9f58aaf319059b262be647135c0fcac9f02413503d40996caa5aa44071c7ea31f7a013e9a43ab6
|
7
|
+
data.tar.gz: dd45454c5273b4f3f688f66bc8bd42b8664b06a42ed3e61eed41d282e0595c4aca3b74cec10996149a0e493a1fda7bc0860bc844ffd87562b04de01bc519f15b
|
data/bin/wti
CHANGED
@@ -36,7 +36,7 @@ command_options = case command
|
|
36
36
|
when "pull"
|
37
37
|
Trollop::options do
|
38
38
|
banner <<-EOS
|
39
|
-
wti pull - Pull target language file(s)
|
39
|
+
wti pull [filename] - Pull target language file(s)
|
40
40
|
[options] are:
|
41
41
|
EOS
|
42
42
|
opt :locale, "ISO code of locale(s) to pull", :type => :string
|
data/history.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## Version 2.1.7 / 2013-08-28
|
2
|
+
|
3
|
+
* New: Ability to pull a specific file or directory.
|
4
|
+
Examples: `wti pull path/to/file.json` to pull a file.
|
5
|
+
`wti pull config/locales/javascript/*` to pull all the files in the `config/locales/javascript directory.
|
6
|
+
* Bug fixes to autofetch.
|
7
|
+
|
1
8
|
## Version 2.1.6 / 2013-08-02
|
2
9
|
|
3
10
|
* Commands now display more information, such as the current project’s name.
|
@@ -15,9 +15,19 @@ module WebTranslateIt
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def call(env)
|
18
|
-
|
19
|
-
I18n.reload!
|
18
|
+
update_translations if valid_request?(env)
|
20
19
|
@app.call(env)
|
21
20
|
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def update_translations
|
25
|
+
WebTranslateIt.fetch_translations
|
26
|
+
I18n.reload!
|
27
|
+
end
|
28
|
+
|
29
|
+
def valid_request?(env)
|
30
|
+
!(env['PATH_INFO'] =~ /\.(js|css|jpeg|jpg|gif|png|woff)$/)
|
31
|
+
end
|
22
32
|
end
|
23
33
|
end
|
@@ -36,7 +36,11 @@ module WebTranslateIt
|
|
36
36
|
# Selecting files to pull
|
37
37
|
files = []
|
38
38
|
fetch_locales_to_pull.each do |locale|
|
39
|
-
|
39
|
+
if parameters.any?
|
40
|
+
files = configuration.files.find_all{ |file| parameters.include?(file.file_path) }.sort{ |a,b| a.file_path <=> b.file_path }
|
41
|
+
else
|
42
|
+
files = configuration.files.find_all{ |file| file.locale == locale }.sort{ |a,b| a.file_path <=> b.file_path }
|
43
|
+
end
|
40
44
|
end
|
41
45
|
if files.size == 0
|
42
46
|
puts "No files to pull."
|
data/lib/web_translate_it.rb
CHANGED
@@ -23,7 +23,7 @@ module WebTranslateIt
|
|
23
23
|
return if config.ignore_locales.include?(locale)
|
24
24
|
config.logger.debug { " Fetching #{locale} language file(s) from WebTranslateIt" } if config.logger
|
25
25
|
WebTranslateIt::Connection.new(config.api_key) do |http|
|
26
|
-
config.files.find_all{ |file| file.locale.in?(locale, I18n.
|
26
|
+
config.files.find_all{ |file| file.locale.in?(locale, I18n.locale) }.each do |file|
|
27
27
|
response = file.fetch(http)
|
28
28
|
end
|
29
29
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WebTranslateIt::AutoFetch do
|
4
|
+
|
5
|
+
let(:application) { double(:application, :call => []) }
|
6
|
+
|
7
|
+
let(:env) do
|
8
|
+
{ 'PATH_INFO' => path }
|
9
|
+
end
|
10
|
+
|
11
|
+
subject { described_class.new(application) }
|
12
|
+
|
13
|
+
before { WebTranslateIt.stub(:fetch_translations) }
|
14
|
+
|
15
|
+
after { subject.call(env) }
|
16
|
+
|
17
|
+
context 'path is /' do
|
18
|
+
let(:path) { '/' }
|
19
|
+
|
20
|
+
it 'should call the application' do
|
21
|
+
application.should_receive(:call).with(env)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should update the translations' do
|
25
|
+
WebTranslateIt.should_receive(:fetch_translations)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should reload the I18n definitions' do
|
29
|
+
I18n.should_receive(:reload!)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'path is /assets/application.js' do
|
34
|
+
let(:path) { '/assets/application.js' }
|
35
|
+
|
36
|
+
it 'should call the application' do
|
37
|
+
application.should_receive(:call).with(env)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should not update the translations' do
|
41
|
+
WebTranslateIt.should_not_receive(:fetch_translations)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should not reload the I18n definitions' do
|
45
|
+
I18n.should_not_receive(:reload!)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web_translate_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edouard Briere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multipart-post
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- spec/examples/config/translation.yml
|
119
119
|
- spec/examples/en.yml
|
120
120
|
- spec/spec_helper.rb
|
121
|
+
- spec/web_translate_it/auto_fetch_spec.rb
|
121
122
|
- spec/web_translate_it/string_spec.rb
|
122
123
|
- spec/web_translate_it/term_spec.rb
|
123
124
|
homepage: https://webtranslateit.com
|
@@ -149,5 +150,6 @@ test_files:
|
|
149
150
|
- spec/examples/config/translation.yml
|
150
151
|
- spec/examples/en.yml
|
151
152
|
- spec/spec_helper.rb
|
153
|
+
- spec/web_translate_it/auto_fetch_spec.rb
|
152
154
|
- spec/web_translate_it/string_spec.rb
|
153
155
|
- spec/web_translate_it/term_spec.rb
|