vocab 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/.gitignore +2 -1
- data/CHANGELOG.md +4 -0
- data/MIT-LICENSE +7 -0
- data/README.md +66 -14
- data/bin/vocab +1 -1
- data/lib/vocab/application.rb +7 -5
- data/lib/vocab/extractor/android.rb +31 -14
- data/lib/vocab/extractor/base.rb +27 -11
- data/lib/vocab/extractor/rails.rb +16 -6
- data/lib/vocab/merger/android.rb +48 -15
- data/lib/vocab/merger/base.rb +0 -6
- data/lib/vocab/translator/android.rb +67 -9
- data/lib/vocab/validator/android.rb +2 -2
- data/lib/vocab/validator/base.rb +7 -1
- data/lib/vocab/validator/rails.rb +1 -1
- data/lib/vocab/version.rb +1 -1
- data/spec/data/android/locales/values/strings.xml +11 -0
- data/spec/data/android/locales/values-es/strings.xml +5 -0
- data/spec/data/android/translations/values-es/es-string-file.xml +11 -0
- data/spec/data/android/write.xml +1 -0
- data/spec/data/android/write_plurals.xml +14 -0
- data/spec/data/rails/locales/en.yml +4 -0
- data/spec/extractor/android_spec.rb +47 -26
- data/spec/extractor/base_spec.rb +25 -8
- data/spec/extractor/rails_spec.rb +23 -20
- data/spec/merger/android_spec.rb +78 -25
- data/spec/merger/base_spec.rb +0 -1
- data/spec/merger/rails_spec.rb +1 -2
- data/spec/spec_helper.rb +8 -5
- data/spec/support/matchers.rb +25 -0
- data/spec/translator/android_spec.rb +45 -2
- data/spec/translator/rails_spec.rb +28 -24
- data/spec/validator/android_spec.rb +2 -2
- data/spec/validator/base_spec.rb +23 -0
- data/spec/validator/rails_spec.rb +6 -6
- data/vocab.gemspec +1 -0
- metadata +23 -8
@@ -12,18 +12,20 @@ describe 'Vocab::Translator::Rails' do
|
|
12
12
|
it 'loads translations from a directory of yml files' do
|
13
13
|
|
14
14
|
actual = @translator.translations
|
15
|
-
expected = {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
15
|
+
expected = {:marketing=>{:banner=>"This product is so good"},
|
16
|
+
:dashboard=>{:chart=>"This value has changed",
|
17
|
+
:details=>"This key/value has been added"},
|
18
|
+
:menu=>{:first=>"First menu item",
|
19
|
+
:second=>"Second menu item"},
|
20
|
+
:not_in_es=>"This key not in spanish",
|
21
|
+
:users=>{:one=>"1 user",
|
22
|
+
:other=>"%{count} users"},
|
23
|
+
:models=>{:product=>{:id_125=>{:description=>"Green with megawatts",
|
24
|
+
:name=>"Lazer"},
|
25
|
+
:id_36=>{:description=>"Polarized and lazer resistant",
|
26
|
+
:name=>"This nested value has changed"},
|
27
|
+
:id_55=>{:description=>"A new nested description",
|
28
|
+
:name=>"a new nested name"}}}}
|
27
29
|
actual.should eql( expected )
|
28
30
|
end
|
29
31
|
|
@@ -95,18 +97,20 @@ describe 'Vocab::Translator::Rails' do
|
|
95
97
|
translator = Vocab::Translator::Rails.new
|
96
98
|
translator.load_dir( "#{vocab_root}/spec/data/rails/locales" )
|
97
99
|
actual = translator.flattened_translations
|
98
|
-
expected = {
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
100
|
+
expected = {:"marketing.banner"=>"This product is so good",
|
101
|
+
:"dashboard.chart"=>"This value has changed",
|
102
|
+
:"dashboard.details"=>"This key/value has been added",
|
103
|
+
:"menu.first"=>"First menu item",
|
104
|
+
:"menu.second"=>"Second menu item",
|
105
|
+
:not_in_es=>"This key not in spanish",
|
106
|
+
:"users.one"=>"1 user",
|
107
|
+
:"users.other"=>"%{count} users",
|
108
|
+
:"models.product.id_125.description"=>"Green with megawatts",
|
109
|
+
:"models.product.id_125.name"=>"Lazer",
|
110
|
+
:"models.product.id_36.description"=>"Polarized and lazer resistant",
|
111
|
+
:"models.product.id_36.name"=>"This nested value has changed",
|
112
|
+
:"models.product.id_55.description"=>"A new nested description",
|
113
|
+
:"models.product.id_55.name"=>"a new nested name"}
|
110
114
|
actual.should == expected
|
111
115
|
end
|
112
116
|
|
@@ -19,7 +19,7 @@ describe "Vocab::Validator::Android" do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'returns a hash containing the extra keys' do
|
22
|
-
@validator.should_receive( :
|
22
|
+
@validator.should_receive( :string_keys ).and_return( [ 'foo' ] )
|
23
23
|
@validator.should_receive( :other_keys ).and_return( [ 'foo', 'extra', 'stuff' ] )
|
24
24
|
result = @validator.validate_file( @path )
|
25
25
|
result[ :extra ].should eql( [ 'extra', 'stuff' ] )
|
@@ -40,7 +40,7 @@ describe "Vocab::Validator::Android" do
|
|
40
40
|
|
41
41
|
it 'validates android locales files' do
|
42
42
|
files = @validator.files_to_validate
|
43
|
-
files.each { |file| @validator.should_receive( :validate_file ).with( file ) }
|
43
|
+
files.each { |file| @validator.should_receive( :validate_file ).with( file ).and_return( {} ) }
|
44
44
|
@validator.should_receive( :print ).exactly( files.size ).times
|
45
45
|
@validator.validate
|
46
46
|
end
|
data/spec/validator/base_spec.rb
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "Vocab::Validator::Base" do
|
4
|
+
|
5
|
+
before( :each ) do
|
6
|
+
@files = [ 'foo', 'bar' ]
|
7
|
+
@good = { :missing => [], :extra => [] }
|
8
|
+
@bad = { :missing => [ 'bad' ], :extra => [] }
|
9
|
+
|
10
|
+
@validator = Vocab::Validator::Base.new
|
11
|
+
@validator.should_receive( :files_to_validate ).and_return( @files )
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "validate" do
|
15
|
+
|
16
|
+
it "returns true if no files have missing keys" do
|
17
|
+
@validator.should_receive( :validate_file ).exactly( @files.size ).times.and_return( @good )
|
18
|
+
@validator.validate.should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns false if any files have missing keys" do
|
22
|
+
@validator.should_receive( :validate_file ).exactly( @files.size ).times.and_return( @bad )
|
23
|
+
@validator.validate.should be_false
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
4
27
|
|
5
28
|
end
|
@@ -15,11 +15,11 @@ describe "Vocab::Validator::Rails" do
|
|
15
15
|
|
16
16
|
it 'returns a hash containing the missing keys' do
|
17
17
|
result = @validator.validate_file( @path )
|
18
|
-
result[ :missing ].should =~ [
|
18
|
+
result[ :missing ].should =~ ["menu.first", "menu.second", "not_in_es", "users.one", "users.other"]
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'returns a hash containing the extra keys' do
|
22
|
-
@validator.should_receive( :
|
22
|
+
@validator.should_receive( :string_keys ).and_return( [ 'foo' ] )
|
23
23
|
@validator.should_receive( :other_keys ).and_return( [ 'foo', 'extra', 'stuff' ] )
|
24
24
|
result = @validator.validate_file( @path )
|
25
25
|
result[ :extra ].should eql( [ 'extra', 'stuff' ] )
|
@@ -41,7 +41,7 @@ describe "Vocab::Validator::Rails" do
|
|
41
41
|
|
42
42
|
it 'validates android locales files' do
|
43
43
|
files = @validator.files_to_validate
|
44
|
-
files.each { |file| @validator.should_receive( :validate_file ).with( file ) }
|
44
|
+
files.each { |file| @validator.should_receive( :validate_file ).with( file ).and_return( {} ) }
|
45
45
|
@validator.should_receive( :print ).exactly( files.size ).times
|
46
46
|
@validator.validate
|
47
47
|
end
|
@@ -66,7 +66,7 @@ describe "Vocab::Validator::Rails" do
|
|
66
66
|
|
67
67
|
end
|
68
68
|
|
69
|
-
describe '
|
69
|
+
describe 'string_keys' do
|
70
70
|
|
71
71
|
before( :each ) do
|
72
72
|
@file = "#{@locales_dir}/es.yml"
|
@@ -74,8 +74,8 @@ describe "Vocab::Validator::Rails" do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'returns the flattened keys from english equivalent file' do
|
77
|
-
keys = ["dashboard.chart", "dashboard.details", "marketing.banner", "menu.first", "menu.second", "not_in_es"]
|
78
|
-
@validator.
|
77
|
+
keys = ["dashboard.chart", "dashboard.details", "marketing.banner", "menu.first", "menu.second", "not_in_es", "users.one", "users.other"]
|
78
|
+
@validator.string_keys( @file ).should =~ keys
|
79
79
|
end
|
80
80
|
|
81
81
|
end
|
data/vocab.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vocab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-16 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157421200 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157421200
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157420580 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157420580
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2157419820 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,18 @@ dependencies:
|
|
43
43
|
version: 2.7.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2157419820
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: simplecov
|
49
|
+
requirement: &2157418700 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2157418700
|
47
58
|
description: Export strings that need to be translated and integrate the completed
|
48
59
|
translations
|
49
60
|
email:
|
@@ -54,7 +65,9 @@ extensions: []
|
|
54
65
|
extra_rdoc_files: []
|
55
66
|
files:
|
56
67
|
- .gitignore
|
68
|
+
- CHANGELOG.md
|
57
69
|
- Gemfile
|
70
|
+
- MIT-LICENSE
|
58
71
|
- README.md
|
59
72
|
- Rakefile
|
60
73
|
- bin/vocab
|
@@ -88,6 +101,7 @@ files:
|
|
88
101
|
- spec/data/android/previous.xml
|
89
102
|
- spec/data/android/translations/values-es/es-string-file.xml
|
90
103
|
- spec/data/android/write.xml
|
104
|
+
- spec/data/android/write_plurals.xml
|
91
105
|
- spec/data/rails/locales/en.yml
|
92
106
|
- spec/data/rails/locales/es.yml
|
93
107
|
- spec/data/rails/locales/models/product/en.yml
|
@@ -146,6 +160,7 @@ test_files:
|
|
146
160
|
- spec/data/android/previous.xml
|
147
161
|
- spec/data/android/translations/values-es/es-string-file.xml
|
148
162
|
- spec/data/android/write.xml
|
163
|
+
- spec/data/android/write_plurals.xml
|
149
164
|
- spec/data/rails/locales/en.yml
|
150
165
|
- spec/data/rails/locales/es.yml
|
151
166
|
- spec/data/rails/locales/models/product/en.yml
|