rwanda 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7935155fa37e92a3cc84b95cfaf5f93459fae59
4
- data.tar.gz: 2d48de8bcdc1cdb1cd01c2ef39c5a15cf8d80e47
3
+ metadata.gz: de04553007e96f17ba5c64c47121ec6f1ba9f70d
4
+ data.tar.gz: 10bff714e5cd301c7321add3af0f28e34097f713
5
5
  SHA512:
6
- metadata.gz: 5eb13f9ecb7c632554936fe85200e82fd9148e19c5b6515dc88a5d99bbb4979b50321a5ae27034d4b51dac3c22262b2a5315c911411e602df46ef703c0ffc327
7
- data.tar.gz: 102598987dfa3b05c9b2c24374e23e75a9bc4a336c0aba9665b2f497c76bd5bb6158f006717e35a38d27fb3f6626f3104878d299a9c6dc88ac434c160f5ce161
6
+ metadata.gz: e6eb6509e493a026f1b98b978ea599eafd2440d2b7b1d76b861f244468a7e33e55d13643ddce21d3a7b04af86771c40547ee2589e69d52d248e432e3b9bc3db8
7
+ data.tar.gz: 97fee3c176396e3ec7fcf3a3f7de1b85012c3ad634cac34ce7354d18ffc18bb8d50a36e381d6cfa65513e1bb4d401f855954d391b7e7a3d56f1ecb5a0a661a09
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0
4
+
5
+ * Add .valid? because the Rails interface needs to accept an empty location as being "like" an .exist?ing one
6
+
3
7
  ## 0.6.0
4
8
 
5
9
  * Addition of Location class (moved out of rails app)
data/README.md CHANGED
@@ -24,6 +24,10 @@ Then you can try it on the command line:
24
24
  > gem 'rwanda'
25
25
  > require 'rwanda'
26
26
 
27
+ ## Status
28
+
29
+ [![Gem Version](https://badge.fury.io/rb/rwanda.svg)](http://badge.fury.io/rb/rwanda)
30
+
27
31
  ## Usage
28
32
 
29
33
  ```ruby
@@ -1,3 +1,3 @@
1
1
  class Rwanda
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/rwanda.rb CHANGED
@@ -113,7 +113,7 @@ class Rwanda
113
113
  end
114
114
  def exist?(district=false, sector=false, cell=false, village=false)
115
115
  villages = @villages.dup
116
- return nil unless district
116
+ return false unless district
117
117
  {district: district, sector: sector, cell: cell, village: village}.each_pair do |division_name,division|
118
118
  #binding.pry
119
119
  return true unless division
@@ -123,6 +123,11 @@ class Rwanda
123
123
  true
124
124
  end
125
125
  def exists?(*p); exist?(*p); end
126
+ def valid?(*p)
127
+ # Is this location either (a) real, or (b) nil (both of which are valid if an object's address can be null)
128
+ return true if p.reject{|i| i.nil?}.empty? # all nils is fine
129
+ exist? *p
130
+ end
126
131
 
127
132
  # )) Translation ((
128
133
  def translate(province)
data/rwanda.gemspec CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.required_ruby_version = '>= 1.9.3'
22
+
21
23
  spec.add_development_dependency "bundler", "~> 1.7"
22
24
  spec.add_development_dependency "rake", "~> 10.0"
23
25
  spec.add_development_dependency "rspec"
data/spec/rwanda_spec.rb CHANGED
@@ -138,6 +138,7 @@ describe Rwanda do
138
138
 
139
139
  expect(r.exist?('karongi','bwishyura','kiniha','nyarurembo')).to eq true
140
140
  expect(r.exist?('karongi','bwishyura','nyarurembo')).to eq false
141
+ expect(r.exist?(nil,nil,'',nil)).to eq false
141
142
  expect(r.exist?('karongi')).to eq true
142
143
 
143
144
  # .exists? is an acceptable synonym
@@ -146,6 +147,16 @@ describe Rwanda do
146
147
  end
147
148
  end
148
149
 
150
+ describe '.valid?' do
151
+ it 'knows whether a chain of divisions is valid, which an empty set is' do
152
+ expect(r.valid?('Karongi','Bwishyura','Kiniha','Nyarurembo')).to eq true
153
+ expect(r.valid?(nil,nil,nil)).to eq true
154
+
155
+ expect(r.valid?('Karongi','Bwishyura','Nyarurembo')).to eq false
156
+ expect(r.valid?(nil,nil,'',nil)).to eq false
157
+ end
158
+ end
159
+
149
160
  describe '.translate' do
150
161
  it 'can translate a province from English to Kinyarwanda' do
151
162
  expect(r.translate('Northern Province')).to eq 'Amajyaruguru'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rwanda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Hetherington
@@ -117,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: '0'
120
+ version: 1.9.3
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - ">="