madison 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -0
- data/Gemfile +5 -7
- data/Gemfile.lock +40 -29
- data/README.md +3 -7
- data/Rakefile +4 -42
- data/lib/madison.rb +10 -28
- data/lib/madison/map.rb +44 -0
- data/lib/{states.json → madison/states.json} +0 -0
- data/lib/madison/version.rb +3 -0
- data/madison.gemspec +11 -54
- data/spec/lib/madison/map_spec.rb +85 -0
- data/spec/lib/madison_spec.rb +67 -48
- metadata +31 -70
- data/VERSION +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fc16088ec67c078a87f2b689483b09fcafa994f3
|
4
|
+
data.tar.gz: 298321db111e9788971b8414587ca308be36e01a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eb0e66b81cc9e74a32d22562e662b20ba6fa67e76a715d8d0b28885d1eef03270030a15168e0e119f633b5fe4f8f84f662affc2dfb2c4ecfc85c08a455944473
|
7
|
+
data.tar.gz: fbf06dd63453d7e0d826b954239349880d88169f2867c78fa39fe9ed19fd5cb03b0bf8e85656966137cdc5bd6e8f1918c158d8bfc757d6f6a7a4f5040bdd30b1
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
madison
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
source
|
2
|
-
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
3
4
|
|
4
5
|
group :development do
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem "bundler", "~> 1.0.0"
|
8
|
-
gem "jeweler", "~> 1.8.4"
|
9
|
-
gem "simplecov"
|
6
|
+
gem 'pry'
|
7
|
+
gem 'rake'
|
10
8
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,38 +1,49 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
madison (0.3.1)
|
5
|
+
json
|
6
|
+
|
1
7
|
GEM
|
2
|
-
remote:
|
8
|
+
remote: https://rubygems.org/
|
3
9
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rspec-
|
18
|
-
rspec-
|
19
|
-
|
20
|
-
|
21
|
-
rspec-expectations (
|
22
|
-
diff-lcs (
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
simplecov
|
10
|
+
coderay (1.1.0)
|
11
|
+
diff-lcs (1.2.5)
|
12
|
+
docile (1.1.5)
|
13
|
+
json (1.8.1)
|
14
|
+
method_source (0.8.2)
|
15
|
+
multi_json (1.10.1)
|
16
|
+
pry (0.10.1)
|
17
|
+
coderay (~> 1.1.0)
|
18
|
+
method_source (~> 0.8.1)
|
19
|
+
slop (~> 3.4)
|
20
|
+
rake (10.3.2)
|
21
|
+
rspec (3.0.0)
|
22
|
+
rspec-core (~> 3.0.0)
|
23
|
+
rspec-expectations (~> 3.0.0)
|
24
|
+
rspec-mocks (~> 3.0.0)
|
25
|
+
rspec-core (3.0.4)
|
26
|
+
rspec-support (~> 3.0.0)
|
27
|
+
rspec-expectations (3.0.4)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.0.0)
|
30
|
+
rspec-mocks (3.0.4)
|
31
|
+
rspec-support (~> 3.0.0)
|
32
|
+
rspec-support (3.0.4)
|
33
|
+
simplecov (0.9.0)
|
34
|
+
docile (~> 1.1.0)
|
35
|
+
multi_json
|
36
|
+
simplecov-html (~> 0.8.0)
|
37
|
+
simplecov-html (0.8.0)
|
38
|
+
slop (3.6.0)
|
28
39
|
|
29
40
|
PLATFORMS
|
30
41
|
ruby
|
31
42
|
|
32
43
|
DEPENDENCIES
|
33
|
-
bundler
|
34
|
-
|
35
|
-
|
36
|
-
|
44
|
+
bundler
|
45
|
+
madison!
|
46
|
+
pry
|
47
|
+
rake
|
37
48
|
rspec
|
38
49
|
simplecov
|
data/README.md
CHANGED
@@ -37,18 +37,14 @@ Require madison:
|
|
37
37
|
|
38
38
|
require 'madison'
|
39
39
|
|
40
|
-
Initialize madison:
|
41
|
-
|
42
|
-
m = Madison.new
|
43
|
-
|
44
40
|
Get a state's abbreviation:
|
45
41
|
|
46
|
-
|
42
|
+
Madison.get_abbrev 'virginia' // 'VA'
|
47
43
|
|
48
44
|
Get a state's name asynchronously:
|
49
45
|
|
50
|
-
|
46
|
+
Madison.get_name 'va' // 'Virginia'
|
51
47
|
|
52
48
|
Get a Ruby hash of US states, each containing 'name' and 'abbr' properties:
|
53
49
|
|
54
|
-
|
50
|
+
Madison.states
|
data/Rakefile
CHANGED
@@ -1,45 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec/core/rake_task'
|
2
4
|
|
3
|
-
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
13
6
|
|
14
|
-
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "madison"
|
18
|
-
gem.homepage = "http://github.com/mdb/madison.rb"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{A simple Ruby gem for working with U.S. state names and abbreviations.}
|
21
|
-
gem.description = %Q{Get a U.S. state name from its abbreviation or get a U.S. state abbreviation from its name.}
|
22
|
-
gem.email = "mikedball@gmail.com"
|
23
|
-
gem.authors = ["Mike Ball"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
|
-
require 'rake/testtask'
|
29
|
-
Rake::TestTask.new(:test) do |test|
|
30
|
-
test.libs << 'lib' << 'spec'
|
31
|
-
test.pattern = 'spec/**/*_spec.rb'
|
32
|
-
test.verbose = true
|
33
|
-
end
|
34
|
-
|
35
|
-
task :default => :test
|
36
|
-
|
37
|
-
require 'rdoc/task'
|
38
|
-
Rake::RDocTask.new do |rdoc|
|
39
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
-
|
41
|
-
rdoc.rdoc_dir = 'rdoc'
|
42
|
-
rdoc.title = "madison #{version}"
|
43
|
-
rdoc.rdoc_files.include('README*')
|
44
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
-
end
|
7
|
+
task :default => :spec
|
data/lib/madison.rb
CHANGED
@@ -1,36 +1,18 @@
|
|
1
|
-
require '
|
1
|
+
require 'madison/version'
|
2
|
+
require 'madison/map'
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
module Madison
|
5
|
+
@map = Madison::Map.new
|
5
6
|
|
6
|
-
def states
|
7
|
-
|
8
|
-
@states ||= JSON.parse( File.open(File.join(madison_dir, "lib", "states.json")).read )
|
7
|
+
def self.states
|
8
|
+
@map.states
|
9
9
|
end
|
10
10
|
|
11
|
-
def get_abbrev(name)
|
12
|
-
|
13
|
-
state_abbrevs[name.downcase]
|
11
|
+
def self.get_abbrev(name)
|
12
|
+
@map.get_abbrev(name)
|
14
13
|
end
|
15
14
|
|
16
|
-
def get_name(abbrev)
|
17
|
-
|
18
|
-
state_names[abbrev.downcase]
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
def state_names
|
23
|
-
@state_names ||= build_map('abbr', 'name')
|
24
|
-
end
|
25
|
-
|
26
|
-
def state_abbrevs
|
27
|
-
@state_abbrevs ||= build_map('name', 'abbr')
|
28
|
-
end
|
29
|
-
|
30
|
-
def build_map(in_key, out_key)
|
31
|
-
states.inject({}) do |map, state|
|
32
|
-
map[state[in_key].downcase] = state[out_key]
|
33
|
-
map
|
34
|
-
end
|
15
|
+
def self.get_name(abbrev)
|
16
|
+
@map.get_name(abbrev)
|
35
17
|
end
|
36
18
|
end
|
data/lib/madison/map.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Madison
|
4
|
+
class Map
|
5
|
+
attr_accessor :states
|
6
|
+
|
7
|
+
def states
|
8
|
+
lib_dir = File.expand_path(File.dirname(File.dirname(__FILE__)))
|
9
|
+
|
10
|
+
@states ||= JSON.parse( File.open(File.join(lib_dir, "madison", "states.json")).read)
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_abbrev(name)
|
14
|
+
validate_arg(name)
|
15
|
+
state_abbrevs[name.downcase]
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_name(abbrev)
|
19
|
+
validate_arg(abbrev)
|
20
|
+
state_names[abbrev.downcase]
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def state_names
|
26
|
+
@state_names ||= build_map('abbr', 'name')
|
27
|
+
end
|
28
|
+
|
29
|
+
def state_abbrevs
|
30
|
+
@state_abbrevs ||= build_map('name', 'abbr')
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_map(in_key, out_key)
|
34
|
+
states.inject({}) do |map, state|
|
35
|
+
map[state[in_key].downcase] = state[out_key]
|
36
|
+
map
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def validate_arg(arg)
|
41
|
+
raise ArgumentError, "Argument '#{arg}' must be a string" unless arg.is_a? String
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
File without changes
|
data/madison.gemspec
CHANGED
@@ -1,66 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'madison/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
6
|
s.name = "madison"
|
8
|
-
s.version =
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
7
|
+
s.version = Madison::VERSION
|
11
8
|
s.authors = ["Mike Ball"]
|
12
|
-
s.date = "2012-10-21"
|
13
9
|
s.description = "Get a U.S. state name from its abbreviation or get a U.S. state abbreviation from its name."
|
10
|
+
s.summary = "A simple Ruby gem for working with U.S. state names and abbreviations."
|
14
11
|
s.email = "mikedball@gmail.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".travis.yml",
|
21
|
-
"Gemfile",
|
22
|
-
"Gemfile.lock",
|
23
|
-
"LICENSE",
|
24
|
-
"README.md",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"lib/madison.rb",
|
28
|
-
"lib/states.json",
|
29
|
-
"madison.gemspec",
|
30
|
-
"spec/lib/madison_spec.rb",
|
31
|
-
"spec/spec_helper.rb"
|
32
|
-
]
|
33
12
|
s.homepage = "http://github.com/mdb/madison.rb"
|
34
13
|
s.licenses = ["MIT"]
|
14
|
+
s.files = `git ls-files`.split($/)
|
15
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
35
16
|
s.require_paths = ["lib"]
|
36
|
-
s.rubygems_version = "1.8.24"
|
37
|
-
s.summary = "A simple Ruby gem for working with U.S. state names and abbreviations."
|
38
17
|
|
39
|
-
|
40
|
-
s.specification_version = 3
|
18
|
+
s.add_dependency "json"
|
41
19
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
46
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
47
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
48
|
-
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
49
|
-
else
|
50
|
-
s.add_dependency(%q<json>, [">= 0"])
|
51
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
52
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
53
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
54
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
55
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
56
|
-
end
|
57
|
-
else
|
58
|
-
s.add_dependency(%q<json>, [">= 0"])
|
59
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
60
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
61
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
62
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
63
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
64
|
-
end
|
20
|
+
s.add_development_dependency "bundler"
|
21
|
+
s.add_development_dependency "rspec"
|
22
|
+
s.add_development_dependency "simplecov"
|
65
23
|
end
|
66
|
-
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Madison::Map do
|
4
|
+
let (:map) { Madison::Map.new }
|
5
|
+
|
6
|
+
it "exists as a class within the Madison module" do
|
7
|
+
expect(Madison::Map.class).to eq Class
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#states" do
|
11
|
+
it "returns a an array of state names and abbreviations" do
|
12
|
+
expect(map.states.length).to eq 51
|
13
|
+
end
|
14
|
+
|
15
|
+
context "an item within the #states array" do
|
16
|
+
it "contains a 'name' key the value of which is the state name" do
|
17
|
+
expect(map.states[0]['name']).to eq "Alabama"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "contains an 'abbr' key, the value of which is the state abbreviation" do
|
21
|
+
expect(map.states[50]['abbr']).to eq "WY"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#get_abbrev" do
|
27
|
+
it "returns a state's abbreviation when it's passed a state's name" do
|
28
|
+
expect(map.get_abbrev("virginia")).to eq "VA"
|
29
|
+
expect(map.get_abbrev("west virginia")).to eq "WV"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns a state's abbreviation when it's passed a state's name, indpendent of the argument's case" do
|
33
|
+
expect(map.get_abbrev("virginiA")).to eq "VA"
|
34
|
+
expect(map.get_abbrev("AlaBama")).to eq "AL"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns nil in the event that is not passed a valid state name" do
|
38
|
+
expect(map.get_abbrev("Fake State")).to be_nil
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when it is not passed a string" do
|
42
|
+
it "raises an ArgumentError if it is passed an integer" do
|
43
|
+
expect { map.get_abbrev(3) }.to raise_error
|
44
|
+
end
|
45
|
+
|
46
|
+
it "raises an ArgumentError if it is passed a nil" do
|
47
|
+
expect { map.get_abbrev(nil) }.to raise_error
|
48
|
+
end
|
49
|
+
|
50
|
+
it "raises an ArgumentError if it is passed a hash" do
|
51
|
+
expect { map.get_abbrev({}) }.to raise_error
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#get_name" do
|
57
|
+
it "returns a state's abbreviation when it's passed a state's name" do
|
58
|
+
expect(map.get_name("va")).to eq "Virginia"
|
59
|
+
expect(map.get_name("WV")).to eq "West Virginia"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns a state's abbreviation when it's passed a state's name, indpendent of the argument's case" do
|
63
|
+
expect(map.get_name("vA")).to eq "Virginia"
|
64
|
+
expect(map.get_name("Al")).to eq "Alabama"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "returns nil in the event that is not passed a valid state name" do
|
68
|
+
expect(map.get_name("FS")).to eq nil
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when it's not passed a string" do
|
72
|
+
it "raises an ArgumentError if it is passed an integer" do
|
73
|
+
expect { map.get_name(3) }.to raise_error
|
74
|
+
end
|
75
|
+
|
76
|
+
it "raises an ArgumentError if it is passed nil" do
|
77
|
+
expect { map.get_name(nil) }.to raise_error
|
78
|
+
end
|
79
|
+
|
80
|
+
it "raises an ArgumentError if it is passed a hash" do
|
81
|
+
expect { map.get_name({}) }.to raise_error
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/spec/lib/madison_spec.rb
CHANGED
@@ -1,64 +1,83 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Madison do
|
4
|
-
|
5
|
-
|
6
|
-
m = Madison.new
|
7
|
-
m.states[0]['name'].should === "Alabama"
|
8
|
-
m.states[50]['abbr'].should === "WY"
|
9
|
-
m.states.length.should === 51
|
10
|
-
end
|
4
|
+
it 'exists as a module' do
|
5
|
+
expect(Madison.class).to eq Module
|
11
6
|
end
|
12
|
-
|
13
|
-
describe "#get_abbrev" do
|
14
|
-
before(:each) do
|
15
|
-
@m = Madison.new
|
16
|
-
end
|
17
7
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
it "returns a state's abbreviation when it's passed a state's name, indpendent of the argument's case" do
|
24
|
-
@m.get_abbrev("virginiA").should === "VA"
|
25
|
-
@m.get_abbrev("AlaBama").should === "AL"
|
8
|
+
describe '#states' do
|
9
|
+
it 'returns an array of hashes representing each US state' do
|
10
|
+
expect(Madison.states.length).to eq 51
|
26
11
|
end
|
27
12
|
|
28
|
-
|
29
|
-
|
30
|
-
|
13
|
+
context 'each hash in the array' do
|
14
|
+
it 'contains a "name" key, the value of which is a state name' do
|
15
|
+
expect(Madison.states[0]['name']).to eq "Alabama"
|
16
|
+
end
|
31
17
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
lambda { @m.get_abbrev({}) }.should raise_error
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "#get_name" do
|
40
|
-
before(:each) do
|
41
|
-
@m = Madison.new
|
18
|
+
it 'contains an "abbr" key, the value of which is a state abbreviation' do
|
19
|
+
expect(Madison.states[50]['abbr']).to eq "WY"
|
20
|
+
end
|
42
21
|
end
|
43
22
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
23
|
+
describe '#get_abbrev' do
|
24
|
+
it "returns a state's abbreviation when it's passed a state's name" do
|
25
|
+
expect(Madison.get_abbrev("virginia")).to eq "VA"
|
26
|
+
expect(Madison.get_abbrev("west virginia")).to eq "WV"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns a state's abbreviation when it's passed a state's name, indpendent of the argument's case" do
|
30
|
+
expect(Madison.get_abbrev("virginiA")).to eq "VA"
|
31
|
+
expect(Madison.get_abbrev("AlaBama")).to eq "AL"
|
32
|
+
end
|
53
33
|
|
54
|
-
|
55
|
-
|
34
|
+
it 'returns nil in the event that is not passed a valid state name' do
|
35
|
+
expect(Madison.get_abbrev('Fake State')).to eq nil
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when it is not passed a string' do
|
39
|
+
it 'raises an argument error when it is passed an integer' do
|
40
|
+
expect { Madison.get_abbrev(3) }.to raise_error
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'raises an argument error when it is passed nil' do
|
44
|
+
expect { Madison.get_abbrev(nil) }.to raise_error
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'raises an ArgumentError if it is passed a hash' do
|
48
|
+
expect { Madison.get_abbrev({}) }.to raise_error
|
49
|
+
end
|
50
|
+
end
|
56
51
|
end
|
57
52
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
describe "#get_name" do
|
54
|
+
it "returns a state's abbreviation when it's passed a state's name" do
|
55
|
+
expect(Madison.get_name("va")).to eq "Virginia"
|
56
|
+
expect(Madison.get_name("WV")).to eq "West Virginia"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns a state's abbreviation when it's passed a state's name, indpendent of the argument's case" do
|
60
|
+
expect(Madison.get_name("vA")).to eq "Virginia"
|
61
|
+
expect(Madison.get_name("Al")).to eq "Alabama"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns nil in the event that is not passed a valid state name" do
|
65
|
+
expect(Madison.get_name("FS")).to eq nil
|
66
|
+
end
|
67
|
+
|
68
|
+
context "when it is not passed a string" do
|
69
|
+
it "raises an ArgumentError if it is passed an integer" do
|
70
|
+
expect { Madison.get_name(3) }.to raise_error
|
71
|
+
end
|
72
|
+
|
73
|
+
it "raises an ArgumentError if it is passed nil" do
|
74
|
+
expect { Madison.get_name(nil) }.to raise_error
|
75
|
+
end
|
76
|
+
|
77
|
+
it "raises an ArgumentError if it is passed a hash" do
|
78
|
+
expect { Madison.get_name({}) }.to raise_error
|
79
|
+
end
|
80
|
+
end
|
62
81
|
end
|
63
82
|
end
|
64
83
|
end
|
metadata
CHANGED
@@ -1,110 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: madison
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Mike Ball
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-08-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: json
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
28
|
+
name: bundler
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '3.12'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.12'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: bundler
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 1.0.0
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 1.0.0
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: jeweler
|
42
|
+
name: rspec
|
80
43
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
44
|
requirements:
|
83
|
-
- -
|
45
|
+
- - '>='
|
84
46
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
47
|
+
version: '0'
|
86
48
|
type: :development
|
87
49
|
prerelease: false
|
88
50
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
51
|
requirements:
|
91
|
-
- -
|
52
|
+
- - '>='
|
92
53
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
54
|
+
version: '0'
|
94
55
|
- !ruby/object:Gem::Dependency
|
95
56
|
name: simplecov
|
96
57
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
58
|
requirements:
|
99
|
-
- -
|
59
|
+
- - '>='
|
100
60
|
- !ruby/object:Gem::Version
|
101
61
|
version: '0'
|
102
62
|
type: :development
|
103
63
|
prerelease: false
|
104
64
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
65
|
requirements:
|
107
|
-
- -
|
66
|
+
- - '>='
|
108
67
|
- !ruby/object:Gem::Version
|
109
68
|
version: '0'
|
110
69
|
description: Get a U.S. state name from its abbreviation or get a U.S. state abbreviation
|
@@ -112,48 +71,50 @@ description: Get a U.S. state name from its abbreviation or get a U.S. state abb
|
|
112
71
|
email: mikedball@gmail.com
|
113
72
|
executables: []
|
114
73
|
extensions: []
|
115
|
-
extra_rdoc_files:
|
116
|
-
- LICENSE
|
117
|
-
- README.md
|
74
|
+
extra_rdoc_files: []
|
118
75
|
files:
|
76
|
+
- .gitignore
|
77
|
+
- .ruby-gemset
|
78
|
+
- .ruby-version
|
119
79
|
- .travis.yml
|
120
80
|
- Gemfile
|
121
81
|
- Gemfile.lock
|
122
82
|
- LICENSE
|
123
83
|
- README.md
|
124
84
|
- Rakefile
|
125
|
-
- VERSION
|
126
85
|
- lib/madison.rb
|
127
|
-
- lib/
|
86
|
+
- lib/madison/map.rb
|
87
|
+
- lib/madison/states.json
|
88
|
+
- lib/madison/version.rb
|
128
89
|
- madison.gemspec
|
90
|
+
- spec/lib/madison/map_spec.rb
|
129
91
|
- spec/lib/madison_spec.rb
|
130
92
|
- spec/spec_helper.rb
|
131
93
|
homepage: http://github.com/mdb/madison.rb
|
132
94
|
licenses:
|
133
95
|
- MIT
|
96
|
+
metadata: {}
|
134
97
|
post_install_message:
|
135
98
|
rdoc_options: []
|
136
99
|
require_paths:
|
137
100
|
- lib
|
138
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
-
none: false
|
140
102
|
requirements:
|
141
|
-
- -
|
103
|
+
- - '>='
|
142
104
|
- !ruby/object:Gem::Version
|
143
105
|
version: '0'
|
144
|
-
segments:
|
145
|
-
- 0
|
146
|
-
hash: 2177336480880133851
|
147
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
-
none: false
|
149
107
|
requirements:
|
150
|
-
- -
|
108
|
+
- - '>='
|
151
109
|
- !ruby/object:Gem::Version
|
152
110
|
version: '0'
|
153
111
|
requirements: []
|
154
112
|
rubyforge_project:
|
155
|
-
rubygems_version:
|
113
|
+
rubygems_version: 2.2.2
|
156
114
|
signing_key:
|
157
|
-
specification_version:
|
115
|
+
specification_version: 4
|
158
116
|
summary: A simple Ruby gem for working with U.S. state names and abbreviations.
|
159
|
-
test_files:
|
117
|
+
test_files:
|
118
|
+
- spec/lib/madison/map_spec.rb
|
119
|
+
- spec/lib/madison_spec.rb
|
120
|
+
- spec/spec_helper.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.0
|