iye 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/iye.gemspec +2 -2
- data/lib/i18n_yaml_editor/transformation.rb +15 -9
- metadata +2 -2
data/README.md
CHANGED
@@ -42,3 +42,7 @@ The source ships with a `config.ru` suitable for development use with `shotgun(1
|
|
42
42
|
|
43
43
|
shotgun -p 5050
|
44
44
|
|
45
|
+
## Troubleshooting
|
46
|
+
|
47
|
+
**``psych.rb:203:in `parse': wrong number of arguments(2 for 1) (ArgumentError)``**
|
48
|
+
: This is caused by a mismatch of the `psych` in standard library and the gem. The bug is fixed in Ruby 1.9.3-p194.
|
data/iye.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module I18nYamlEditor
|
4
|
+
class TransformationError < StandardError; end
|
5
|
+
|
4
6
|
module Transformation
|
5
7
|
def flatten_hash hash, namespace=[], tree={}
|
6
8
|
hash.each {|key, value|
|
@@ -18,15 +20,19 @@ module I18nYamlEditor
|
|
18
20
|
def nest_hash hash
|
19
21
|
result = {}
|
20
22
|
hash.each {|key, value|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
begin
|
24
|
+
sub_result = result
|
25
|
+
keys = key.split(".")
|
26
|
+
keys.each_with_index {|k, idx|
|
27
|
+
if keys.size - 1 == idx
|
28
|
+
sub_result[k.to_sym] = value
|
29
|
+
else
|
30
|
+
sub_result = (sub_result[k.to_sym] ||= {})
|
31
|
+
end
|
32
|
+
}
|
33
|
+
rescue => e
|
34
|
+
raise TransformationError.new("Failed to nest key: #{key.inspect} with value: #{value.inspect}")
|
35
|
+
end
|
30
36
|
}
|
31
37
|
result
|
32
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cuba
|