i18n-tasks 0.7.11 → 0.7.12

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: aaa9e7e25dff9f4b1dc1cc1050c31b0fbbb64a53
4
- data.tar.gz: 744f2ad91cc01f1fdc504e0071eb826a9c14c749
3
+ metadata.gz: a9d57ea517b4561e2eb31ddee6376bb9d65ef9c7
4
+ data.tar.gz: ddaf2b27bca1586c84625864809c970ac697e8de
5
5
  SHA512:
6
- metadata.gz: 9e26846e83a160f186aefe663ebdfc06c0ddf95467eef1e00dc98de90c72fdbde095533786f564be08ad0ad021530ff15a795484e800003e84fd6373029b2653
7
- data.tar.gz: f51de5a3004845077b9dab2c79079832a868ec9706d19126fb0e6aee73d92bcb0971318a911a33a458dbd7acc09f6f7b0fe601f4901f44eb1fdd2a107ec20cd4
6
+ metadata.gz: 669191968390c3ed44ba2537ecd51603a76f56f542c82499dbf3ce89d5c0b303085ba6d37ba40a0099c7947cf319a42e2b3513756aacf2c2f40c89dd592e9396
7
+ data.tar.gz: 88f3289f9e4734a074056d6be1d0310c2c8299c98679988664f62819cf39fa9b11ebb58df353bed86dc4fca21f72bed5bc784c5af0ba9820434e0fd18a6ead89
data/.travis.yml CHANGED
@@ -1,10 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.2.0
3
4
  - 2.1.5
4
5
  - 2.0.0
5
6
  - 1.9.3
6
7
  - jruby
7
- - rbx-2.2.10
8
+ - rbx-2.4.1
8
9
  env:
9
10
  global:
10
11
  - TRAVIS=1
data/CHANGES.md CHANGED
@@ -1,6 +1,12 @@
1
+ ## 0.7.12
2
+
3
+ * Handle relative keys in controllers nested in modules by [Alexander Tipugin](https://github.com/atipugin). [#128](https://github.com/glebm/i18n-tasks/issues/128).
4
+ * Only write files that changed [#125](https://github.com/glebm/i18n-tasks/issues/125).
5
+ * Allow `[]` in the non-strict scanner pattern [#127](https://github.com/glebm/i18n-tasks/issues/127).
6
+
1
7
  ## 0.7.11
2
8
 
3
- * Set slop dependency to 3.5 to ensure Ruby 1.9 compatibility. [#121](https://github.com/glebm/i18n-tasks/pull/121)
9
+ * Set slop dependency to 3.5 to ensure Ruby 1.9 compatibility ([#121](https://github.com/glebm/i18n-tasks/pull/121)).
4
10
  MRI 1.9 EOL is [February 23, 2015](https://www.ruby-lang.org/en/news/2014/01/10/ruby-1-9-3-will-end-on-2015/).
5
11
  We will support 1.9 until rbx and jruby support 2.0.
6
12
 
@@ -10,7 +16,7 @@
10
16
 
11
17
  ## 0.7.9
12
18
 
13
- * Support relative keys in Rails controller actions by [Jessie A. Young](https://github.com/jessieay). [#46](https://github.com/glebm/i18n-tasks/issues/46)
19
+ * Support relative keys in Rails controller actions by [Jessie A. Young](https://github.com/jessieay). [#46](https://github.com/glebm/i18n-tasks/issues/46).
14
20
  * Minor fixes
15
21
 
16
22
  ## 0.7.8
data/README.md CHANGED
@@ -22,7 +22,7 @@ i18n-tasks can be used with any project using the ruby [i18n gem][i18n-gem] (def
22
22
  Add it to the Gemfile:
23
23
 
24
24
  ```ruby
25
- gem 'i18n-tasks', '~> 0.7.11'
25
+ gem 'i18n-tasks', '~> 0.7.12'
26
26
  ```
27
27
 
28
28
  Copy default [configuration file](#configuration) (optional):
@@ -38,10 +38,16 @@ module I18n
38
38
  end
39
39
 
40
40
  def write_tree(path, tree)
41
+ hash = tree.to_hash(true)
42
+ adapter = self.class.adapter_name_for_path(path)
43
+ content = adapter_dump(hash, adapter)
44
+ # Ignore unchanged data
45
+ return if File.file?(path) &&
46
+ # Comparing hashes for equality directly would ignore key order.
47
+ # Round-trip through the adapter and compare the strings instead:
48
+ content == adapter_dump(load_file(path), adapter)
41
49
  ::FileUtils.mkpath(File.dirname path)
42
- ::File.open(path, 'w') { |f|
43
- f.write adapter_dump(tree.to_hash(true), self.class.adapter_name_for_path(path))
44
- }
50
+ ::File.open(path, 'w') { |f| f.write content }
45
51
  end
46
52
 
47
53
  module ClassMethods
@@ -128,7 +128,7 @@ module I18n::Tasks::Scanners
128
128
 
129
129
  VALID_KEY_CHARS = /[-\w.?!;]/
130
130
  VALID_KEY_RE_STRICT = /^#{VALID_KEY_CHARS}+$/
131
- VALID_KEY_RE = /^(#{VALID_KEY_CHARS}|[:\#{@}])+$/
131
+ VALID_KEY_RE = /^(#{VALID_KEY_CHARS}|[:\#{@}\[\]])+$/
132
132
 
133
133
  def valid_key?(key, strict = false)
134
134
  return false if @key_filter && @key_filter_pattern !~ key
@@ -42,7 +42,7 @@ module I18n
42
42
  file_name = normalized_path.gsub(%r(#{path_root(normalized_path, roots)}/|(\.[^/]+)*$), '')
43
43
 
44
44
  if options[:closest_method].present?
45
- "#{file_name.split('_').first}.#{options[:closest_method]}"
45
+ "#{file_name.split('_').first}.#{options[:closest_method]}".tr('/', '.')
46
46
  else
47
47
  file_name.tr('/', '.').gsub(%r(\._), '.')
48
48
  end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
  module I18n
3
3
  module Tasks
4
- VERSION = '0.7.11'
4
+ VERSION = '0.7.12'
5
5
  end
6
6
  end
@@ -9,7 +9,7 @@ describe 'Google Translation' do
9
9
  nil_value_test = ['nil-value-key', nil, nil],
10
10
  text_test = ['key', "Hello - %{user} O'neill!", "Hola - %{user} O'neill!"],
11
11
  html_test = ['html-key.html', "Hello - <b>%{user} O'neill</b>", "Hola - <b>%{user} O'neill</b>"],
12
- array_test = ['array-key', ['Hello.', nil, '', 'Goodbye.'], ['¡Hola.', nil, '', '¡Adiós.']],
12
+ array_test = ['array-key', ['Hello.', nil, '', 'Goodbye.'], ['Hola.', nil, '', 'Adiós.']],
13
13
  fixnum_test = ['numeric-key', 1, 1],
14
14
  ]
15
15
 
@@ -6,12 +6,32 @@ describe 'Tree siblings / forest' do
6
6
  context 'Node' do
7
7
  it '::new with children' do
8
8
  children = I18n::Tasks::Data::Tree::Siblings.from_key_attr([['a', value: 1]])
9
- node = I18n::Tasks::Data::Tree::Node.new(
9
+ node = new_node(
10
10
  key: 'fr',
11
11
  children: children
12
12
  )
13
13
  expect(node.to_siblings.first.children.parent.key).to eq 'fr'
14
14
  end
15
+
16
+ it '== (false by value)' do
17
+ expect(build_node({'a' => {'b' => {'c' => 1}}})).to_not(
18
+ eq(build_node({'a' => {'b' => {'c' => 2}}})))
19
+ end
20
+
21
+ it '== (false by key)' do
22
+ expect(build_node({'a' => {'b' => {'c' => 1}}})).to_not(
23
+ eq(build_node({'a' => {'b' => {'d' => 1}}})))
24
+ end
25
+
26
+ it '== (false by children)' do
27
+ expect(build_node({'a' => {'b' => {'c' => 1}}})).to_not(
28
+ eq(build_node({'a' => {'b' => {'c' => 1}, 'x' => 2}})))
29
+ end
30
+
31
+ it '== (true)' do
32
+ expect(build_node({'a' => {'b' => {'c' => 1}, 'x' => 2}})).to_not(
33
+ eq(build_node({'a' => {'b' => {'d' => 1}, 'x' => 2}})))
34
+ end
15
35
  end
16
36
 
17
37
  context 'a tree' do
@@ -55,7 +75,7 @@ describe 'Tree siblings / forest' do
55
75
 
56
76
  it '#set conflict value <- scope' do
57
77
  a = build_tree(a: 1)
58
- expect { silence_stderr { a.set('a.b', build_node(key: 'b', value: 1)) } }.to_not raise_error
78
+ expect { silence_stderr { a.set('a.b', new_node(key: 'b', value: 1)) } }.to_not raise_error
59
79
  end
60
80
 
61
81
  it '#intersect' do
@@ -72,18 +92,18 @@ describe 'Tree siblings / forest' do
72
92
  end
73
93
 
74
94
  it '#append!' do
75
- expect(build_tree({'a' => 1}).append!(build_node(key: 'b', value: 2)).to_hash).to eq('a' => 1, 'b' => 2)
95
+ expect(build_tree({'a' => 1}).append!(new_node(key: 'b', value: 2)).to_hash).to eq('a' => 1, 'b' => 2)
76
96
  end
77
97
 
78
98
  it '#set replace value' do
79
- expect(build_tree(a: {b: 1}).tap {|t| t['a.b'] = build_node(key: 'b', value: 2) }.to_hash).to(
99
+ expect(build_tree(a: {b: 1}).tap {|t| t['a.b'] = new_node(key: 'b', value: 2) }.to_hash).to(
80
100
  eq('a' => {'b' => 2})
81
101
  )
82
102
  end
83
103
 
84
104
  it '#set get' do
85
105
  t = build_tree(a: {x: 1})
86
- node = build_node(key: 'd', value: 'e')
106
+ node = new_node(key: 'd', value: 'e')
87
107
  t['a.b.c.' + node.key] = node
88
108
  expect(t['a.b.c.d'].value).to eq('e')
89
109
  end
data/spec/readme_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  require 'spec_helper'
3
3
  describe 'README.md' do
4
- let(:readme) { File.read('README.md') }
4
+ let(:readme) { File.read('README.md', encoding: 'UTF-8') }
5
5
  it 'has valid YAML in ```yaml blocks' do
6
6
  readme.scan /```yaml\n(.*)(?=^)\n```/ do |m|
7
7
  expect { YAML.load(m[0]) }.to_not raise_errors
@@ -19,9 +19,7 @@ describe 'Relative keys' do
19
19
 
20
20
  context 'relative key in controller' do
21
21
  it 'works' do
22
- base_scanner = I18n::Tasks::Scanners::BaseScanner.new
23
-
24
- key = base_scanner.absolutize_key(
22
+ key = scanner.absolutize_key(
25
23
  '.success',
26
24
  'app/controllers/users_controller.rb',
27
25
  %w(app/controllers),
@@ -30,6 +28,19 @@ describe 'Relative keys' do
30
28
 
31
29
  expect(key).to eq('users.create.success')
32
30
  end
31
+
32
+ context 'nested in module' do
33
+ it 'works' do
34
+ key = scanner.absolutize_key(
35
+ '.success',
36
+ 'app/controllers/nested/users_controller.rb',
37
+ %w(app/controllers),
38
+ 'create'
39
+ )
40
+
41
+ expect(key).to eq('nested.users.create.success')
42
+ end
43
+ end
33
44
  end
34
45
  end
35
46
  end
@@ -15,4 +15,8 @@ module CaptureStd
15
15
  ensure
16
16
  $stdout = out
17
17
  end
18
+
19
+ def silence_stderr(&block)
20
+ silence_stream($stderr, &block)
21
+ end
18
22
  end
@@ -23,7 +23,7 @@ module TestCodebase
23
23
 
24
24
  def run_cmd(name, *args, &block)
25
25
  in_test_app_dir do
26
- silence_stderr {
26
+ silence_stream($stderr) {
27
27
  capture_stdout { i18n_cmd.run(name, *args, &block) }
28
28
  }
29
29
  end
@@ -10,6 +10,12 @@ module Trees
10
10
  end
11
11
 
12
12
  def build_node(attr = {})
13
+ raise 'invalid node (more than 1 root)' if attr.size > 1
14
+ key, value = attr.first
15
+ I18n::Tasks::Data::Tree::Node.from_key_value(key, value)
16
+ end
17
+
18
+ def new_node(attr = {})
13
19
  I18n::Tasks::Data::Tree::Node.new(attr)
14
20
  end
15
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.11
4
+ version: 0.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-21 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis
@@ -206,7 +206,6 @@ extra_rdoc_files: []
206
206
  files:
207
207
  - ".coveralls.yml"
208
208
  - ".gitignore"
209
- - ".jrubyrc"
210
209
  - ".travis.yml"
211
210
  - CHANGES.md
212
211
  - Gemfile
@@ -334,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
334
333
  version: '0'
335
334
  requirements: []
336
335
  rubyforge_project:
337
- rubygems_version: 2.4.4
336
+ rubygems_version: 2.4.5
338
337
  signing_key:
339
338
  specification_version: 4
340
339
  summary: Manage localization and translation with the awesome power of static analysis
data/.jrubyrc DELETED
@@ -1,2 +0,0 @@
1
- compat.version=2.0
2
-