transdifflation 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Fudgefile +1 -0
- data/Gemfile +3 -1
- data/README.md +7 -6
- data/lib/tasks/translation_coverage.rake +4 -6
- data/lib/transdifflation/railtie.rb +4 -4
- data/lib/transdifflation/transdifflation.yml +3 -3
- data/lib/transdifflation/utilities.rb +5 -4
- data/lib/transdifflation/version.rb +1 -1
- data/lib/transdifflation/yaml_reader.rb +2 -0
- data/lib/transdifflation.rb +34 -24
- data/spec/coverage_spec.rb +136 -136
- data/spec/lost_in_translation_spec.rb +19 -19
- data/spec/transdifflation_spec.rb +50 -29
- data/spec/utilities_spec.rb +4 -4
- data/spec/yaml_reader_spec.rb +4 -4
- data/spec/yaml_writer_spec.rb +3 -3
- data/transdifflation.gemspec +3 -1
- metadata +18 -2
data/Fudgefile
CHANGED
data/Gemfile
CHANGED
@@ -4,14 +4,16 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
gem 'rails'
|
7
|
+
gem 'ya2yaml'
|
7
8
|
|
8
9
|
group :development, :test do
|
9
10
|
gem 'fudge'
|
10
11
|
gem 'rspec'
|
11
12
|
gem 'yard'
|
13
|
+
gem 'cane'
|
12
14
|
gem 'simplecov'
|
13
15
|
gem 'rake'
|
14
|
-
|
16
|
+
gem 'rspec'
|
15
17
|
gem 'rspec-rails'
|
16
18
|
gem 'guard-sass', :require => false
|
17
19
|
gem 'pry'
|
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
# Transdifflation
|
1
|
+
# Transdifflation [![travis-ci](https://secure.travis-ci.org/Sage/transdifflation.png)](http://travis-ci.org/#!/Sage/transdifflation)
|
2
2
|
|
3
|
-
What is Transdifflation? Transdifflation is
|
4
|
-
|
5
|
-
|
3
|
+
What is Transdifflation? Transdifflation is a portmanteau of 'Translation' and 'Diff'. It helps you to manage the translation of Rails i18n strings that appear in your application and the Ruby Gems it includes.
|
4
|
+
|
5
|
+
It compares two .yml locale files, one in your source code (the *target*) and one in others' (gems, other projects) source code (the *source*) and generates a beside-file with the keys you haven't translated yet.
|
6
|
+
Then you can merge it. It is designed to detect changes between versions. For now, the target file cannot be renamed, and it is generated in 'config/locales/' + to_locale (param in task). Names are inferred by the task params.
|
6
7
|
|
7
8
|
Also, it has three new rake tasks to provide information to you about missing translations between two locales, and continuous integration support.
|
8
9
|
|
9
|
-
|
10
|
+
It never changes your source files (unless they don't yet exist, in which case they are created for you).
|
10
11
|
|
11
12
|
## Installation
|
12
13
|
|
@@ -26,7 +27,7 @@ Or install it yourself as:
|
|
26
27
|
|
27
28
|
### How to configure your Rake tasks
|
28
29
|
|
29
|
-
It needs a config file (
|
30
|
+
It needs a config file (`transdifflation.yml`) placed on your host root, or in 'config'. If not exists, a rake task is set up to generate it: ```rake transdifflation:config```. Config file looks like:
|
30
31
|
|
31
32
|
```yml
|
32
33
|
tasks:
|
@@ -8,8 +8,7 @@ namespace :transdifflation do
|
|
8
8
|
|
9
9
|
#Reading config file
|
10
10
|
search_locations = %w[config/transdifflation.yml transdifflation.yml]
|
11
|
-
|
12
|
-
|
11
|
+
|
13
12
|
file_task_config = nil
|
14
13
|
search_locations.each do |path| #Take config file from these locations
|
15
14
|
abs_path = File.expand_path(path, Rails.root)
|
@@ -31,7 +30,7 @@ namespace :transdifflation do
|
|
31
30
|
I18n.backend.load_translations
|
32
31
|
|
33
32
|
end
|
34
|
-
|
33
|
+
translations = I18n.backend.send(:translations)
|
35
34
|
|
36
35
|
hash_from_locale = translations[from_locale]
|
37
36
|
hash_to_locale = translations[to_locale]
|
@@ -44,6 +43,8 @@ namespace :transdifflation do
|
|
44
43
|
task :coverage, [:from_locale, :to_locale] => [:environment] do |t, args|
|
45
44
|
|
46
45
|
args.with_defaults(:from_locale => I18n.default_locale, :to_locale => I18n.locale)
|
46
|
+
#I18n.load_path.
|
47
|
+
|
47
48
|
puts "\nChecking how much work you have left...\n"
|
48
49
|
from_locale = args[:from_locale].to_sym
|
49
50
|
to_locale = args[:to_locale].to_sym
|
@@ -52,7 +53,4 @@ namespace :transdifflation do
|
|
52
53
|
differences = get_coverage_rate(from_locale, to_locale)
|
53
54
|
puts "You have #{differences}"
|
54
55
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
56
|
end
|
@@ -14,7 +14,7 @@ module Transdifflation
|
|
14
14
|
railtie_name :transdifflation
|
15
15
|
rake_tasks do
|
16
16
|
begin
|
17
|
-
|
17
|
+
|
18
18
|
Dir[ File.join(File.dirname(__FILE__), '../tasks/*.rake')] .each { |f| load f } #Load static tasks
|
19
19
|
|
20
20
|
|
@@ -98,7 +98,7 @@ module Transdifflation
|
|
98
98
|
end
|
99
99
|
|
100
100
|
rescue Transdifflation::ConfigFileNotFound
|
101
|
-
#Generate task to set-up
|
101
|
+
#Generate task to set-up
|
102
102
|
namespace :transdifflation do
|
103
103
|
desc "Task to set-up config file in host"
|
104
104
|
task :setup do
|
@@ -111,11 +111,11 @@ module Transdifflation
|
|
111
111
|
|
112
112
|
rescue Transdifflation::ConfigFileWithErrors => e
|
113
113
|
|
114
|
-
raise "Gem 'Transdifflation' says => #{e.message}"
|
114
|
+
raise "Gem 'Transdifflation' says => #{e.message}"
|
115
115
|
|
116
116
|
rescue Exception => e
|
117
117
|
|
118
|
-
raise "Gem 'Transdifflation' says => #{e.message}"
|
118
|
+
raise "Gem 'Transdifflation' says => #{e.message}"
|
119
119
|
|
120
120
|
end
|
121
121
|
end
|
@@ -6,10 +6,10 @@ module Transdifflation
|
|
6
6
|
class HashSymbolTranslator
|
7
7
|
# Convert keys (strings) into symbols
|
8
8
|
def symbolize(hash)
|
9
|
-
hash = hash.inject({}) { |memo,(k,v)|
|
9
|
+
hash = hash.inject({}) { |memo,(k,v)|
|
10
10
|
if(v.instance_of? Hash)
|
11
11
|
v = symbolize(v)
|
12
|
-
end
|
12
|
+
end
|
13
13
|
memo[k.to_sym] = v
|
14
14
|
memo
|
15
15
|
}
|
@@ -17,10 +17,10 @@ module Transdifflation
|
|
17
17
|
end
|
18
18
|
# Convert keys into string
|
19
19
|
def unsymbolize(hash)
|
20
|
-
hash = hash.inject({}) { |memo,(k,v)|
|
20
|
+
hash = hash.inject({}) { |memo,(k,v)|
|
21
21
|
if(v.instance_of? Hash)
|
22
22
|
v = unsymbolize(v)
|
23
|
-
end
|
23
|
+
end
|
24
24
|
memo[k.to_s] = v
|
25
25
|
memo
|
26
26
|
}
|
@@ -31,6 +31,7 @@ module Transdifflation
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
# monkeypatch the Hash class to convert to/from symbols
|
34
35
|
class Hash
|
35
36
|
|
36
37
|
#convert all keys in a Hash (presumily from YAML) in symbols
|
@@ -9,7 +9,9 @@ module Transdifflation
|
|
9
9
|
def self.read_YAML_from_gem(gem_name, file_path_to_yaml_in_gem)
|
10
10
|
|
11
11
|
#get where the gem is localized
|
12
|
+
|
12
13
|
gem_SRC =`bundle show #{gem_name}`.chomp
|
14
|
+
|
13
15
|
raise ArgumentError.new("Gem '#{gem_name}' not installed") if ($?.to_i != 0) #get return code and check if is different from zero
|
14
16
|
|
15
17
|
#get the file within the gem
|
data/lib/transdifflation.rb
CHANGED
@@ -9,7 +9,7 @@ require 'pry'
|
|
9
9
|
# The main module for the program
|
10
10
|
module Transdifflation
|
11
11
|
|
12
|
-
require 'transdifflation/railtie' if defined?(Rails)
|
12
|
+
require 'transdifflation/railtie' if defined?(Rails)
|
13
13
|
|
14
14
|
# Implements the core
|
15
15
|
class Comparer
|
@@ -19,7 +19,7 @@ module Transdifflation
|
|
19
19
|
#Instance variable to get if changes have been detected
|
20
20
|
attr_reader :has_changes
|
21
21
|
|
22
|
-
def initialize
|
22
|
+
def initialize
|
23
23
|
@has_changes = false
|
24
24
|
end
|
25
25
|
|
@@ -35,16 +35,20 @@ module Transdifflation
|
|
35
35
|
from_locale ||= I18n.default_locale
|
36
36
|
to_locale ||= I18n.locale
|
37
37
|
|
38
|
-
|
39
38
|
yml_gem_content = YAMLReader.read_YAML_from_gem(gem_name, path_to_yaml_in_gem)
|
40
39
|
puts "Loaded YAML content from gem '#{gem_name}', file '#{path_to_yaml_in_gem}'"
|
41
40
|
|
42
|
-
|
43
41
|
#build the file name in our host
|
44
42
|
filename_in_gem_SRC = File.basename( path_to_yaml_in_gem )
|
45
43
|
host_target_filename = filename_in_gem_SRC.gsub(/-?#{from_locale}\./) do |match_s|
|
46
44
|
match_s.sub("#{from_locale}", "#{to_locale}")
|
47
45
|
end
|
46
|
+
|
47
|
+
#The folder is created if doesn't exist
|
48
|
+
if !File.directory?("config/locales/#{to_locale}")
|
49
|
+
FileUtils.mkdir_p(File.join(Rails.root, "config/locales/#{to_locale}"))
|
50
|
+
end
|
51
|
+
|
48
52
|
host_target_file = File.join( Rails.root, "config/locales/#{to_locale}", "#{gem_name}.#{host_target_filename}")
|
49
53
|
|
50
54
|
if(!File.file? host_target_file)
|
@@ -52,12 +56,9 @@ module Transdifflation
|
|
52
56
|
else
|
53
57
|
generate_diff_file(yml_gem_content, host_target_file, from_locale, to_locale)
|
54
58
|
end
|
55
|
-
|
56
59
|
@has_changes
|
57
60
|
end
|
58
61
|
|
59
|
-
|
60
|
-
|
61
62
|
# Get Diff from YAML translation locale file from filesystem and generate differences in a file on our host
|
62
63
|
#
|
63
64
|
# @param [String] tag_name Tag name this file will be installed on host
|
@@ -74,10 +75,16 @@ module Transdifflation
|
|
74
75
|
puts "Loaded YAML content from file '#{path_to_yaml_relative_from_rails_root}'"
|
75
76
|
|
76
77
|
#build the file name in our host
|
77
|
-
filename_in_SRC = File.basename(
|
78
|
+
filename_in_SRC = File.basename(path_to_yaml_relative_from_rails_root )
|
78
79
|
host_target_filename = filename_in_SRC.gsub(/-?#{from_locale}\./) do |match_s|
|
79
80
|
match_s.sub("#{from_locale}", "#{to_locale}")
|
80
81
|
end
|
82
|
+
|
83
|
+
#The folder is created if doesn't exist
|
84
|
+
if !File.directory?("config/locales/#{to_locale}")
|
85
|
+
FileUtils.mkdir_p(File.join(Rails.root, "config/locales/#{to_locale}"))
|
86
|
+
end
|
87
|
+
|
81
88
|
host_target_file = File.join( Rails.root, "config/locales/#{to_locale}", "#{tag_name}.#{host_target_filename}")
|
82
89
|
|
83
90
|
if(!File.file? host_target_file)
|
@@ -109,8 +116,8 @@ module Transdifflation
|
|
109
116
|
# @param [Hash] hash_from_locale I18n source translation to compare
|
110
117
|
# @param [Hash] hash_to_locale I18n target translation to compare
|
111
118
|
# @param [String] token The string you want to compare. example: **NOT TRANSLATED**
|
112
|
-
def coverage_rate(hash_from_locale, hash_to_locale, token = NOT_TRANSLATED)
|
113
|
-
|
119
|
+
def coverage_rate(hash_from_locale, hash_to_locale, token = NOT_TRANSLATED)
|
120
|
+
|
114
121
|
if hash_from_locale.nil?
|
115
122
|
return "Translation coverage error: from_locale language not detected."
|
116
123
|
end
|
@@ -118,9 +125,9 @@ module Transdifflation
|
|
118
125
|
if hash_to_locale.nil?
|
119
126
|
return "Translation coverage error: to_locale language not detected."
|
120
127
|
end
|
121
|
-
|
128
|
+
|
122
129
|
if hash_from_locale.empty?
|
123
|
-
return "from_locale is empty, so you have everything translated"
|
130
|
+
return "from_locale is empty, so you have everything translated"
|
124
131
|
end
|
125
132
|
|
126
133
|
words = 0
|
@@ -133,13 +140,13 @@ module Transdifflation
|
|
133
140
|
end
|
134
141
|
|
135
142
|
|
136
|
-
# Get the number of translated keys
|
143
|
+
# Get the number of translated keys
|
137
144
|
#
|
138
145
|
# @param [Hash] hash_from I18n source translation to compare
|
139
146
|
# @param [Hash] hash_to I18n target translation to compare
|
140
147
|
# @param [String] token The string you want to compare. example: **NOT TRANSLATED**
|
141
148
|
# @param [Integer] words Number of keys (accumulated) from hash_from
|
142
|
-
# @param [Integer] found Number of keys (accumulated) where token is not found in hash_to
|
149
|
+
# @param [Integer] found Number of keys (accumulated) where token is not found in hash_to
|
143
150
|
def rate_from_branch(hash_from, hash_to, token, words, found)
|
144
151
|
|
145
152
|
hash_from.each_pair{ |key, value|
|
@@ -154,12 +161,12 @@ module Transdifflation
|
|
154
161
|
else
|
155
162
|
words += 1
|
156
163
|
if hash_to[key.to_sym]
|
157
|
-
found += 1 if !hash_to[key.to_sym].to_s.include?(token)
|
158
|
-
end
|
164
|
+
found += 1 if !hash_to[key.to_sym].to_s.include?(token)
|
165
|
+
end
|
159
166
|
end
|
160
167
|
}
|
161
168
|
return words, found
|
162
|
-
end
|
169
|
+
end
|
163
170
|
|
164
171
|
private
|
165
172
|
|
@@ -206,17 +213,23 @@ module Transdifflation
|
|
206
213
|
|
207
214
|
#if value is a hash, we call it recursively
|
208
215
|
if (source_value.instance_of? Hash)
|
209
|
-
if(!target.has_key?
|
216
|
+
if(!target.has_key?(source_key_translated))
|
210
217
|
target[source_key_translated] = Hash.new
|
211
218
|
end
|
212
219
|
translate_keys_in_same_yaml(source_value, target[source_key_translated], from_locale, to_locale, add_NOT_TRANSLATED) #recurrence of other hashes
|
213
220
|
else
|
214
221
|
#it's a leaf node
|
215
|
-
target[source_key_translated] = (add_NOT_TRANSLATED ? "#{NOT_TRANSLATED}#{source_value}" : "#{source_value}") if !target.has_key?
|
222
|
+
target[source_key_translated] = (add_NOT_TRANSLATED ? "#{NOT_TRANSLATED}#{source_value}" : "#{source_value}") if !target.has_key?(source_key_translated)
|
216
223
|
end
|
217
224
|
}
|
218
225
|
end
|
219
226
|
|
227
|
+
# Generates a difference file from YAML hash
|
228
|
+
#
|
229
|
+
# @param [Hash] yml_source_content Source YAML-format hash
|
230
|
+
# @param [Hash] host_target_file Target file
|
231
|
+
# @param [Symbol] from_locale Default locale in gem. Used to translate 'from'
|
232
|
+
# @param [Symbol] to_locale Default locale in host. Used to translate 'to'
|
220
233
|
def generate_diff_file(yml_source_content, host_target_file, from_locale, to_locale)
|
221
234
|
|
222
235
|
existant_yml = YAMLReader.read_YAML_from_pathfile(host_target_file)
|
@@ -230,16 +243,13 @@ module Transdifflation
|
|
230
243
|
temp_removed_diff_hash = {}
|
231
244
|
translate_keys_in_same_yaml(removed_diff_hash, temp_removed_diff_hash, from_locale, to_locale, false)
|
232
245
|
removed_diff_hash = temp_removed_diff_hash
|
233
|
-
|
234
246
|
end
|
235
247
|
|
236
|
-
|
237
248
|
if( added_diff_hash.length > 0 || removed_diff_hash.length > 0 )
|
238
|
-
|
239
249
|
diff_file = File.join(File.dirname(host_target_file), "#{File.basename(host_target_file)}.diff")
|
240
250
|
diff_file_stream = File.new(diff_file, "w+:UTF-8")
|
241
251
|
begin
|
242
|
-
|
252
|
+
|
243
253
|
if (added_diff_hash.length > 0)
|
244
254
|
diff_file_stream.write("ADDED KEYS (Keys not found in your file, founded in source file) ********************\n")
|
245
255
|
diff_file_stream.write(YAMLWriter.to_yaml(added_diff_hash)) #we can't use YAML#dump due to issues wuth Utf8 chars
|
@@ -256,7 +266,7 @@ module Transdifflation
|
|
256
266
|
end
|
257
267
|
puts "File #{File.basename( host_target_file )} processed >> %s" % [ "#{File.basename( diff_file )} has the changes!"]
|
258
268
|
@has_changes = true
|
259
|
-
else
|
269
|
+
else
|
260
270
|
puts "File #{File.basename( host_target_file )} processed >> No changes!"
|
261
271
|
end
|
262
272
|
end
|
data/spec/coverage_spec.rb
CHANGED
@@ -2,140 +2,140 @@ require 'spec_helper'
|
|
2
2
|
require 'transdifflation'
|
3
3
|
|
4
4
|
describe :translation_coverage do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
5
|
+
describe :coverage_rate do
|
6
|
+
it 'should return a message when hash_from_locale is an nil hash' do
|
7
|
+
@comparer = Transdifflation::Comparer.new
|
8
|
+
hash_from_locale = nil
|
9
|
+
hash_to_locale = {}
|
10
|
+
token = "**NOT TRANSLATED**"
|
11
|
+
|
12
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "Translation coverage error: from_locale language not detected."
|
13
|
+
end
|
14
|
+
it 'should return a message when hash_to_locale is an nil hash' do
|
15
|
+
@comparer = Transdifflation::Comparer.new
|
16
|
+
hash_from_locale = {}
|
17
|
+
hash_to_locale = nil
|
18
|
+
token = "**NOT TRANSLATED**"
|
19
|
+
|
20
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "Translation coverage error: to_locale language not detected."
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should return 100% when hash_from_locale is empty' do
|
24
|
+
@comparer = Transdifflation::Comparer.new
|
25
|
+
hash_from_locale = {}
|
26
|
+
hash_to_locale = {}
|
27
|
+
token = "**NOT TRANSLATED**"
|
28
|
+
|
29
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "from_locale is empty, so you have everything translated"
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should return 100% when hash_from_locale is empty, even if there is something at hash_to_locale' do
|
33
|
+
@comparer = Transdifflation::Comparer.new
|
34
|
+
hash_from_locale = {}
|
35
|
+
hash_to_locale = {:home => "hogar"}
|
36
|
+
token = "**NOT TRANSLATED**"
|
37
|
+
|
38
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "from_locale is empty, so you have everything translated"
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should return 0% when theres all to translate' do
|
42
|
+
@comparer = Transdifflation::Comparer.new
|
43
|
+
hash_from_locale = {:home => "home"}
|
44
|
+
hash_to_locale = {}
|
45
|
+
token = "**NOT TRANSLATED**"
|
46
|
+
|
47
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "0.00% 0/1 entries translated"
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should return 100% when you have everything translated (5/5)' do
|
51
|
+
@comparer = Transdifflation::Comparer.new
|
52
|
+
hash_from_locale = { :one => "one", :two => "two", :three => "tree", :four => "four", :five => "five" }
|
53
|
+
hash_to_locale = { :one => "uno", :two => "dos", :three => "tres", :four => "cuatro", :five => "cinco" }
|
54
|
+
token = "**NOT TRANSLATED**"
|
55
|
+
|
56
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "100.00% 5/5 entries translated"
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should return 80% when you have 8/10 terms translated' do
|
60
|
+
@comparer = Transdifflation::Comparer.new
|
61
|
+
hash_from_locale = { :one => "one", :two => "two", :three => "tree", :four => "four", :five => "five", :six => "six", :seven => "seven", :eight => "eight", :nine => "nine", :ten => "ten" }
|
62
|
+
hash_to_locale = { :one => "uno", :two => "dos", :three => "tres", :four => "cuatro", :five => "cinco", :six => "**NOT TRANSLATED** six", :seven => "**NOT TRANSLATED** seven", :eight => "ocho", :nine => "nueve", :ten => "diez" }
|
63
|
+
token = "**NOT TRANSLATED**"
|
64
|
+
|
65
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "80.00% 8/10 entries translated"
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
it 'should return 70% when you have 7/10 terms translated, but you dont have a term, even in the hash and 2 of them are not translated' do
|
70
|
+
@comparer = Transdifflation::Comparer.new
|
71
|
+
hash_from_locale = { :one => "one", :two => "two", :three => "tree", :four => "four", :five => "five", :six => "six", :seven => "seven", :eight => "eight", :nine => "nine", :ten => "ten" }
|
72
|
+
hash_to_locale = { :one => "uno", :two => "dos", :three => "tres", :four => "cuatro", :five => "cinco", :six => "**NOT TRANSLATED** six", :seven => "**NOT TRANSLATED** seven", :eight => "ocho", :nine => "nueve" }
|
73
|
+
token = "**NOT TRANSLATED**"
|
74
|
+
|
75
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "70.00% 7/10 entries translated"
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should return 62.50% when you have 5/8 terms translated' do
|
79
|
+
@comparer = Transdifflation::Comparer.new
|
80
|
+
hash_from_locale = { :one => "one", :two => "two", :three => "tree", :four => "four", :five => "five", :six => "six", :seven => "seven", :eight => "eight" }
|
81
|
+
hash_to_locale = { :one => "uno", :two => "**NOT TRANSLATED** two", :three => "tres", :four => "cuatro", :five => "cinco", :six => "**NOT TRANSLATED** six", :seven => "**NOT TRANSLATED** seven", :eight => "ocho"}
|
82
|
+
token = "**NOT TRANSLATED**"
|
83
|
+
|
84
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "62.50% 5/8 entries translated"
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should return 62.50% when you have 5/8 terms translated, having extra terms at the hash_to_locale hash' do
|
88
|
+
@comparer = Transdifflation::Comparer.new
|
89
|
+
hash_from_locale = { :one => "one", :two => "two", :three => "tree", :four => "four", :five => "five", :six => "six", :seven => "seven", :eight => "eight" }
|
90
|
+
hash_to_locale = { :one => "uno", :two => "**NOT TRANSLATED** two", :three => "tres", :four => "cuatro", :five => "cinco", :six => "**NOT TRANSLATED** six", :seven => "**NOT TRANSLATED** seven", :eight => "ocho", :puerta => "Puerta"}
|
91
|
+
token = "**NOT TRANSLATED**"
|
92
|
+
|
93
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "62.50% 5/8 entries translated"
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should return 100.00% in nested hash' do
|
97
|
+
@comparer = Transdifflation::Comparer.new
|
98
|
+
hash_from_locale = { :house => "house", :street => {:street_name => "street name", :postal => "postal code"}}
|
99
|
+
hash_to_locale = { :house => "casa", :street => {:street_name => "Nombre de la calle", :postal => "codigo postal"}}
|
100
|
+
token = "**NOT TRANSLATED**"
|
101
|
+
|
102
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "100.00% 3/3 entries translated"
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should return 3 entries, 2 translations found' do
|
106
|
+
@comparer = Transdifflation::Comparer.new
|
107
|
+
hash_from_locale = { :house => "house", :street => {:street_name => "street name", :postal => "postal code"}}
|
108
|
+
hash_to_locale = { :house => "casa", :street => {:street_name => "**NOT TRANSLATED** Nombre de la calle", :postal => "codigo postal"}}
|
109
|
+
token = "**NOT TRANSLATED**"
|
110
|
+
|
111
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "66.67% 2/3 entries translated"
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should return 0.00% in nested hash' do
|
115
|
+
@comparer = Transdifflation::Comparer.new
|
116
|
+
hash_from_locale = { :street => {:street_name => "**NOT TRANSLATED** Nombre de la calle", :postal => "codigo postal", :number => { :one => "one", :two => "two", :three => "tree"}}}
|
117
|
+
hash_to_locale = { :one => "uno"}
|
118
|
+
token = "**NOT TRANSLATED**"
|
119
|
+
|
120
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "0.00% 0/5 entries translated"
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should return 10.00% in nested hash' do
|
124
|
+
@comparer = Transdifflation::Comparer.new
|
125
|
+
hash_from_locale = { :one => "one", :two => "two", :three => "tree", :four => "four", :five => "five", :six => "six", :seven => "seven", :eight => "eight", :nine => "nine", :ten => "ten", :street => {:street_name => "**NOT TRANSLATED** Nombre de la calle", :postal => "codigo postal"}}
|
126
|
+
hash_to_locale = { :one => "uno"}
|
127
|
+
token = "**NOT TRANSLATED**"
|
128
|
+
|
129
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "8.33% 1/12 entries translated"
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should return 8.33% in nested hash with only one term' do
|
133
|
+
@comparer = Transdifflation::Comparer.new
|
134
|
+
hash_from_locale = { :one => "one", :two => "two", :three => "tree", :four => "four", :five => "five", :six => "six", :seven => "seven", :eight => "eight", :nine => "nine", :ten => "ten", :street => {:street_name => "Nombre de la calle", :postal => "codigo postal"}}
|
135
|
+
hash_to_locale = { :one => "uno"}
|
136
|
+
token = "**NOT TRANSLATED**"
|
137
|
+
|
138
|
+
@comparer.coverage_rate(hash_from_locale, hash_to_locale, token).should == "8.33% 1/12 entries translated"
|
139
|
+
end
|
140
|
+
end
|
141
141
|
end
|
@@ -3,26 +3,26 @@ require 'transdifflation'
|
|
3
3
|
|
4
4
|
describe :lost_in_translation do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
before (:each) do
|
7
|
+
@comparer = Transdifflation::Comparer.new
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
describe :inner_functionallity do
|
11
|
+
it 'should return no differences with same data' do
|
12
|
+
i18n = { :es => {:one_key => 'uno', :another_key => 'dos'} }
|
13
|
+
@comparer.get_rest_of_translation(i18n, i18n, :es, :es).should eql({})
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
it 'should return differences with different data' do
|
17
|
+
i18n_en = { :en => {:one_key => 'one', :another_key => 'another', :another_one => 'another_one_even'} }
|
18
|
+
i18n_es = { :es => {:one_key => 'uno', :another_key => 'dos'} }
|
19
|
+
@comparer.get_rest_of_translation(i18n_en, i18n_es, :en, :es).should eql( {"es" => {"another_one" => "another_one_even" }} )
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
it 'should return no differences if target has more info than source' do
|
23
|
+
i18n_en = { :en => {:one_key => 'one', :another_key => 'another'} }
|
24
|
+
i18n_es = { :es => {:one_key => 'uno', :another_key => 'dos', :another_one => 'tres'} }
|
25
|
+
@comparer.get_rest_of_translation(i18n_en, i18n_es, :en, :es).should eql({})
|
26
|
+
end
|
27
|
+
end
|
28
28
|
end
|
@@ -25,14 +25,12 @@ describe :get_transdifflation_from_gem do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should call get_first_time_file if the files does not exist' do
|
28
|
-
|
29
|
-
|
30
28
|
#We actually don't care about basename, and we want to generate a testfile in our tests
|
31
29
|
File.stub(:basename).and_return('/dir/file_or_something')
|
32
30
|
File.stub(:join).and_return(File.join(File.dirname(__FILE__), '/assets/testfile'))
|
33
31
|
|
34
32
|
File.stub(:gsub).and_return('idontcare')
|
35
|
-
|
33
|
+
File.stub(:directory?).and_return(true)
|
36
34
|
#File? Should return false, to simulate that the file is not created
|
37
35
|
File.stub(:file?).and_return(false)
|
38
36
|
|
@@ -52,7 +50,7 @@ describe :get_transdifflation_from_gem do
|
|
52
50
|
File.stub(:join).and_return(File.join(File.dirname(__FILE__), '/assets/testfile'))
|
53
51
|
|
54
52
|
File.stub(:gsub).and_return('idontcare')
|
55
|
-
|
53
|
+
File.stub(:directory?).and_return(true)
|
56
54
|
#File? Should return true, to simulate that the file is exists
|
57
55
|
File.stub(:file?).and_return(true)
|
58
56
|
|
@@ -65,22 +63,17 @@ describe :get_transdifflation_from_gem do
|
|
65
63
|
end
|
66
64
|
|
67
65
|
it 'should translate yaml name from source locale to target locale' do
|
68
|
-
|
69
66
|
@path_to_yaml_in_gem = 'config/locales/en/gem_name.en.yml' #source file, it has to be translated, and match inner reg exp
|
70
67
|
|
71
68
|
#File? Should return true, to simulate that the file is exists
|
72
69
|
File.stub(:file?).and_return(true)
|
73
70
|
#Finally simulate the call to generate_diff_file
|
74
71
|
@comparer.stub(:generate_diff_file).and_return(nil)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
72
|
+
File.stub(:directory?).and_return(true)
|
79
73
|
|
80
74
|
#call to method
|
81
75
|
expect { @comparer.get_transdifflation_from_gem(@gem_name, @path_to_yaml_in_gem, @from_locale, @to_locale) }.to_not raise_error
|
82
76
|
end
|
83
|
-
|
84
77
|
end
|
85
78
|
|
86
79
|
describe :get_transdifflation_from_file do
|
@@ -104,12 +97,9 @@ describe :get_transdifflation_from_file do
|
|
104
97
|
|
105
98
|
#We require to simulate "Rails.root"
|
106
99
|
::Rails.stub(:root).and_return('/rails')
|
107
|
-
|
108
100
|
end
|
109
101
|
|
110
102
|
it 'should call get_first_time_file if the files does not exist' do
|
111
|
-
|
112
|
-
|
113
103
|
#We actually don't care about basename, and we want to generate a testfile in our tests
|
114
104
|
File.stub(:basename).and_return('/dir/file_or_something')
|
115
105
|
File.stub(:join).and_return('./spec/assets/testfile_path')
|
@@ -136,6 +126,7 @@ describe :get_transdifflation_from_file do
|
|
136
126
|
File.stub(:gsub).and_return('idontcare')
|
137
127
|
#File? Should return false, to simulate that the file is not created
|
138
128
|
File.stub(:file?).and_return(true)
|
129
|
+
File.stub(:directory?).and_return(true)
|
139
130
|
|
140
131
|
# And finally we are checking which method is being called, making them throw different exceptions
|
141
132
|
@comparer.stub(:get_first_time_file).and_raise(ArgumentError)
|
@@ -145,7 +136,6 @@ describe :get_transdifflation_from_file do
|
|
145
136
|
end
|
146
137
|
|
147
138
|
it 'should translate yaml name from source locale to target locale' do
|
148
|
-
|
149
139
|
@path_to_yaml_relative_from_rails_root = '../config/locales/en/file_name.en.yml' #source file, it has to be translated, and match inner reg exp
|
150
140
|
|
151
141
|
#File? Should return true, to simulate that the file is exists
|
@@ -154,12 +144,9 @@ describe :get_transdifflation_from_file do
|
|
154
144
|
#Finally simulate the call to generate_diff_file
|
155
145
|
@comparer.stub(:generate_diff_file).and_return(nil)
|
156
146
|
|
157
|
-
|
158
|
-
|
159
147
|
#call to method
|
160
148
|
expect { @comparer.get_transdifflation_from_file(@tag_name, @path_to_yaml_relative_from_rails_root, @from_locale, @to_locale) }.to_not raise_error
|
161
149
|
end
|
162
|
-
|
163
150
|
end
|
164
151
|
|
165
152
|
|
@@ -181,29 +168,24 @@ describe :comparer_common_methods do
|
|
181
168
|
|
182
169
|
#YAMLReader should returnb a valid hash
|
183
170
|
Transdifflation::YAMLReader.stub(:read_YAML_from_gem).and_return({en: {:home => "hogar"}})
|
184
|
-
|
185
|
-
|
186
171
|
#We require to simulate "Rails.root"
|
187
172
|
::Rails.stub(:root).and_return('/rails')
|
188
173
|
end
|
189
174
|
|
190
175
|
it 'should generate first timefile if the files does not exist' do
|
191
176
|
|
192
|
-
|
193
177
|
#We actually don't care about basename, and we want to generate a testfile in our tests
|
194
178
|
File.stub(:basename).and_return('config/locales/en/gem_name.en.yml')
|
195
179
|
|
196
|
-
|
197
180
|
#File? Should return false, to simulate that the file is not created
|
198
181
|
File.stub(:file?).and_return(false)
|
199
182
|
|
200
|
-
|
201
183
|
#now we must stub File.open, write and close in order to avoid fails on get_first_time_file
|
202
184
|
mock_file = mock("File")
|
203
185
|
mock_file.stub(:write).and_return(nil)
|
204
186
|
mock_file.stub(:close).and_return(nil)
|
205
187
|
File.stub(:open).and_return(mock_file)
|
206
|
-
|
188
|
+
File.stub(:directory?).and_return(true)
|
207
189
|
|
208
190
|
expect {@comparer.get_transdifflation_from_gem(@gem_name, @path_to_yaml_in_gem, @from_locale, @to_locale) }.to_not raise_error
|
209
191
|
end
|
@@ -222,10 +204,10 @@ describe :comparer_common_methods do
|
|
222
204
|
#We require to simulate "Rails.root"
|
223
205
|
::Rails.should_receive(:root).and_return('/rails')
|
224
206
|
File.stub(:gsub).and_return('idontcare')
|
207
|
+
File.stub(:directory?).and_return(true)
|
225
208
|
#File? Should return false, to simulate that the file is not created
|
226
209
|
File.stub(:file?).and_return(true)
|
227
210
|
|
228
|
-
|
229
211
|
#YAMLReader should return TWO valid hashes
|
230
212
|
Transdifflation::YAMLReader.stub(:read_YAML_from_pathfile).and_return( {es: {:dorothy => "Dorothy"}})
|
231
213
|
|
@@ -235,10 +217,7 @@ describe :comparer_common_methods do
|
|
235
217
|
mock_file.stub(:close).and_return(nil)
|
236
218
|
File.stub(:open).and_return(mock_file)
|
237
219
|
|
238
|
-
|
239
220
|
expect { @comparer.get_transdifflation_from_gem(@gem_name, @path_to_yaml_in_gem, @from_locale, @to_locale) }.to_not raise_error
|
240
|
-
|
241
|
-
|
242
221
|
end
|
243
222
|
|
244
223
|
it 'should generate a clear diff_file when differences exists' do
|
@@ -249,10 +228,10 @@ describe :comparer_common_methods do
|
|
249
228
|
#We require to simulate "Rails.root"
|
250
229
|
::Rails.should_receive(:root).and_return('/rails')
|
251
230
|
File.stub(:gsub).and_return('idontcare')
|
231
|
+
File.stub(:directory?).and_return(true)
|
252
232
|
#File? Should return false, to simulate that the file is not created
|
253
233
|
File.stub(:file?).and_return(true)
|
254
234
|
|
255
|
-
|
256
235
|
#now we must stub File.open, write and close in order to avoid fails on get_first_time_file
|
257
236
|
mock_file = mock("File")
|
258
237
|
mock_file.stub(:write).and_return(nil)
|
@@ -261,14 +240,56 @@ describe :comparer_common_methods do
|
|
261
240
|
|
262
241
|
#YAMLReader should return TWO valid hashes
|
263
242
|
Transdifflation::YAMLReader.stub(:read_YAML_from_pathfile).and_return({en: {:home => "hogar"}})
|
243
|
+
expect { @comparer.get_transdifflation_from_gem(@gem_name, @path_to_yaml_in_gem, @from_locale, @from_locale) }.to_not raise_error
|
244
|
+
end
|
264
245
|
|
246
|
+
it "should create a folder in get_transdifflation_from_gem when it doesn't exist" do
|
247
|
+
#We actually don't care about basename, and we want to generate a testfile in our tests
|
248
|
+
File.stub(:basename).and_return('/dir/file_or_something')
|
265
249
|
|
266
|
-
|
250
|
+
Transdifflation::YAMLReader.stub(:read_YAML_from_gem).and_return({en: {:home => "hogar"}}) #We require to simulate "Rails.root"
|
251
|
+
::Rails.should_receive(:root).and_return('/rails')
|
252
|
+
File.stub(:gsub).and_return('idontcare')
|
267
253
|
|
254
|
+
File.stub(:directory?).and_return(false)
|
255
|
+
#File? Should return false, to simulate that the file is not created
|
256
|
+
|
257
|
+
File.stub(:join).and_return(["./spec/tempFolder"])
|
258
|
+
File.stub(:file?).and_return(false)
|
268
259
|
|
260
|
+
#now we must stub File.open, write and close in order to avoid fails on get_first_time_file
|
261
|
+
mock_file = mock("File")
|
262
|
+
mock_file.stub(:write).and_return(nil)
|
263
|
+
mock_file.stub(:close).and_return(nil)
|
264
|
+
File.stub(:open).and_return(mock_file)
|
265
|
+
|
266
|
+
@comparer.get_transdifflation_from_gem(@gem_name, @path_to_yaml_in_gem, @from_locale, @from_locale)
|
267
|
+
FileUtils.remove_dir("./spec/tempFolder").should == 0
|
269
268
|
end
|
270
269
|
|
270
|
+
it "should create a folder in get_transdifflation_from_file when it doesn't exist" do
|
271
|
+
#We actually don't care about basename, and we want to generate a testfile in our tests
|
272
|
+
File.stub(:basename).and_return('/dir/file_or_something')
|
271
273
|
|
274
|
+
Transdifflation::YAMLReader.stub(:read_YAML_from_pathfile).and_return({en: {:home => "hogar"}}) #We require to simulate "Rails.root"
|
275
|
+
::Rails.should_receive(:root).and_return('/rails')
|
276
|
+
File.stub(:gsub).and_return('idontcare')
|
277
|
+
|
278
|
+
File.stub(:directory?).and_return(false)
|
279
|
+
#File? Should return false, to simulate that the file is not created
|
280
|
+
|
281
|
+
File.stub(:join).and_return(["./spec/tempFolder"])
|
282
|
+
File.stub(:file?).and_return(false)
|
283
|
+
|
284
|
+
#now we must stub File.open, write and close in order to avoid fails on get_first_time_file
|
285
|
+
mock_file = mock("File")
|
286
|
+
mock_file.stub(:write).and_return(nil)
|
287
|
+
mock_file.stub(:close).and_return(nil)
|
288
|
+
File.stub(:open).and_return(mock_file)
|
289
|
+
|
290
|
+
@comparer.get_transdifflation_from_file(@gem_name, @path_to_yaml_in_gem, @from_locale, @from_locale)
|
291
|
+
FileUtils.remove_dir("./spec/tempFolder").should == 0
|
292
|
+
end
|
272
293
|
end
|
273
294
|
|
274
295
|
|
data/spec/utilities_spec.rb
CHANGED
@@ -4,19 +4,19 @@ describe :symbolize! do
|
|
4
4
|
it 'convert a key in a Hash (presumily from YAML) in symbol' do
|
5
5
|
example_hash = { "es" => 666 }
|
6
6
|
example_hash.symbolize!
|
7
|
-
|
7
|
+
example_hash.should == { :es => 666 }
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'convert all keys in a Hash (presumily from YAML) in symbols' do
|
11
11
|
example_hash = { "es" => 666, "lala" => "truururur" }
|
12
12
|
example_hash.symbolize!
|
13
|
-
|
13
|
+
example_hash.should == { :es => 666, :lala => "truururur" }
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'convert all keys in a Hash (presumily from YAML) in symbols but if there is a hash it should leave it' do
|
17
17
|
example_hash = { :es => 666, "lala" => "truururur" }
|
18
18
|
example_hash.symbolize!
|
19
|
-
|
19
|
+
example_hash.should == { :es => 666, :lala => "truururur" }
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should return something usefull on nil' do
|
@@ -31,4 +31,4 @@ describe :symbolize! do
|
|
31
31
|
hash_translator.symbolize(example_hash)
|
32
32
|
example_hash.should == { :es => 666, "lala" => "truururur", :nested => {:another => "Call for simbolize"}}
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
data/spec/yaml_reader_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe :YAMLReader do
|
|
26
26
|
File.stub(:file?).and_return(true)
|
27
27
|
::Rails.should_receive(:root).and_return('/rails')
|
28
28
|
|
29
|
-
|
29
|
+
|
30
30
|
expect {Transdifflation::YAMLReader.read_YAML_from_filesystem('whatever')}.to_not raise_error(ArgumentError)
|
31
31
|
end
|
32
32
|
end
|
@@ -45,8 +45,8 @@ describe :YAMLReader do
|
|
45
45
|
it 'should not raise an error exception when a gem exists (rspec)' do
|
46
46
|
a_gem = 'rspec'
|
47
47
|
a_path = 'README.md'
|
48
|
-
|
49
48
|
Transdifflation::YAMLReader.stub(:get_YAML_content_from_YAML_file).and_return(':a => 2')
|
49
|
+
|
50
50
|
expect {Transdifflation::YAMLReader.read_YAML_from_gem(a_gem, a_path)}.to_not raise_error(ArgumentError)
|
51
51
|
end
|
52
52
|
end
|
@@ -73,8 +73,8 @@ describe :YAMLReader do
|
|
73
73
|
it 'should return {} when there is no YAML file' do
|
74
74
|
a_yml_path = 'bad.yml'
|
75
75
|
YAML.stub(:load_file).and_return(false)
|
76
|
-
|
77
|
-
|
76
|
+
|
77
|
+
Transdifflation::YAMLReader.get_YAML_content_from_YAML_file(a_yml_path).should == {}
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'should return the YAML in case it load properly the file' do
|
data/spec/yaml_writer_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe :YAMLWriter do
|
|
15
15
|
|
16
16
|
it 'should chomp if matches with the regex: /\?\s+/' do
|
17
17
|
hashy = {:movie => "Avengers"}
|
18
|
-
Regex = "!ruby/symbol ---? \"es\"\n"
|
18
|
+
Regex = "!ruby/symbol ---? \"es\"\n"
|
19
19
|
hashy.deep_stringify_keys.stub(:send).and_return(Regex)
|
20
20
|
|
21
21
|
Transdifflation::YAMLWriter.to_yaml(hashy).should be == ":\"es\""
|
@@ -27,7 +27,7 @@ describe :YAMLWriter do
|
|
27
27
|
hashy = {:en=>{:date=>{:formats=>{:default=>"%d/%m/%Y", :short=>"%d %b"}}}}
|
28
28
|
hashy.deep_stringify_keys.should == {:en=>{:date=>{:formats=>{:default=>"%d/%m/%Y", :short=>"%d %b"}}}}
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
it 'should print all the nodes from a hash in the exact same order' do
|
32
32
|
hashy = {:en=>{:date=>{:formats=>{:default=>"%d/%m/%Y", :short=>"%d %b"}}}}
|
33
33
|
hashy.deep_stringify_keys.should == hashy
|
@@ -39,4 +39,4 @@ describe :YAMLWriter do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
end
|
42
|
+
end
|
data/transdifflation.gemspec
CHANGED
@@ -16,7 +16,8 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = Transdifflation::VERSION
|
17
17
|
|
18
18
|
#Dependencies
|
19
|
-
gem.add_dependency
|
19
|
+
gem.add_dependency('rails', '~> 3.2.8')
|
20
|
+
gem.add_dependency('ya2yaml')
|
20
21
|
|
21
22
|
gem.add_development_dependency 'rspec', '>= 2.8.0'
|
22
23
|
gem.add_development_dependency 'guard-rspec'
|
@@ -29,3 +30,4 @@ Gem::Specification.new do |gem|
|
|
29
30
|
gem.add_development_dependency 'pry'
|
30
31
|
end
|
31
32
|
|
33
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transdifflation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
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-10-
|
12
|
+
date: 2012-10-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.2.8
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: ya2yaml
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: rspec
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|