rails_locale_sorter 0.1.0 → 0.1.1
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/lib/rails_locale_sorter.rb +9 -7
- data/lib/rails_locale_sorter/version.rb +1 -1
- metadata +4 -4
data/lib/rails_locale_sorter.rb
CHANGED
@@ -14,7 +14,7 @@ module RailsLocaleSorter
|
|
14
14
|
def self.convert_and_sort(object, deep = false)
|
15
15
|
# from http://seb.box.re/2010/1/15/deep-hash-ordering-with-ruby-1-8/
|
16
16
|
if object.is_a?(Hash)
|
17
|
-
# Hash is ordered in Ruby 1.9!
|
17
|
+
# Hash is ordered in Ruby 1.9!
|
18
18
|
res = self.returning(RUBY_VERSION >= '1.9' ? Hash.new : ActiveSupport::OrderedHash.new) do |map|
|
19
19
|
object.each {|k, v| map[k] = deep ? convert_and_sort(v, deep) : v }
|
20
20
|
end
|
@@ -74,7 +74,7 @@ module RailsLocaleSorter
|
|
74
74
|
|
75
75
|
def apply_patches(reverse_dirs = false)
|
76
76
|
swap_dirs if reverse_dirs
|
77
|
-
|
77
|
+
|
78
78
|
process_each_file do |patch, file, filename|
|
79
79
|
target = YAML::load_file("#{@out}/#{filename}")
|
80
80
|
|
@@ -85,7 +85,9 @@ module RailsLocaleSorter
|
|
85
85
|
|
86
86
|
swap_dirs if reverse_dirs
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
|
+
private
|
90
|
+
|
89
91
|
def swap_dirs
|
90
92
|
tmp = @source
|
91
93
|
@source = @out
|
@@ -108,9 +110,9 @@ module RailsLocaleSorter
|
|
108
110
|
def process_each_file(&block)
|
109
111
|
# for ya2yaml
|
110
112
|
$KCODE="UTF8"
|
111
|
-
|
113
|
+
|
112
114
|
puts 'Processing...'
|
113
|
-
|
115
|
+
|
114
116
|
with_each_file do |f, filename|
|
115
117
|
print " #{filename.split('.').first} "
|
116
118
|
STDOUT.flush
|
@@ -120,14 +122,14 @@ module RailsLocaleSorter
|
|
120
122
|
end
|
121
123
|
puts "Done!"
|
122
124
|
end
|
123
|
-
|
125
|
+
|
124
126
|
def sort_and_write(filename, hash, filters = [])
|
125
127
|
hash = OrderFact.convert_and_sort(hash, true)
|
126
128
|
|
127
129
|
filters.each { |filt| hash.first.last.delete(filt) }
|
128
130
|
|
129
131
|
File.open("#{@out}/#{filename}", "w+") do |fw|
|
130
|
-
fw.puts hash.ya2yaml(:syck_compatible => true)
|
132
|
+
fw.puts hash.ya2yaml(:syck_compatible => true).gsub(/ +$/, '')
|
131
133
|
end
|
132
134
|
end
|
133
135
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_locale_sorter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Wheeler
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-04-09 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|