web_translate_it 2.1.6 → 2.1.7

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
  SHA1:
3
- metadata.gz: 8840c157cbda25ab687330a0a169e38305963efd
4
- data.tar.gz: 7c525d74126a800ba7c39772dc81607f7012e938
3
+ metadata.gz: 997264353b0b8bb1bc5b8f92833a32de153cb2b9
4
+ data.tar.gz: eef60ff25069f6ebc2567548c6f5a98b81891979
5
5
  SHA512:
6
- metadata.gz: 384ebc9cc632375ec5fcec6922790e4dc7a72eef4ab03fa3fcf1385ab3365304a0c2cd2612770080c4a3cc70fdeaba01d1ae9887b02d88aa8437d6554f434b1a
7
- data.tar.gz: 21b018dbc2ab1546bb9b432e904e3ef93cbdb9445f57eebccda07f4f55d739fcab5e842d02656954cf9fe5ff5da2a1f2a00ed365d59210c0b0755e5849a57372
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
- WebTranslateIt::fetch_translations unless env['REQUEST_PATH'] =~ /\.(js|css|jpeg|jpg|gif|png|woff)$/
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
- files.concat configuration.files.find_all{ |file| file.locale == locale }
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."
@@ -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.lang) }.each do |file|
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
@@ -1,2 +1,7 @@
1
1
  require File.expand_path('../../lib/web_translate_it', __FILE__)
2
2
  require 'rspec'
3
+
4
+ class I18n
5
+ def self.reload!
6
+ end
7
+ end
@@ -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.6
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-02 00:00:00.000000000 Z
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