i18n_kit 0.0.2 → 0.0.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{i18n_kit}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["funkensturm."]
@@ -66,8 +66,12 @@ module I18nKit
66
66
  end
67
67
 
68
68
  def to_flat_hash
69
- # On demand flattening
70
- populate_flat_hash(@hash) if @flat_hash.size == 0 and @hash.size > 1
69
+ if @flat_hash.size == 0 and @hash.size > 1
70
+ # On demand flattening
71
+ each_pair(@hash) do |key, value|
72
+ @flat_hash[key] = value
73
+ end
74
+ end
71
75
  @flat_hash
72
76
  end
73
77
 
@@ -78,21 +82,12 @@ module I18nKit
78
82
  def to_s
79
83
  @name
80
84
  end
81
-
82
- protected
83
-
84
- def populate_flat_hash(data, root=[])
85
- data.each do |key, value|
86
- if value.is_a?(Hash)
87
- new_root = root + [key]
88
- populate_flat_hash(value, new_root)
89
- else
90
- data.each do |k, v|
91
- flat_key = [root] + [k]
92
- @flat_hash[flat_key.join('.')] = v
93
- end
94
- return
95
- end
85
+
86
+ def each_pair(hash, prev_key=nil, &block)
87
+ hash.each do |key, value|
88
+ curr_key = [prev_key, key].compact.join('.').to_sym
89
+ yield curr_key.to_s, value unless value.is_a?(Hash)
90
+ each_pair(value, curr_key, &block) if value.is_a?(Hash)
96
91
  end
97
92
  end
98
93
 
@@ -44,7 +44,6 @@ module I18nKit
44
44
  # This is every row except the header row
45
45
  # The key is expected to be in the first column
46
46
  key = columns[0].text.to_s.strip
47
- puts row.inspect if key == 'buk.sell.contact.valuation.choose_closest_auction_house'
48
47
  # Now let's read the translations for this key. I.e. all columns except the first one
49
48
  locales.each_with_index do |locale, locale_index|
50
49
  locale = locale.to_s
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_kit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - funkensturm.