i18n-tasks 0.4.1 → 0.4.2

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: 71be19b5936a14fe104e5637369097c2a835b57a
4
- data.tar.gz: bf6e3c088c8f202032c81f71782acff219465c0c
3
+ metadata.gz: c36031ff1ffa5b67ffd68c4fc5375f4508598eff
4
+ data.tar.gz: 1dec92e192b4f30d33ba4411a69c55cb09ff542e
5
5
  SHA512:
6
- metadata.gz: 22661c315b535b89fd04b9d8efc52781da3b5409f3474ae9ada566d98e96795ca802988c917fd300e90d889b6c6057ef4fab144d98e212d5f592e87303c57967
7
- data.tar.gz: 1d9778f7d2ae1a3a56e76fe33ed00d7fcfb453337e224deac743b21213aee2b8f2beaadd005133abe991ea49004fe10a6c95743302f5152fa7aef378bc4ca017
6
+ metadata.gz: 636e7c94c6890519aa730e7b1aa13a8dba0c9d323c0b59214dc9474bf39fff80266267a770e41974eff888f7805fc59be63c1d3873094558d23319a13f1eb344
7
+ data.tar.gz: ce2e60ac8f14d31357a9508a9160f7cd2eb308e3c5df0793156b22fbcd160356188a40eb3a7d215f2894c23893510e6068dcb8461f60159654e0fdc2afaeba1e
data/.travis.yml CHANGED
@@ -2,12 +2,13 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1.1
4
4
  - 2.0.0
5
+ - 1.9.3
5
6
  - jruby-head
6
7
  - rbx-2
7
8
  matrix:
8
9
  allow_failures:
9
10
  # no keyword argument support in rbx
10
- - rbx
11
+ - rvm: rbx-2
11
12
  env:
12
13
  global:
13
14
  - TRAVIS=1
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.2
2
+
3
+ * Ruby 1.9.3-compatible again
4
+
1
5
  ## 0.4.1
2
6
 
3
7
  * Improved error messages across the board
data/Gemfile CHANGED
@@ -5,5 +5,5 @@ gemspec
5
5
 
6
6
  group :development do
7
7
  gem 'coveralls', require: false
8
- gem 'byebug', platform: :mri, require: false
8
+ gem 'byebug', platform: :mri_20, require: false
9
9
  end
data/README.md CHANGED
@@ -18,7 +18,7 @@ i18n-tasks can be used with any project using [i18n][i18n-gem] (default in Rails
18
18
  Add to Gemfile:
19
19
 
20
20
  ```ruby
21
- gem 'i18n-tasks', '~> 0.4.0'
21
+ gem 'i18n-tasks', '~> 0.4.2'
22
22
  ```
23
23
 
24
24
  i18n-tasks does not load or execute any of the application's code but performs static-only analysic.
@@ -98,7 +98,8 @@ module I18n::Tasks
98
98
  cmd :config do
99
99
  cfg = i18n_task.config_for_inspect.to_yaml
100
100
  cfg.sub! /\A---\n/, ''
101
- cfg.gsub! /^([^\s-].+?)$/, Term::ANSIColor.cyan(Term::ANSIColor.bold('\1'))
101
+ cfg.gsub! /^([^\s-].+?:)/, Term::ANSIColor.cyan(Term::ANSIColor.bold('\1'))
102
+ cfg.gsub! '!ruby/hash:ActiveSupport::HashWithIndifferentAccess', ''
102
103
  puts cfg
103
104
  end
104
105
 
@@ -9,6 +9,7 @@ module I18n::Tasks::Configuration
9
9
  config/i18n-tasks.yml config/i18n-tasks.yml.erb
10
10
  i18n-tasks.yml i18n-tasks.yml.erb
11
11
  )
12
+
12
13
  def file_config
13
14
  file = CONFIG_FILES.detect { |f| File.exists?(f) }
14
15
  file = YAML.load(Erubis::Eruby.new(File.read(file)).result) if file
@@ -27,7 +28,7 @@ module I18n::Tasks::Configuration
27
28
  @config_sections[:data] ||= begin
28
29
  {
29
30
  adapter: data.class.name,
30
- config: data.config
31
+ config: data.config
31
32
  }
32
33
  end
33
34
  end
@@ -97,6 +98,13 @@ module I18n::Tasks::Configuration
97
98
 
98
99
  def config_for_inspect
99
100
  # hide empty sections, stringify keys
100
- Hash[config_sections.reject { |k, v| v.empty? }.map { |k, v| [k.to_s, v.respond_to?(:stringify_keys) ? v.stringify_keys : v] }]
101
+ Hash[config_sections.reject { |k, v| v.empty? }.map { |k, v|
102
+ [k.to_s, v.respond_to?(:stringify_keys) ? v.stringify_keys : v] }].tap do |h|
103
+ h.each do |_k, v|
104
+ if v.is_a?(Hash) && v.key?('config')
105
+ v.merge! v.delete('config')
106
+ end
107
+ end
108
+ end
101
109
  end
102
110
  end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'i18n/tasks/data/tree/traversal'
2
4
  require 'i18n/tasks/data/tree/siblings'
3
5
  module I18n::Tasks::Data::Tree
@@ -5,12 +7,12 @@ module I18n::Tasks::Data::Tree
5
7
  attr_accessor :value
6
8
  attr_reader :key, :children, :parent
7
9
 
8
- def initialize(key: nil, value: nil, data: nil, parent: nil, children: nil)
9
- @key = key.try(:to_s)
10
- @value = value
11
- @data = data
12
- @parent = parent
13
- self.children = children if children
10
+ def initialize(opts = {})
11
+ @key = opts[:key].try(:to_s)
12
+ @value = opts[:value]
13
+ @data = opts[:data]
14
+ @parent = opts[:parent]
15
+ self.children = opts[:children] if opts[:children]
14
16
  end
15
17
 
16
18
  def attributes
@@ -113,7 +115,8 @@ module I18n::Tasks::Data::Tree
113
115
  derive.append!(nodes)
114
116
  end
115
117
 
116
- def full_key(root: true)
118
+ def full_key(opts = {})
119
+ root = opts.key?(:root) ? opts[:root] : true
117
120
  @full_key ||= {}
118
121
  @full_key[root] ||= "#{"#{parent.full_key(root: root)}." if parent? && (root || parent.parent?)}#{key}"
119
122
  end
@@ -151,7 +154,7 @@ module I18n::Tasks::Data::Tree
151
154
  delegate :to_json, to: :to_hash
152
155
  delegate :to_yaml, to: :to_hash
153
156
 
154
- def inspect(level: 0)
157
+ def inspect(level = 0)
155
158
  label =
156
159
  if null?
157
160
  Term::ANSIColor.dark '∅'
@@ -167,7 +170,7 @@ module I18n::Tasks::Data::Tree
167
170
 
168
171
  r = "#{' ' * level}#{label}"
169
172
  if children?
170
- r += "\n" + children.map { |c| c.inspect(level: level + 1) }.join("\n") if children?
173
+ r += "\n" + children.map { |c| c.inspect(level + 1) }.join("\n") if children?
171
174
  end
172
175
  r
173
176
  end
@@ -1,11 +1,13 @@
1
+ # coding: utf-8
2
+
1
3
  require 'i18n/tasks/data/tree/traversal'
2
4
  module I18n::Tasks::Data::Tree
3
5
  # A list of nodes
4
6
  class Nodes
5
7
  attr_reader :list
6
8
 
7
- def initialize(nodes: [])
8
- @list = nodes.to_a.clone
9
+ def initialize(opts = {})
10
+ @list = opts[:nodes] ? opts[:nodes].to_a.clone : []
9
11
  end
10
12
 
11
13
  delegate :each, :present?, :empty?, :blank?, :size, :to_a, to: :@list
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'i18n/tasks/data/tree/traversal'
2
4
  require 'i18n/tasks/data/tree/nodes'
3
5
  module I18n::Tasks::Data::Tree
@@ -7,11 +9,11 @@ module I18n::Tasks::Data::Tree
7
9
  class Siblings < Nodes
8
10
  attr_reader :parent, :key_to_node
9
11
 
10
- def initialize(nodes: [], parent: nil)
11
- super(nodes: nodes)
12
+ def initialize(opts = {})
13
+ super(nodes: opts[:nodes])
12
14
  @key_to_node = siblings.inject({}) { |h, node| h[node.key] = node; h }
13
15
  @parent = first.try(:parent) || Node.null
14
- self.parent = parent if parent
16
+ self.parent = opts[:parent] if opts[:parent]
15
17
  end
16
18
 
17
19
  def attributes
@@ -111,9 +113,10 @@ module I18n::Tasks::Data::Tree
111
113
 
112
114
  # build forest from nested hash, e.g. {'es' => { 'common' => { name => 'Nombre', 'age' => 'Edad' } } }
113
115
  # this is the native i18n gem format
114
- def from_nested_hash(hash, parent: Node.null)
116
+ def from_nested_hash(hash, opts = {})
117
+ opts[:parent] ||= Node.null
115
118
  Siblings.new nodes: hash.map { |key, value| Node.from_key_value key, value },
116
- parent: parent
119
+ parent: opts[:parent]
117
120
  end
118
121
 
119
122
  alias [] from_nested_hash
@@ -14,7 +14,8 @@ module I18n::Tasks::Data::Tree
14
14
  end
15
15
 
16
16
  # @param root include root in full key
17
- def keys(root: true, &visitor)
17
+ def keys(opts = {}, &visitor)
18
+ root = opts.key?(:root) ? opts[:root] : true
18
19
  return to_enum(:keys, root: root) unless visitor
19
20
  leaves { |node| visitor.yield(node.full_key(root: root), node) }
20
21
  end
@@ -65,7 +66,8 @@ module I18n::Tasks::Data::Tree
65
66
  end
66
67
 
67
68
  # @return Siblings
68
- def select_keys(root: true, &block)
69
+ def select_keys(opts = {}, &block)
70
+ root = opts.key?(:root) ? opts[:root] : true
69
71
  ok = {}
70
72
  keys(root: root) do |full_key, node|
71
73
  if block.yield(full_key, node)
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module Tasks
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.2'
4
4
  end
5
5
  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.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-07 00:00:00.000000000 Z
11
+ date: 2014-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis