Indirizzo 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Indirizzo.gemspec +2 -2
- data/Rakefile +3 -3
- data/lib/indirizzo/constants.rb +0 -15
- data/test/test_address.rb +6 -1
- data/test/test_helper.rb +1 -3
- metadata +8 -8
data/Indirizzo.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{Indirizzo}
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.5"
|
4
4
|
|
5
5
|
s.authors = [%q{Dave Worth}]
|
6
|
-
s.date = %q{
|
6
|
+
s.date = %q{2012-01-11}
|
7
7
|
s.description = %q{Indirizzo is simply an extraction of the US Street Address parsing code from Geocoder::US}
|
8
8
|
s.email = %q{dave@highgroove.com}
|
9
9
|
|
data/Rakefile
CHANGED
data/lib/indirizzo/constants.rb
CHANGED
@@ -10,31 +10,16 @@ module Indirizzo
|
|
10
10
|
attr_accessor :regexp
|
11
11
|
def self.[] (*items)
|
12
12
|
hash = super(*items)
|
13
|
-
#hash.build_partial
|
14
13
|
hash.build_match
|
15
14
|
hash.keys.each {|k| hash[k.downcase] = hash.fetch(k)}
|
16
15
|
hash.values.each {|v| hash[v.downcase] = v}
|
17
16
|
hash.freeze
|
18
17
|
end
|
19
|
-
# The build_partial method constructs a hash of case-insensitive,
|
20
|
-
# whitespace-delimited prefixes to keys and values in the two-way Map.
|
21
|
-
def build_partial
|
22
|
-
@partial = Set.new()
|
23
|
-
[keys, values].flatten.each do |item|
|
24
|
-
@partial << item.downcase
|
25
|
-
item.downcase.split.each {|token| @partial << token}
|
26
|
-
end
|
27
|
-
end
|
28
18
|
def build_match
|
29
19
|
@regexp = Regexp.new(
|
30
20
|
'\b(' + [keys,values].flatten.join("|") + ')\b',
|
31
21
|
Regexp::IGNORECASE)
|
32
22
|
end
|
33
|
-
# The partial? method returns true if the key is a prefix of some
|
34
|
-
# key in the Map.
|
35
|
-
def partial? (key)
|
36
|
-
@partial.member? key.downcase
|
37
|
-
end
|
38
23
|
def key? (key)
|
39
24
|
super(key.downcase)
|
40
25
|
end
|
data/test/test_address.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'set'
|
3
2
|
require 'indirizzo/address'
|
4
3
|
|
5
4
|
include Indirizzo
|
6
5
|
|
7
6
|
class TestAddress < Test::Unit::TestCase
|
8
7
|
|
8
|
+
def test_new_raises_exception_with_no_text
|
9
|
+
assert_raise do
|
10
|
+
Address.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
9
14
|
def test_new
|
10
15
|
addr = Address.new("1600 Pennsylvania Av., Washington DC")
|
11
16
|
assert_equal "1600 Pennsylvania Av, Washington DC", addr.text
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Indirizzo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
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:
|
12
|
+
date: 2012-01-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70348554395680 !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: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70348554395680
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: cover_me
|
27
|
-
requirement: &
|
27
|
+
requirement: &70348554395240 !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: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70348554395240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: awesome_print
|
38
|
-
requirement: &
|
38
|
+
requirement: &70348554394820 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70348554394820
|
47
47
|
description: Indirizzo is simply an extraction of the US Street Address parsing code
|
48
48
|
from Geocoder::US
|
49
49
|
email: dave@highgroove.com
|