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.
@@ -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 = { :marketing=>{ :banner=>"This product is so good" },
16
- :models =>{ :product=>{ :id_125=>{ :description=>"Green with megawatts",
17
- :name =>"Lazer" },
18
- :id_55 =>{ :description=>"A new nested description",
19
- :name =>"a new nested name" },
20
- :id_36 =>{ :description=>"Polarized and lazer resistant",
21
- :name =>"This nested value has changed" } } },
22
- :menu =>{ :second=>"Second menu item",
23
- :first=>"First menu item" },
24
- :dashboard=>{ :chart =>"This value has changed",
25
- :details=>"This key/value has been added" },
26
- :not_in_es=>"This key not in spanish" }
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 = { :"dashboard.details" =>"This key/value has been added",
99
- :"models.product.id_125.name" =>"Lazer",
100
- :"models.product.id_55.name" =>"a new nested name",
101
- :"models.product.id_36.name" =>"This nested value has changed",
102
- :"menu.second" =>"Second menu item",
103
- :"dashboard.chart" =>"This value has changed",
104
- :"menu.first" =>"First menu item",
105
- :"marketing.banner" =>"This product is so good",
106
- :"models.product.id_125.description"=>"Green with megawatts",
107
- :"models.product.id_55.description" =>"A new nested description",
108
- :"models.product.id_36.description" =>"Polarized and lazer resistant",
109
- :"not_in_es" =>"This key not in spanish" }
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( :english_keys ).and_return( [ 'foo' ] )
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
@@ -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 =~ [ "menu.first", "menu.second", "not_in_es" ]
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( :english_keys ).and_return( [ 'foo' ] )
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 'english_keys' do
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.english_keys( @file ).should =~ keys
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
@@ -21,5 +21,6 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency "i18n"
22
22
  s.add_dependency "nokogiri"
23
23
  s.add_development_dependency "rspec", "~> 2.7.0"
24
+ s.add_development_dependency "simplecov"
24
25
  # s.add_runtime_dependency "rest-client"
25
26
  end
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.2
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-02-09 00:00:00.000000000Z
12
+ date: 2012-04-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
16
- requirement: &2152232980 !ruby/object:Gem::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: *2152232980
24
+ version_requirements: *2157421200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &2152232140 !ruby/object:Gem::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: *2152232140
35
+ version_requirements: *2157420580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2152230840 !ruby/object:Gem::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: *2152230840
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