rats 0.2.2 → 0.2.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/VERSION +1 -1
- data/lib/rats/base.rb +8 -8
- data/lib/rats/data/quarter.rb +2 -0
- data/rats.gemspec +2 -2
- data/spec/rats_spec.rb +25 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/lib/rats/base.rb
CHANGED
@@ -85,8 +85,8 @@ module Rats
|
|
85
85
|
def valid?
|
86
86
|
# check each data field individually
|
87
87
|
[:meridian, :range, :township, :section, :quarter].each do |data|
|
88
|
-
valid = self.send(data.to_s.
|
89
|
-
add_error(data, self.send(data.to_s.
|
88
|
+
valid = self.send(data.to_s.chars.first).valid?
|
89
|
+
add_error(data, self.send(data.to_s.chars.first).error) unless valid
|
90
90
|
end
|
91
91
|
|
92
92
|
# check each field as it relates to others
|
@@ -158,7 +158,7 @@ module Rats
|
|
158
158
|
end
|
159
159
|
|
160
160
|
def location_type?(location)
|
161
|
-
location.to_s.match(/^\d{8}\D{2}/) ? :parcel_id : :description
|
161
|
+
location.to_s.match(/^\d{8}\D{0,2}/) ? :parcel_id : :description
|
162
162
|
end
|
163
163
|
|
164
164
|
def parse_description(description)
|
@@ -176,9 +176,9 @@ module Rats
|
|
176
176
|
end
|
177
177
|
|
178
178
|
def parse_parcel_id(parcel_id)
|
179
|
-
result = parcel_id.to_s.scan(/^(\d{1})(\d{2})(\d{3})(\d{2})(\D{2})
|
179
|
+
result = parcel_id.to_s.scan(/^(\d{1})(\d{2})(\d{3})(\d{2})(\D{2})?/)
|
180
180
|
return unless result && result.size > 0
|
181
|
-
numbers = result.pop
|
181
|
+
numbers = result.pop.compact
|
182
182
|
self.meridian = numbers.shift.to_i if numbers.size > 0
|
183
183
|
self.range = numbers.shift.to_i if numbers.size > 0
|
184
184
|
self.township = numbers.shift.to_i if numbers.size > 0
|
@@ -210,10 +210,10 @@ module Rats
|
|
210
210
|
|
211
211
|
def long_location
|
212
212
|
quarter_section = []
|
213
|
-
quarter_section << self.q.fullname if self.q && self.q.fullname.size > 0
|
214
|
-
quarter_section << self.s.fullname if self.s && self.s.fullname.size > 0
|
213
|
+
quarter_section << self.q.fullname if (self.q && self.q.fullname.size > 0)
|
214
|
+
quarter_section << self.s.fullname if (self.s && self.s.fullname.size > 0)
|
215
215
|
parts = []
|
216
|
-
parts << quarter_section.compact.join(' of ') if quarter_section && quarter_section.size > 0
|
216
|
+
parts << quarter_section.compact.join(' of ') if (quarter_section && quarter_section.size > 0)
|
217
217
|
parts << self.t.fullname
|
218
218
|
parts << self.r.fullname
|
219
219
|
parts << self.m.fullname
|
data/lib/rats/data/quarter.rb
CHANGED
@@ -11,6 +11,7 @@ module Rats
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def fullname
|
14
|
+
return "" unless self.value
|
14
15
|
template = "the %s Quarter"
|
15
16
|
case self.value.to_s.downcase.to_sym
|
16
17
|
when :ne
|
@@ -29,6 +30,7 @@ module Rats
|
|
29
30
|
private
|
30
31
|
|
31
32
|
def validate!
|
33
|
+
return unless self.value
|
32
34
|
VALID_QUARTERS.include?(self.value.to_s.downcase.to_sym)
|
33
35
|
end
|
34
36
|
|
data/rats.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rats}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mark G"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-08}
|
13
13
|
s.description = %q{A ruby class to help with using the Alberta Township System}
|
14
14
|
s.email = %q{rats@attackcorp.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/rats_spec.rb
CHANGED
@@ -53,6 +53,7 @@ describe "Rats" do
|
|
53
53
|
land.township.should == 2
|
54
54
|
land.range.should == 3
|
55
55
|
land.meridian.should == 4
|
56
|
+
land.scope.should == :quarter
|
56
57
|
end
|
57
58
|
|
58
59
|
it "understands NE-1-2-3-W4" do
|
@@ -62,6 +63,7 @@ describe "Rats" do
|
|
62
63
|
land.township.should == 2
|
63
64
|
land.range.should == 3
|
64
65
|
land.meridian.should == 4
|
66
|
+
land.scope.should == :quarter
|
65
67
|
end
|
66
68
|
|
67
69
|
it "understands NE-1-2-3-4" do
|
@@ -71,6 +73,7 @@ describe "Rats" do
|
|
71
73
|
land.township.should == 2
|
72
74
|
land.range.should == 3
|
73
75
|
land.meridian.should == 4
|
76
|
+
land.scope.should == :quarter
|
74
77
|
end
|
75
78
|
|
76
79
|
it "understands NE 1-1-1-4" do
|
@@ -80,6 +83,7 @@ describe "Rats" do
|
|
80
83
|
land.township.should == 2
|
81
84
|
land.range.should == 3
|
82
85
|
land.meridian.should == 4
|
86
|
+
land.scope.should == :quarter
|
83
87
|
end
|
84
88
|
|
85
89
|
it "understands NE 1 2 3 4" do
|
@@ -89,6 +93,7 @@ describe "Rats" do
|
|
89
93
|
land.township.should == 2
|
90
94
|
land.range.should == 3
|
91
95
|
land.meridian.should == 4
|
96
|
+
land.scope.should == :quarter
|
92
97
|
end
|
93
98
|
|
94
99
|
it "understands 40300201NE" do
|
@@ -98,6 +103,17 @@ describe "Rats" do
|
|
98
103
|
land.township.should == 2
|
99
104
|
land.range.should == 3
|
100
105
|
land.meridian.should == 4
|
106
|
+
land.scope.should == :quarter
|
107
|
+
end
|
108
|
+
|
109
|
+
it "understands 40300201" do
|
110
|
+
land = Rats.new("40300201")
|
111
|
+
land.quarter.should be_nil
|
112
|
+
land.section.should == 1
|
113
|
+
land.township.should == 2
|
114
|
+
land.range.should == 3
|
115
|
+
land.meridian.should == 4
|
116
|
+
land.scope.should == :section
|
101
117
|
end
|
102
118
|
|
103
119
|
it "understands 1-2-3 W4" do
|
@@ -107,6 +123,7 @@ describe "Rats" do
|
|
107
123
|
land.township.should == 2
|
108
124
|
land.range.should == 3
|
109
125
|
land.meridian.should == 4
|
126
|
+
land.scope.should == :section
|
110
127
|
end
|
111
128
|
|
112
129
|
it "understands 2-3 W4" do
|
@@ -116,6 +133,7 @@ describe "Rats" do
|
|
116
133
|
land.township.should == 2
|
117
134
|
land.range.should == 3
|
118
135
|
land.meridian.should == 4
|
136
|
+
land.scope.should == :township
|
119
137
|
end
|
120
138
|
|
121
139
|
it "understands 3 W4" do
|
@@ -125,6 +143,7 @@ describe "Rats" do
|
|
125
143
|
land.township.should be_nil
|
126
144
|
land.range.should == 3
|
127
145
|
land.meridian.should == 4
|
146
|
+
land.scope.should == :unknown
|
128
147
|
end
|
129
148
|
|
130
149
|
it "understands W4" do
|
@@ -134,6 +153,7 @@ describe "Rats" do
|
|
134
153
|
land.township.should be_nil
|
135
154
|
land.range.should be_nil
|
136
155
|
land.meridian.should == 4
|
156
|
+
land.scope.should == :unknown
|
137
157
|
end
|
138
158
|
|
139
159
|
it "understands individual values" do
|
@@ -143,6 +163,7 @@ describe "Rats" do
|
|
143
163
|
land.township.should == 2
|
144
164
|
land.range.should == 3
|
145
165
|
land.meridian.should == 4
|
166
|
+
land.scope.should == :quarter
|
146
167
|
end
|
147
168
|
|
148
169
|
it "understands SE 1-119-24 W4" do
|
@@ -152,6 +173,7 @@ describe "Rats" do
|
|
152
173
|
land.township.should == 119
|
153
174
|
land.range.should == 24
|
154
175
|
land.meridian.should == 4
|
176
|
+
land.scope.should == :quarter
|
155
177
|
end
|
156
178
|
|
157
179
|
describe "alternate method" do
|
@@ -309,11 +331,13 @@ describe "Rats" do
|
|
309
331
|
|
310
332
|
it "returns the long version with Section" do
|
311
333
|
land = Rats.new("1-2-3 W4")
|
334
|
+
#puts land.inspect
|
312
335
|
land.location(:long).should == "Section 1, Township 2, Range 3, West of the Fourth Meridian"
|
313
336
|
end
|
314
337
|
|
315
338
|
it "returns the long version with Township" do
|
316
339
|
land = Rats.new("2-3 W4")
|
340
|
+
#puts land.inspect
|
317
341
|
land.location(:long).should == "Township 2, Range 3, West of the Fourth Meridian"
|
318
342
|
end
|
319
343
|
|
@@ -356,6 +380,7 @@ describe "Rats" do
|
|
356
380
|
|
357
381
|
it "knows when it isn't valid"do
|
358
382
|
land = Rats.new("3 W4")
|
383
|
+
#puts land.inspect
|
359
384
|
land.valid?.should be_false
|
360
385
|
end
|
361
386
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 3
|
9
|
+
version: 0.2.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Mark G
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-08 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|