makeloc 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/VERSION +1 -1
- data/lib/makeloc/core_extensions.rb +31 -13
- data/lib/makeloc/generators/do/USAGE +3 -1
- data/lib/makeloc/generators/do/do_generator.rb +7 -1
- data/makeloc.gemspec +5 -6
- data/spec/generators/test_generator_spec.rb +63 -50
- data/spec/generators/tmp/{test.en.yml.bk → test.en.yml.original} +0 -0
- data/spec/generators/tmp/{test_incomplete.en.yml.bk → test_incomplete.en.yml.original} +2 -0
- data/spec/spec_helper.rb +2 -2
- metadata +4 -5
- data/spec/generators/tmp/test.en.yml +0 -185
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3d4e4f0024656f307a78ca6f2666e6c393dc05d
|
4
|
+
data.tar.gz: 00f1cb02e417f676c20b02ac87334711841a10a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cf55090558bb393400048527940adb4e7aca1c1241b3b2d33edd13db4e697b92a2a2b0037d568f12f848323fbb8c236dc5997f0cdc3bff3e46e3c095fa682d8
|
7
|
+
data.tar.gz: 883bedc6f342a923d02a9b7e230a4ecb7f1e07b9211b7273b7f3237e298bd316ab813b1039a3c8794d58035d93e0dfec8839d5c22f626accf317e5bac9d36260
|
data/README.md
CHANGED
@@ -12,8 +12,9 @@ Makeloc, given a reference filepath (formatted as `path/to/file/context.referenc
|
|
12
12
|
## Usage
|
13
13
|
Makeloc is a generator. The following will create, or update if it exists, the file `config/locales/activerecord.it.yml`
|
14
14
|
|
15
|
-
rails g makeloc:do it config/locales/activerecord.en.yml
|
15
|
+
rails g makeloc:do it config/locales/activerecord.en.yml [--strict]
|
16
16
|
|
17
|
+
with option --strict it overwrites (if already present) the generated locale file deleting its original extra translations
|
17
18
|
|
18
19
|
## Test
|
19
20
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -37,29 +37,47 @@ class Hash
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def at(path)
|
40
|
+
def at(path,opts={})
|
41
41
|
array_path = path.to_s.split('.')
|
42
42
|
current_key = array_path.shift
|
43
|
+
# raise ArgumentError, "wrong key " unless self.keys.include?(current_key)
|
44
|
+
raise ArgumentError, "wrong opts" unless (opts.empty? or opts[:set])
|
43
45
|
if array_path.empty?
|
44
|
-
|
46
|
+
case opts[:set]
|
47
|
+
when :delete
|
48
|
+
self.delete(current_key)
|
49
|
+
when nil
|
50
|
+
self[current_key]
|
51
|
+
else
|
52
|
+
self[current_key] = opts[:set]
|
53
|
+
end
|
45
54
|
else
|
46
|
-
self[current_key].at(array_path.join('.'))
|
55
|
+
self[current_key] and self[current_key].at(array_path.join('.'),opts)
|
47
56
|
end
|
48
57
|
end
|
49
58
|
|
59
|
+
def delete_at(path)
|
60
|
+
at(path, :set => :delete)
|
61
|
+
end
|
62
|
+
|
50
63
|
end
|
51
64
|
|
52
|
-
# hash = { a: 1, b: { d: 2, e: [3, 4] }, c: {f: 0, g: 3} }
|
65
|
+
# # hash = { a: 1, b: { d: 2, e: [3, 4] }, c: {f: 0, g: 3} }
|
53
66
|
# hash = {"date"=>{"abbr_day_names"=>["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"], "abbr_month_names"=>[nil, "Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"], "day_names"=>["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"], "formats"=>{"default"=>"%d-%m-%Y", "long"=>"%d %B %Y", "short"=>"%d %b"}, "month_names"=>[nil, "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"], "order"=>[:day, :month, :year]}, "datetime"=>{"distance_in_words"=>{"about_x_hours"=>{"one"=>"circa un'ora", "other"=>"circa %{count} ore"}, "about_x_months"=>{"one"=>"circa un mese", "other"=>"circa %{count} mesi"}, "about_x_years"=>{"one"=>"circa un anno", "other"=>"circa %{count} anni"}, "almost_x_years"=>{"one"=>"circa 1 anno", "other"=>"circa %{count} anni"}, "half_a_minute"=>"mezzo minuto", "less_than_x_minutes"=>{"one"=>"meno di un minuto", "other"=>"meno di %{count} minuti"}, "less_than_x_seconds"=>{"one"=>"meno di un secondo", "other"=>"meno di %{count} secondi"}, "over_x_years"=>{"one"=>"oltre un anno", "other"=>"oltre %{count} anni"}, "x_days"=>{"one"=>"1 giorno", "other"=>"%{count} giorni"}, "x_minutes"=>{"one"=>"1 minuto", "other"=>"%{count} minuti"}, "x_months"=>{"one"=>"1 mese", "other"=>"%{count} mesi"}, "x_seconds"=>{"one"=>"1 secondo", "other"=>"%{count} secondi"}}, "prompts"=>{"day"=>"Giorno", "hour"=>"Ora", "minute"=>"Minuto", "month"=>"Mese", "second"=>"Secondi", "year"=>"Anno"}}, "errors"=>{"format"=>"%{attribute} %{message}", "messages"=>{"accepted"=>"deve essere accettata", "blank"=>"non può essere lasciato in bianco", "confirmation"=>"non coincide con la conferma", "empty"=>"non può essere vuoto", "equal_to"=>"deve essere uguale a %{count}", "even"=>"deve essere pari", "exclusion"=>"è riservato", "greater_than"=>"deve essere superiore a %{count}", "greater_than_or_equal_to"=>"deve essere superiore o uguale a %{count}", "inclusion"=>"non è incluso nella lista", "invalid"=>"non è valido", "less_than"=>"deve essere meno di %{count}", "less_than_or_equal_to"=>"deve essere meno o uguale a %{count}", "not_a_number"=>"non è un numero", "not_an_integer"=>"non è un intero", "odd"=>"deve essere dispari", "record_invalid"=>"Validazione fallita: %{errors}", "taken"=>"è già in uso", "too_long"=>{"one"=>"è troppo lungo (il massimo è 1 carattere)", "other"=>"è troppo lungo (il massimo è %{count} caratteri)"}, "too_short"=>{"one"=>"è troppo corto (il minimo è 1 carattere)", "other"=>"è troppo corto (il minimo è %{count} caratteri)"}, "wrong_length"=>{"one"=>"è della lunghezza sbagliata (deve essere di 1 carattere)", "other"=>"è della lunghezza sbagliata (deve essere di %{count} caratteri)"}}, "template"=>{"body"=>"Per favore ricontrolla i seguenti campi:", "header"=>{"one"=>"Non posso salvare questo %{model}: 1 errore", "other"=>"Non posso salvare questo %{model}: %{count} errori."}}}, "helpers"=>{"select"=>{"prompt"=>"Per favore, seleziona", "prompt_allow_nil"=>"Per favore, seleziona o lascia in binaco"}, "submit"=>{"create"=>"Crea %{model}", "submit"=>"Invia %{model}", "update"=>"Aggiorna %{model}", "cancel"=>"Annulla %{model}", "reset"=>"Cancella %{model}", "add"=>"Aggiungi %{model}"}, "links"=>{"new"=>"Nuovo %{model}", "add"=>"Aggiungi %{model}", "edit"=>"Modifica %{model}", "reset"=>"Reset", "back"=>"Indietro", "cancel"=>"Annulla", "confirm"=>"Sei sicuro?", "destroy"=>"Elimina %{model}", "show"=>"Visualizza %{model}"}, "titles"=>{"index"=>"Lista %{model}", "edit"=>"Modifica %{model}", "new"=>"Nuovo %{model}", "show"=>"Riepilogo %{model}"}, "tooltips"=>{"edit"=>"Modifica %{model}", "save"=>"Salva %{model}", "new"=>"Crea %{model}", "destroy"=>"Elimina %{model}", "back"=>"Torna alla lista", "show"=>"Visualizza %{model}", "add"=>"Aggiungi %{model}"}}, "sign_out"=>"Esci", "sign_in"=>"Accedi", "number"=>{"currency"=>{"format"=>{"delimiter"=>",", "format"=>"%n %u", "precision"=>2, "separator"=>".", "significant"=>false, "strip_insignificant_zeros"=>false, "unit"=>"€"}}, "format"=>{"delimiter"=>",", "precision"=>2, "separator"=>".", "significant"=>false, "strip_insignificant_zeros"=>false}, "human"=>{"decimal_units"=>{"format"=>"%n %u", "units"=>{"billion"=>"Miliardi", "million"=>"Milioni", "quadrillion"=>"Biliardi", "thousand"=>"Mila", "trillion"=>"Bilioni", "unit"=>""}}, "format"=>{"delimiter"=>"", "precision"=>1, "significant"=>true, "strip_insignificant_zeros"=>true}, "storage_units"=>{"format"=>"%n %u", "units"=>{"byte"=>{"one"=>"Byte", "other"=>"Byte"}, "gb"=>"GB", "kb"=>"KB", "mb"=>"MB", "tb"=>"TB"}}}, "percentage"=>{"format"=>{"delimiter"=>""}}, "precision"=>{"format"=>{"delimiter"=>""}}}, "support"=>{"array"=>{"last_word_connector"=>" e ", "two_words_connector"=>" e ", "words_connector"=>", "}}, "time"=>{"am"=>"am", "formats"=>{"default"=>"%a %d %b %Y, %H:%M:%S %z", "long"=>"%d %B %Y %H:%M", "short"=>"%d %b %H:%M"}, "pm"=>"pm"}, "gender_suffix"=>{"M"=>"o", "F"=>"a"}, "activemodel"=>{"errors"=>{"format"=>"%{attribute} %{message}", "messages"=>{"accepted"=>"deve essere accettata", "blank"=>"non può essere lasciato in bianco", "confirmation"=>"non coincide con la conferma", "empty"=>"non può essere vuoto", "equal_to"=>"deve essere uguale a %{count}", "even"=>"deve essere pari", "exclusion"=>"è riservato", "greater_than"=>"deve essere superiore a %{count}", "greater_than_or_equal_to"=>"deve essere superiore o uguale a %{count}", "inclusion"=>"non è incluso nella lista", "invalid"=>"non è valido", "less_than"=>"deve essere meno di %{count}", "less_than_or_equal_to"=>"deve essere meno o uguale a %{count}", "not_a_number"=>"non è un numero", "not_an_integer"=>"non è un intero", "odd"=>"deve essere dispari", "record_invalid"=>"Validazione fallita: %{errors}", "taken"=>"è già in uso", "too_long"=>{"one"=>"è troppo lungo (il massimo è 1 carattere)", "other"=>"è troppo lungo (il massimo è %{count} caratteri)"}, "too_short"=>{"one"=>"è troppo corto (il minimo è 1 carattere)", "other"=>"è troppo corto (il minimo è %{count} caratteri)"}, "wrong_length"=>{"one"=>"è della lunghezza sbagliata (deve essere di 1 carattere)", "other"=>"è della lunghezza sbagliata (deve essere di %{count} caratteri)"}}, "template"=>{"body"=>"Per favore ricontrolla i seguenti campi:", "header"=>{"one"=>"Non posso salvare questo %{model}: 1 errore", "other"=>"Non posso salvare questo %{model}: %{count} errori."}}}}, "activerecord"=>{"errors"=>{"format"=>"%{attribute} %{message}", "messages"=>{"accepted"=>"deve essere accettata", "blank"=>"non può essere lasciato in bianco", "confirmation"=>"non coincide con la conferma", "empty"=>"non può essere vuoto", "equal_to"=>"deve essere uguale a %{count}", "even"=>"deve essere pari", "exclusion"=>"è riservato", "greater_than"=>"deve essere superiore a %{count}", "greater_than_or_equal_to"=>"deve essere superiore o uguale a %{count}", "inclusion"=>"non è incluso nella lista", "invalid"=>"non è valido", "less_than"=>"deve essere meno di %{count}", "less_than_or_equal_to"=>"deve essere meno o uguale a %{count}", "not_a_number"=>"non è un numero", "not_an_integer"=>"non è un intero", "odd"=>"deve essere dispari", "record_invalid"=>"Validazione fallita: %{errors}", "taken"=>"è già in uso", "too_long"=>{"one"=>"è troppo lungo (il massimo è 1 carattere)", "other"=>"è troppo lungo (il massimo è %{count} caratteri)"}, "too_short"=>{"one"=>"è troppo corto (il minimo è 1 carattere)", "other"=>"è troppo corto (il minimo è %{count} caratteri)"}, "wrong_length"=>{"one"=>"è della lunghezza sbagliata (deve essere di 1 carattere)", "other"=>"è della lunghezza sbagliata (deve essere di %{count} caratteri)"}}, "template"=>{"body"=>"Per favore ricontrolla i seguenti campi:", "header"=>{"one"=>"Non posso salvare questo %{model}: 1 errore", "other"=>"Non posso salvare questo %{model}: %{count} errori."}}}}}
|
54
67
|
|
55
|
-
# puts hash.at('date.
|
68
|
+
# # puts hash.at('date.dady_names').nil?
|
69
|
+
# # puts hash.at('datetime.distance_in_words.about_x_hours.one', :set => 'ciccio')
|
70
|
+
# # puts hash.at('datetime.distance_in_words.about_x_hours.one')
|
71
|
+
# # puts hash.at('datetime.distance_in_words.about_x_hours.one', :set => :delete)
|
72
|
+
# puts hash.delete_at('datetime.distance_in_words.about_x_hours.one')
|
73
|
+
# puts hash.at('datetime.distance_in_words.about_x_hours')
|
56
74
|
|
57
|
-
# hash.parse{|k,v| puts "#{k} => #{v}"}
|
58
|
-
# puts
|
59
|
-
# hash.parse_leaves{|k,v| puts "#{k} => #{v}"}
|
60
|
-
# puts
|
61
|
-
# hash.parse(true){|k,v| puts "#{k} => #{v}"}
|
62
|
-
# puts
|
63
|
-
# hash.update_leaves!{|k,v| nil }
|
75
|
+
# # hash.parse{|k,v| puts "#{k} => #{v}"}
|
76
|
+
# # puts
|
77
|
+
# # hash.parse_leaves{|k,v| puts "#{k} => #{v}"}
|
78
|
+
# # puts
|
79
|
+
# # hash.parse(true){|k,v| puts "#{k} => #{v}"}
|
80
|
+
# # puts
|
81
|
+
# # hash.update_leaves!{|k,v| nil }
|
64
82
|
|
65
|
-
# puts hash
|
83
|
+
# # puts hash
|
@@ -2,7 +2,9 @@ Description:
|
|
2
2
|
A little generator to tidy locale files along with their content for Ruby On Rails
|
3
3
|
|
4
4
|
Example:
|
5
|
-
rails g makeloc:do it config/locales/activerecord.en.yml
|
5
|
+
rails g makeloc:do it config/locales/activerecord.en.yml [--strict]
|
6
6
|
|
7
7
|
This will create:
|
8
8
|
config/locales/activerecord.it.yml
|
9
|
+
|
10
|
+
with option --strict it overwrites (if already present) the generated locale file deleting its original extra translations
|
@@ -6,6 +6,7 @@ module Makeloc
|
|
6
6
|
|
7
7
|
argument :target_lang, :type => :string
|
8
8
|
argument :source_file, :type => :string
|
9
|
+
class_option :strict, :type => :boolean
|
9
10
|
|
10
11
|
def do
|
11
12
|
ref_locale_fp = Pathname.new(source_file)
|
@@ -23,7 +24,12 @@ module Makeloc
|
|
23
24
|
# updating target data with original values if they exists
|
24
25
|
if File.exist? target_fp
|
25
26
|
existing_target_data = YAML.load(File.open(File.expand_path(target_fp)))[target_lang]
|
26
|
-
|
27
|
+
|
28
|
+
# delete extra keys present in original target data
|
29
|
+
(existing_target_data.flatten_keys - target_data.flatten_keys).each{|extra_key| existing_target_data.delete_at(extra_key)} if options[:strict]
|
30
|
+
|
31
|
+
target_data.deep_merge!(existing_target_data)
|
32
|
+
|
27
33
|
end
|
28
34
|
|
29
35
|
create_file(target_fp){ {target_lang => target_data}.to_yaml(:line_width => -1) } # line_width => -1 to disable indentation
|
data/makeloc.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: makeloc 0.
|
5
|
+
# stub: makeloc 0.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "makeloc"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.2.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["masciugo"]
|
14
|
-
s.date = "2014-07-
|
14
|
+
s.date = "2014-07-09"
|
15
15
|
s.description = ""
|
16
16
|
s.email = "masciugo@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -33,10 +33,9 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/makeloc/railtie.rb",
|
34
34
|
"makeloc.gemspec",
|
35
35
|
"spec/generators/test_generator_spec.rb",
|
36
|
-
"spec/generators/tmp/test.en.yml",
|
37
|
-
"spec/generators/tmp/test.en.yml.bk",
|
36
|
+
"spec/generators/tmp/test.en.yml.original",
|
38
37
|
"spec/generators/tmp/test.it.yml",
|
39
|
-
"spec/generators/tmp/test_incomplete.en.yml.
|
38
|
+
"spec/generators/tmp/test_incomplete.en.yml.original",
|
40
39
|
"spec/spec_helper.rb"
|
41
40
|
]
|
42
41
|
s.homepage = "http://github.com/masciugo/makeloc"
|
@@ -4,69 +4,82 @@ module Makeloc
|
|
4
4
|
|
5
5
|
describe DoGenerator do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
# loaded once at beginning
|
8
|
+
let!(:ref_hash_with_root) { YAML.load(File.read(REF_LANG_FP)) }
|
9
|
+
let!(:ref_hash) { ref_hash_with_root[REF_LANG] }
|
10
|
+
let!(:incomplete_target_hash_with_root) { YAML.load(File.read(TARGET_INCOMPLETE_ORIGINAL_FP)) }
|
11
|
+
let!(:incomplete_target_hash) { incomplete_target_hash_with_root[TARGET_LANG] }
|
12
|
+
|
13
|
+
EXTRA_KEYS = %w{ date.extra_key_1 date.formats.extra_key_2 }
|
14
|
+
MISSING_KEYS = %w{ datetime.distance_in_words.about_x_hours.other date.abbr_day_names }
|
15
|
+
|
16
|
+
# loaded at runtime after each generation
|
17
|
+
let(:target_hash_with_root) { YAML.load(File.read(TARGET_LANG_FP)) }
|
18
|
+
let(:target_hash) { target_hash_with_root[TARGET_LANG] }
|
19
|
+
|
20
|
+
shared_examples "a brand new generated locale file" do
|
21
|
+
it "should generate a #{TARGET_LANG_FP.basename} file in the same dir" do
|
22
|
+
File.exists? TARGET_LANG_FP
|
23
|
+
end
|
24
|
+
it "#{TARGET_LANG_FP.basename} hash has '#{TARGET_LANG}' as root key" do
|
25
|
+
target_hash_with_root.keys.should ==([TARGET_LANG])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
shared_examples "a new generated locale file with identical structure" do
|
30
|
+
it "#{TARGET_LANG_FP.basename} hash has identical keys set as #{REF_LANG_FP.basename} hash" do
|
31
|
+
target_hash.flatten_keys.should eql(ref_hash.flatten_keys)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
with_input "y\n" do
|
36
|
+
|
37
|
+
context "when #{TARGET_LANG_FP.basename} doesn't exist" do
|
38
|
+
with_args "en", REF_LANG_FP
|
39
|
+
|
10
40
|
before(:each) do
|
11
|
-
FileUtils.
|
41
|
+
FileUtils.rm_rf TARGET_LANG_FP
|
42
|
+
subject.should generate
|
12
43
|
end
|
13
44
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
let(:target_hash) { target_hash_with_root[TARGET_LANG] }
|
21
|
-
|
22
|
-
shared_examples "a brand new generated locale file" do
|
23
|
-
it "should generate a #{TARGET_LANG_FP.basename} file in the same dir" do
|
24
|
-
File.exists? TARGET_LANG_FP
|
25
|
-
end
|
26
|
-
it "#{TARGET_LANG_FP.basename} hash has same structure as hash for #{REF_LANG_FP.basename}" do
|
27
|
-
ref_hash.flatten_keys.should eql(target_hash.flatten_keys)
|
28
|
-
end
|
29
|
-
it "#{TARGET_LANG_FP.basename} hash has '#{TARGET_LANG}' as root key" do
|
30
|
-
target_hash_with_root.keys.should ==([TARGET_LANG])
|
31
|
-
end
|
45
|
+
it_should_behave_like "a brand new generated locale file"
|
46
|
+
it_should_behave_like "a new generated locale file with identical structure"
|
47
|
+
it "gets created with nil leaves" do
|
48
|
+
all_values = []
|
49
|
+
target_hash.parse_leaves{|k,v| all_values << v }
|
50
|
+
all_values.compact.should be_empty
|
32
51
|
end
|
52
|
+
end
|
33
53
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# loaded once at beginning
|
38
|
-
let!(:incomplete_target_hash_with_root) { YAML.load(File.read(TARGET_INCOMPLETE_BK_FP)) }
|
39
|
-
let!(:incomplete_target_hash) { incomplete_target_hash_with_root[TARGET_LANG] }
|
40
|
-
|
41
|
-
before(:each) do
|
42
|
-
FileUtils.cp TARGET_INCOMPLETE_BK_FP, TARGET_LANG_FP
|
43
|
-
subject.should generate
|
44
|
-
end
|
45
|
-
it_should_behave_like "a brand new generated locale file"
|
54
|
+
context "when #{TARGET_LANG_FP.basename} already exists with some missing keys (ie.: #{MISSING_KEYS.join(', ')}) and some extra keys (ie.: #{EXTRA_KEYS.join(', ')})" do
|
55
|
+
with_args "en", REF_LANG_FP
|
46
56
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
52
|
-
it "keeps old values (value at 'date.abbr_month_names' is in lang #{TARGET_LANG})" do
|
53
|
-
target_hash.at('date.abbr_month_names').should ==(incomplete_target_hash.at('date.abbr_month_names'))
|
54
|
-
end
|
57
|
+
before(:each) do
|
58
|
+
FileUtils.cp TARGET_INCOMPLETE_ORIGINAL_FP, TARGET_LANG_FP
|
59
|
+
subject.should generate
|
55
60
|
end
|
56
61
|
|
57
|
-
|
58
|
-
|
59
|
-
|
62
|
+
it_should_behave_like "a brand new generated locale file"
|
63
|
+
MISSING_KEYS.each do |key|
|
64
|
+
it "value at '#{key}' is nil" do
|
65
|
+
target_hash.at(key).should be_nil
|
60
66
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
67
|
+
end
|
68
|
+
it "keeps old values (value at 'date.abbr_month_names' is in lang #{TARGET_LANG})" do
|
69
|
+
target_hash.at('date.abbr_month_names').should ==(incomplete_target_hash.at('date.abbr_month_names'))
|
70
|
+
end
|
71
|
+
EXTRA_KEYS.each do |key|
|
72
|
+
it "keeps extra key #{key} along with its original value" do
|
73
|
+
target_hash.at(key).should == incomplete_target_hash.at(key)
|
66
74
|
end
|
67
75
|
end
|
76
|
+
context "with option --strict" do
|
77
|
+
with_args "en", REF_LANG_FP, '--strict'
|
78
|
+
it_should_behave_like "a new generated locale file with identical structure"
|
79
|
+
end
|
68
80
|
|
69
81
|
end
|
82
|
+
|
70
83
|
end
|
71
84
|
|
72
85
|
end
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -38,5 +38,5 @@ REF_LANG = 'it'
|
|
38
38
|
REF_LANG_FP = Pathname.new(File.join(TMP_FOLDER,"test.#{REF_LANG}.yml"))
|
39
39
|
TARGET_LANG_FP = Pathname.new(File.join(TMP_FOLDER,"test.#{TARGET_LANG}.yml"))
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
TARGET_LANG_ORIGINAL_FP = Pathname.new(File.join(TMP_FOLDER,"test.#{TARGET_LANG}.yml.original"))
|
42
|
+
TARGET_INCOMPLETE_ORIGINAL_FP = Pathname.new(File.join(TMP_FOLDER,"test_incomplete.#{TARGET_LANG}.yml.original"))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: makeloc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masciugo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -144,10 +144,9 @@ files:
|
|
144
144
|
- lib/makeloc/railtie.rb
|
145
145
|
- makeloc.gemspec
|
146
146
|
- spec/generators/test_generator_spec.rb
|
147
|
-
- spec/generators/tmp/test.en.yml
|
148
|
-
- spec/generators/tmp/test.en.yml.bk
|
147
|
+
- spec/generators/tmp/test.en.yml.original
|
149
148
|
- spec/generators/tmp/test.it.yml
|
150
|
-
- spec/generators/tmp/test_incomplete.en.yml.
|
149
|
+
- spec/generators/tmp/test_incomplete.en.yml.original
|
151
150
|
- spec/spec_helper.rb
|
152
151
|
homepage: http://github.com/masciugo/makeloc
|
153
152
|
licenses:
|
@@ -1,185 +0,0 @@
|
|
1
|
-
---
|
2
|
-
en:
|
3
|
-
date:
|
4
|
-
abbr_day_names:
|
5
|
-
abbr_month_names:
|
6
|
-
day_names:
|
7
|
-
formats:
|
8
|
-
default:
|
9
|
-
long:
|
10
|
-
short:
|
11
|
-
month_names:
|
12
|
-
order:
|
13
|
-
datetime:
|
14
|
-
distance_in_words:
|
15
|
-
about_x_hours:
|
16
|
-
one:
|
17
|
-
other:
|
18
|
-
about_x_months:
|
19
|
-
one:
|
20
|
-
other:
|
21
|
-
about_x_years:
|
22
|
-
one:
|
23
|
-
other:
|
24
|
-
almost_x_years:
|
25
|
-
one:
|
26
|
-
other:
|
27
|
-
half_a_minute:
|
28
|
-
less_than_x_minutes:
|
29
|
-
one:
|
30
|
-
other:
|
31
|
-
less_than_x_seconds:
|
32
|
-
one:
|
33
|
-
other:
|
34
|
-
over_x_years:
|
35
|
-
one:
|
36
|
-
other:
|
37
|
-
x_days:
|
38
|
-
one:
|
39
|
-
other:
|
40
|
-
x_minutes:
|
41
|
-
one:
|
42
|
-
other:
|
43
|
-
x_months:
|
44
|
-
one:
|
45
|
-
other:
|
46
|
-
x_seconds:
|
47
|
-
one:
|
48
|
-
other:
|
49
|
-
prompts:
|
50
|
-
day:
|
51
|
-
hour:
|
52
|
-
minute:
|
53
|
-
month:
|
54
|
-
second:
|
55
|
-
year:
|
56
|
-
errors:
|
57
|
-
format:
|
58
|
-
messages:
|
59
|
-
accepted:
|
60
|
-
blank:
|
61
|
-
confirmation:
|
62
|
-
empty:
|
63
|
-
equal_to:
|
64
|
-
even:
|
65
|
-
exclusion:
|
66
|
-
greater_than:
|
67
|
-
greater_than_or_equal_to:
|
68
|
-
inclusion:
|
69
|
-
invalid:
|
70
|
-
less_than:
|
71
|
-
less_than_or_equal_to:
|
72
|
-
not_a_number:
|
73
|
-
not_an_integer:
|
74
|
-
odd:
|
75
|
-
record_invalid:
|
76
|
-
taken:
|
77
|
-
too_long:
|
78
|
-
one:
|
79
|
-
other:
|
80
|
-
too_short:
|
81
|
-
one:
|
82
|
-
other:
|
83
|
-
wrong_length:
|
84
|
-
one:
|
85
|
-
other:
|
86
|
-
template:
|
87
|
-
body:
|
88
|
-
header:
|
89
|
-
one:
|
90
|
-
other:
|
91
|
-
helpers:
|
92
|
-
select:
|
93
|
-
prompt:
|
94
|
-
prompt_allow_nil:
|
95
|
-
submit:
|
96
|
-
create:
|
97
|
-
submit:
|
98
|
-
update:
|
99
|
-
cancel:
|
100
|
-
reset:
|
101
|
-
add:
|
102
|
-
links:
|
103
|
-
new:
|
104
|
-
add:
|
105
|
-
edit:
|
106
|
-
reset:
|
107
|
-
back:
|
108
|
-
cancel:
|
109
|
-
confirm:
|
110
|
-
destroy:
|
111
|
-
show:
|
112
|
-
titles:
|
113
|
-
index:
|
114
|
-
edit:
|
115
|
-
new:
|
116
|
-
show:
|
117
|
-
tooltips:
|
118
|
-
edit:
|
119
|
-
save:
|
120
|
-
new:
|
121
|
-
destroy:
|
122
|
-
back:
|
123
|
-
show:
|
124
|
-
add:
|
125
|
-
sign_out:
|
126
|
-
sign_in:
|
127
|
-
number:
|
128
|
-
currency:
|
129
|
-
format:
|
130
|
-
delimiter:
|
131
|
-
format:
|
132
|
-
precision:
|
133
|
-
separator:
|
134
|
-
significant:
|
135
|
-
strip_insignificant_zeros:
|
136
|
-
unit:
|
137
|
-
format:
|
138
|
-
delimiter:
|
139
|
-
precision:
|
140
|
-
separator:
|
141
|
-
significant:
|
142
|
-
strip_insignificant_zeros:
|
143
|
-
human:
|
144
|
-
decimal_units:
|
145
|
-
format:
|
146
|
-
units:
|
147
|
-
billion:
|
148
|
-
million:
|
149
|
-
quadrillion:
|
150
|
-
thousand:
|
151
|
-
trillion:
|
152
|
-
unit:
|
153
|
-
format:
|
154
|
-
delimiter:
|
155
|
-
precision:
|
156
|
-
significant:
|
157
|
-
strip_insignificant_zeros:
|
158
|
-
storage_units:
|
159
|
-
format:
|
160
|
-
units:
|
161
|
-
byte:
|
162
|
-
one:
|
163
|
-
other:
|
164
|
-
gb:
|
165
|
-
kb:
|
166
|
-
mb:
|
167
|
-
tb:
|
168
|
-
percentage:
|
169
|
-
format:
|
170
|
-
delimiter:
|
171
|
-
precision:
|
172
|
-
format:
|
173
|
-
delimiter:
|
174
|
-
support:
|
175
|
-
array:
|
176
|
-
last_word_connector:
|
177
|
-
two_words_connector:
|
178
|
-
words_connector:
|
179
|
-
time:
|
180
|
-
am:
|
181
|
-
formats:
|
182
|
-
default:
|
183
|
-
long:
|
184
|
-
short:
|
185
|
-
pm:
|