us_states 0.0.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.8.0"
10
+ gem "yard", "~> 0.7"
11
+ gem "bundler", ">= 1.0.0"
12
+ gem "jeweler", "~> 1.8.4"
13
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Byron Anderson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = us_states
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to us_states
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Byron Anderson. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
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'
13
+
14
+ require 'jeweler'
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 = "us_states"
18
+ gem.homepage = "http://github.com/byronanderson/us_states"
19
+ gem.license = "MIT"
20
+ gem.summary = "A module containing a list of all of the united states and territories"
21
+ gem.description = "As simple as that"
22
+ gem.email = "byron@nationbuilder.com"
23
+ gem.authors = ["Byron Anderson", "Jim Gilliam"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'yard'
42
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -1,4 +1,6 @@
1
1
  module State
2
+ class InvalidState < RuntimeError; end
3
+
2
4
  CODES = {
3
5
  'AL' => 'Alabama',
4
6
  'AK' => 'Alaska',
@@ -59,4 +61,30 @@ module State
59
61
  'WI' => 'Wisconsin',
60
62
  'WY' => 'Wyoming'
61
63
  }
64
+
65
+
66
+ def self.member?(state)
67
+ CODES.member? normalize(state)
68
+ rescue InvalidState
69
+ false
70
+ end
71
+
72
+ def self.states
73
+ CODES.values
74
+ end
75
+
76
+ def self.normalize(state)
77
+ return state.upcase if CODES.member? state.upcase
78
+ return STATE_TO_CODE.fetch state.downcase
79
+ rescue KeyError
80
+ raise InvalidState
81
+ end
82
+
83
+ private
84
+
85
+ STATE_TO_CODE = CODES.inject({}) do |hash, code_state|
86
+ code, state = code_state
87
+ hash[state.downcase] = code
88
+ hash
89
+ end
62
90
  end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'us_states'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
@@ -0,0 +1,19 @@
1
+ require 'us_states'
2
+
3
+ describe State do
4
+ describe ".normalize" do
5
+ specify { State.normalize("Alabama").should == "AL" }
6
+ specify { State.normalize("AL").should == "AL" }
7
+ specify { State.normalize("texas").should == "TX" }
8
+ specify do
9
+ expect { State.normalize("south") }.to raise_error(State::InvalidState)
10
+ end
11
+ specify { State.normalize("tx").should == "TX" }
12
+ end
13
+
14
+ describe ".member?" do
15
+ specify { State.member?("AL").should be_true }
16
+ specify { State.member?("XT").should be_false }
17
+ specify { State.member?("Alabama").should be_true }
18
+ end
19
+ end
@@ -0,0 +1,59 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "us_states"
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Byron Anderson", "Jim Gilliam"]
12
+ s.date = "2012-09-29"
13
+ s.description = "As simple as that"
14
+ s.email = "byron@nationbuilder.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/us_states.rb",
28
+ "spec/spec_helper.rb",
29
+ "spec/us_states_spec.rb",
30
+ "us_states.gemspec"
31
+ ]
32
+ s.homepage = "http://github.com/byronanderson/us_states"
33
+ s.licenses = ["MIT"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = "1.8.24"
36
+ s.summary = "A module containing a list of all of the united states and territories"
37
+
38
+ if s.respond_to? :specification_version then
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
43
+ s.add_development_dependency(%q<yard>, ["~> 0.7"])
44
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
45
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
46
+ else
47
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
48
+ s.add_dependency(%q<yard>, ["~> 0.7"])
49
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
50
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
54
+ s.add_dependency(%q<yard>, ["~> 0.7"])
55
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
56
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
57
+ end
58
+ end
59
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: us_states
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,17 +10,94 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-24 00:00:00.000000000 Z
14
- dependencies: []
13
+ date: 2012-09-29 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 2.8.0
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 2.8.0
31
+ - !ruby/object:Gem::Dependency
32
+ name: yard
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '0.7'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '0.7'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 1.0.0
63
+ - !ruby/object:Gem::Dependency
64
+ name: jeweler
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: 1.8.4
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 1.8.4
15
79
  description: As simple as that
16
80
  email: byron@nationbuilder.com
17
81
  executables: []
18
82
  extensions: []
19
- extra_rdoc_files: []
83
+ extra_rdoc_files:
84
+ - LICENSE.txt
85
+ - README.rdoc
20
86
  files:
21
- - lib/states.rb
22
- homepage: http://rubygems.org/gems/us_states
23
- licenses: []
87
+ - .document
88
+ - .rspec
89
+ - Gemfile
90
+ - LICENSE.txt
91
+ - README.rdoc
92
+ - Rakefile
93
+ - VERSION
94
+ - lib/us_states.rb
95
+ - spec/spec_helper.rb
96
+ - spec/us_states_spec.rb
97
+ - us_states.gemspec
98
+ homepage: http://github.com/byronanderson/us_states
99
+ licenses:
100
+ - MIT
24
101
  post_install_message:
25
102
  rdoc_options: []
26
103
  require_paths:
@@ -31,6 +108,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
31
108
  - - ! '>='
32
109
  - !ruby/object:Gem::Version
33
110
  version: '0'
111
+ segments:
112
+ - 0
113
+ hash: -2482533967524400247
34
114
  required_rubygems_version: !ruby/object:Gem::Requirement
35
115
  none: false
36
116
  requirements:
@@ -42,5 +122,5 @@ rubyforge_project:
42
122
  rubygems_version: 1.8.24
43
123
  signing_key:
44
124
  specification_version: 3
45
- summary: A module containing a list of all of the united states
125
+ summary: A module containing a list of all of the united states and territories
46
126
  test_files: []