united_states 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cae89f62b5c954b0f687db1f81c12474f27df029
4
+ data.tar.gz: 5edc0812266220c1bbf5e17b8b9b194663f3738e
5
+ SHA512:
6
+ metadata.gz: 4ca2c3a7d0829e880ee41102e57530f5d4c63ccee2ce3a781efc6b9c4a68afa728ae5d8818b5de5334f894442e9f51d11de4335f8aaea39040ee776ff4363489
7
+ data.tar.gz: 6f53c514d69c9d42bf4e324724754508b4ef5a429976d1b1ec15c59d41d170f2c956e8137ce8c3faf200796c88a86891dde54d2448cfc8fce38d3c0650b2c186
data/.gitignore ADDED
@@ -0,0 +1,53 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ Gemfile.lock
46
+ .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # rspec failure tracking
50
+ .rspec_status
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
data/.rubocop.yml ADDED
@@ -0,0 +1,29 @@
1
+ # Please see the following for configuration options:
2
+ # https://github.com/bbatsov/rubocop
3
+ # https://github.com/nevir/rubocop-rspec
4
+ require: rubocop-rspec
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.3
8
+
9
+ Documentation:
10
+ Exclude:
11
+ - spec/**/*_spec.rb
12
+
13
+ Metrics/BlockLength:
14
+ Exclude:
15
+ - spec/**/*_spec.rb
16
+
17
+ Metrics/ClassLength:
18
+ Exclude:
19
+ - spec/**/*_spec.rb
20
+
21
+ RSpec/DescribeClass:
22
+ Exclude:
23
+ - spec/support/**/*
24
+
25
+ Style/MultilineMethodCallBraceLayout:
26
+ EnforcedStyle: same_line
27
+
28
+ Style/MultilineMethodCallIndentation:
29
+ EnforcedStyle: indented
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ united_states
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at kyle.thomas.whittington@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+
4
+ # Specify your gem's dependencies in united_states.gemspec
5
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Kyle Whittington
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # UnitedStates
2
+
3
+ [![CircleCI](https://circleci.com/gh/kWhittington/united_states.svg?style=svg)](https://circleci.com/gh/kWhittington/united_states)
4
+
5
+ The names and abbreviations of each United States of America State.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's `Gemfile`:
10
+
11
+ ```ruby
12
+ gem 'united_states'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install united_states
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `./bin/setup` to install dependencies.
30
+ Then, run `./bin/test` to run code quality checks and tests.
31
+ Then, run './bin/document' to generate `doc/` and open `doc/index.html`
32
+ to view the documentation. See
33
+ http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md for
34
+ documentation syntax.
35
+
36
+ You can also run `./bin/console` for an interactive prompt that will allow
37
+ you to experiment.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake
40
+ install`. To release a new version, update the version number in
41
+ `version.rb`, and then run `bundle exec rake release`, which will create a
42
+ git tag for the version, push git commits and tags, and push the
43
+ `.gem` file to [rubygems.org](https://rubygems.org).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at
48
+ https://github.com/Kyle Whittington/united_states. This project is intended
49
+ to be a safe, welcoming space for collaboration, and contributors are
50
+ expected to adhere to the
51
+ [Contributor Covenant](http://contributor-covenant.org) code of conduct.
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the
56
+ [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'united_states'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ require 'pry'
12
+ Pry.start
data/bin/document ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bash
2
+ bundle exec yard doc
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/test ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+ bundle exec rubocop
3
+ bundle exec rake spec
data/circle.yml ADDED
@@ -0,0 +1,6 @@
1
+ dependencies:
2
+ override:
3
+ - ./bin/setup
4
+ test:
5
+ override:
6
+ - ./bin/test
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+ require 'united_states/version'
3
+ require 'united_states/state/designation'
4
+
5
+ # rubocop: disable Metrics/ModuleLength
6
+ #
7
+ # Top-level namespace for this gem.
8
+ module UnitedStates
9
+ # @return [Array<UnitedStates::State::Abbreviation>]
10
+ # a collection of all U.S. State Abbreviations.
11
+ def self.abbreviations
12
+ all.map(&:abbreviation)
13
+ end
14
+
15
+ # rubocop: disable Metrics/AbcSize
16
+ # rubocop: disable Metrics/MethodLength
17
+ # @return [Array<UnitedStates::State::Designation>]
18
+ # a collection of all U.S. State Designations.
19
+ def self.all
20
+ [
21
+ UnitedStates::State::Designation.new(
22
+ name: 'Alabama', abbreviation: 'AL'),
23
+ UnitedStates::State::Designation.new(
24
+ name: 'Alaska', abbreviation: 'AK'),
25
+ UnitedStates::State::Designation.new(
26
+ name: 'Arizona', abbreviation: 'AZ'),
27
+ UnitedStates::State::Designation.new(
28
+ name: 'Arkansas', abbreviation: 'AR'),
29
+ UnitedStates::State::Designation.new(
30
+ name: 'California', abbreviation: 'CA'),
31
+ UnitedStates::State::Designation.new(
32
+ name: 'Colorado', abbreviation: 'CO'),
33
+ UnitedStates::State::Designation.new(
34
+ name: 'Connecticut', abbreviation: 'CT'),
35
+ UnitedStates::State::Designation.new(
36
+ name: 'Delaware', abbreviation: 'DE'),
37
+ UnitedStates::State::Designation.new(
38
+ name: 'Florida', abbreviation: 'FL'),
39
+ UnitedStates::State::Designation.new(
40
+ name: 'Georgia', abbreviation: 'GA'),
41
+ UnitedStates::State::Designation.new(
42
+ name: 'Hawaii', abbreviation: 'HI'),
43
+ UnitedStates::State::Designation.new(
44
+ name: 'Idaho', abbreviation: 'ID'),
45
+ UnitedStates::State::Designation.new(
46
+ name: 'Illinois', abbreviation: 'IL'),
47
+ UnitedStates::State::Designation.new(
48
+ name: 'Indiana', abbreviation: 'IN'),
49
+ UnitedStates::State::Designation.new(
50
+ name: 'Iowa', abbreviation: 'IA'),
51
+ UnitedStates::State::Designation.new(
52
+ name: 'Kansas', abbreviation: 'KS'),
53
+ UnitedStates::State::Designation.new(
54
+ name: 'Kentucky', abbreviation: 'KY'),
55
+ UnitedStates::State::Designation.new(
56
+ name: 'Louisiana', abbreviation: 'LA'),
57
+ UnitedStates::State::Designation.new(
58
+ name: 'Maine', abbreviation: 'ME'),
59
+ UnitedStates::State::Designation.new(
60
+ name: 'Maryland', abbreviation: 'MD'),
61
+ UnitedStates::State::Designation.new(
62
+ name: 'Massachusetts', abbreviation: 'MA'),
63
+ UnitedStates::State::Designation.new(
64
+ name: 'Michigan', abbreviation: 'MI'),
65
+ UnitedStates::State::Designation.new(
66
+ name: 'Minnesota', abbreviation: 'MN'),
67
+ UnitedStates::State::Designation.new(
68
+ name: 'Mississippi', abbreviation: 'MS'),
69
+ UnitedStates::State::Designation.new(
70
+ name: 'Missouri', abbreviation: 'MO'),
71
+ UnitedStates::State::Designation.new(
72
+ name: 'Montana', abbreviation: 'MT'),
73
+ UnitedStates::State::Designation.new(
74
+ name: 'Nebraska', abbreviation: 'NE'),
75
+ UnitedStates::State::Designation.new(
76
+ name: 'Nevada', abbreviation: 'NV'),
77
+ UnitedStates::State::Designation.new(
78
+ name: 'New Hampshire', abbreviation: 'NH'),
79
+ UnitedStates::State::Designation.new(
80
+ name: 'New Jersey', abbreviation: 'NJ'),
81
+ UnitedStates::State::Designation.new(
82
+ name: 'New Mexico', abbreviation: 'NM'),
83
+ UnitedStates::State::Designation.new(
84
+ name: 'New York', abbreviation: 'NY'),
85
+ UnitedStates::State::Designation.new(
86
+ name: 'North Carolina', abbreviation: 'NC'),
87
+ UnitedStates::State::Designation.new(
88
+ name: 'North Dakota', abbreviation: 'ND'),
89
+ UnitedStates::State::Designation.new(
90
+ name: 'Ohio', abbreviation: 'OH'),
91
+ UnitedStates::State::Designation.new(
92
+ name: 'Oklahoma', abbreviation: 'OK'),
93
+ UnitedStates::State::Designation.new(
94
+ name: 'Oregon', abbreviation: 'OR'),
95
+ UnitedStates::State::Designation.new(
96
+ name: 'Pennsylvania', abbreviation: 'PA'),
97
+ UnitedStates::State::Designation.new(
98
+ name: 'Rhode Island', abbreviation: 'RI'),
99
+ UnitedStates::State::Designation.new(
100
+ name: 'South Carolina', abbreviation: 'SC'),
101
+ UnitedStates::State::Designation.new(
102
+ name: 'South Dakota', abbreviation: 'SD'),
103
+ UnitedStates::State::Designation.new(
104
+ name: 'Tennessee', abbreviation: 'TN'),
105
+ UnitedStates::State::Designation.new(
106
+ name: 'Texas', abbreviation: 'TX'),
107
+ UnitedStates::State::Designation.new(
108
+ name: 'Utah', abbreviation: 'UT'),
109
+ UnitedStates::State::Designation.new(
110
+ name: 'Vermont', abbreviation: 'VT'),
111
+ UnitedStates::State::Designation.new(
112
+ name: 'Virginia', abbreviation: 'VA'),
113
+ UnitedStates::State::Designation.new(
114
+ name: 'Washington', abbreviation: 'WA'),
115
+ UnitedStates::State::Designation.new(
116
+ name: 'West Virginia', abbreviation: 'WV'),
117
+ UnitedStates::State::Designation.new(
118
+ name: 'Wisconsin', abbreviation: 'WI'),
119
+ UnitedStates::State::Designation.new(
120
+ name: 'Wyoming', abbreviation: 'WY')
121
+ ]
122
+ end
123
+ # rubocop: enable Metrics/AbcSize
124
+ # rubocop: enable Metrics/MethodLength
125
+
126
+ # @return [Array<UnitedStates::State::Name>]
127
+ # a collection of all U.S. State Names.
128
+ def self.names
129
+ all.map(&:name)
130
+ end
131
+ end
132
+ # rubocop: enable Metrics/ModuleLength
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UnitedStates
4
+ module State
5
+ # A U.S. State abbreviation.
6
+ class Abbreviation
7
+ # Thrown when someone attempts to make an Abbreviation instance
8
+ # from a string longer than 2 characters.
9
+ class StringTooLongError < StandardError
10
+ DEFAULT_MESSAGE = 'string too long, abbreviations must be 2 characters'
11
+
12
+ def initialize(message = DEFAULT_MESSAGE)
13
+ super(message)
14
+ end
15
+ end
16
+
17
+ # Thrown when someone attempts to make an Abbreviation instance
18
+ # from a string shorter than 2 characters.
19
+ class StringTooShortError < StandardError
20
+ DEFAULT_MESSAGE = 'string too short, abbreviations must be 2 characters'
21
+
22
+ def initialize(message = DEFAULT_MESSAGE)
23
+ super(message)
24
+ end
25
+ end
26
+
27
+ # @param string [String]
28
+ # the abbreviation of the State
29
+ # @raise [UnitedStates::State::Abbreviation::StringTooLongError]
30
+ # if the string is over 2 characters in length
31
+ # @raise [UnitedStates::State::Abbreviation::StringTooShortError]
32
+ # if the string is under 2 characters in length
33
+ # @return [UnitedStates::State::Abbreviation]
34
+ def initialize(string)
35
+ ensure_string_not_too_long(string)
36
+ ensure_string_not_too_short(string)
37
+ @string = string
38
+ end
39
+
40
+ # @param [UnitedStates::State::Abbreviation]
41
+ # @return [Boolean]
42
+ # whether or not other.to_s matches self.to_s
43
+ def ==(other)
44
+ other.to_s == to_s
45
+ end
46
+
47
+ # @return [String]
48
+ # an all lowercase version of this Abbrevation
49
+ def lowercase
50
+ @string.downcase
51
+ end
52
+
53
+ # @return [String]
54
+ # an all uppercase version of this Abbrevation
55
+ def uppercase
56
+ @string.upcase
57
+ end
58
+
59
+ # @return [String]
60
+ # an all uppercase version of this Abbreviation
61
+ def to_s
62
+ uppercase
63
+ end
64
+
65
+ private
66
+
67
+ # @param string [String]
68
+ # @raise [UnitedStates::State::Abbreviation::StringTooLongError]
69
+ # if the string is over 2 characters in length
70
+ # @return [true]
71
+ # if the string is under 2 characters in length
72
+ def ensure_string_not_too_long(string)
73
+ return true if string.length <= 2
74
+ raise StringTooLongError,
75
+ "#{string} too long, abbreviations must be 2 characters"
76
+ end
77
+
78
+ # @param string [String]
79
+ # @raise [UnitedStates::State::Abbreviation::StringTooShortError]
80
+ # if the string is under 2 characters in length
81
+ # @return [true]
82
+ # if the string is 2 characters or more in length
83
+ def ensure_string_not_too_short(string)
84
+ return true if string.length >= 2
85
+ raise StringTooShortError,
86
+ "#{string} too short, abbreviations must be 2 characters"
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ require 'united_states/state/abbreviation'
3
+ require 'united_states/state/name'
4
+
5
+ module UnitedStates
6
+ module State
7
+ # Represents the various way to designate a state (e.g. name, abbreviation).
8
+ class Designation
9
+ # @!attribute [r] abbreviation
10
+ # @return [UnitedStates::State::Abbreviation]
11
+ # the state's abbreviation
12
+ attr_reader :abbreviation
13
+
14
+ # @!attribute [r] name
15
+ # @return [UnitedStates::State::Name]
16
+ # the state's name
17
+ attr_reader :name
18
+
19
+ # @param name [String]
20
+ # @param abbreviation [String]
21
+ # @raise [UnitedStates::State::Abbreviation::StringTooLongError]
22
+ # if the string is over 2 characters in length
23
+ # @raise [UnitedStates::State::Abbreviation::StringTooShortError]
24
+ # if the string is under 2 characters in length
25
+ def initialize(name:, abbreviation:)
26
+ @name = UnitedStates::State::Name.new(name)
27
+ @abbreviation = UnitedStates::State::Abbreviation.new(abbreviation)
28
+ end
29
+
30
+ # @param other [UnitedStates::State::Designation]
31
+ # @return [Boolean]
32
+ # whether or not other's name and abbreviation is equal
33
+ # to this Designation's name and abbreviation
34
+ def ==(other)
35
+ other.name == name &&
36
+ other.abbreviation == abbreviation
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UnitedStates
4
+ module State
5
+ # A state name, requires the name be given on initialization.
6
+ class Name
7
+ # @param string [String]
8
+ # the name of the State
9
+ # @return [UnitedStates::State::Name]
10
+ def initialize(string)
11
+ @string = string
12
+ end
13
+
14
+ # @param [UnitedStates::State::Name]
15
+ # @return [Boolean]
16
+ # whether or not other.to_s matches self.to_s
17
+ def ==(other)
18
+ other.to_s == to_s
19
+ end
20
+
21
+ # @return [String]
22
+ # the State's name with a leading lower case letter
23
+ # and each following word capitalized with no separation.
24
+ def camel_case
25
+ "#{pascal_case[0, 1].downcase}#{pascal_case[1..-1]}"
26
+ end
27
+
28
+ # @return [String]
29
+ # the State's name with a leading capital letter.
30
+ def capitalize
31
+ @string.split.map(&:capitalize).join(' ')
32
+ end
33
+
34
+ # @return [String]
35
+ # the State's name in all lowercase letters.
36
+ def lowercase
37
+ @string.downcase
38
+ end
39
+
40
+ # @return [String]
41
+ # the State's name with each word with a leading capital letter
42
+ # with no separation.
43
+ def pascal_case
44
+ capitalize.tr(' ', '')
45
+ end
46
+
47
+ # @return [String]
48
+ # the State's name all uppercase and separated by underscores.
49
+ def screaming_snake_case
50
+ snake_case.upcase
51
+ end
52
+
53
+ # @return [String]
54
+ # the State's name all lowercase and separated by underscores.
55
+ def snake_case
56
+ lowercase.tr(' ', '_')
57
+ end
58
+
59
+ # @return [String]
60
+ # the State's name with a leading capital letter.
61
+ def to_s
62
+ capitalize
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module UnitedStates
3
+ VERSION = '1.0.0'
4
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+ # coding: utf-8
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'united_states/version'
6
+
7
+ # rubocop: disable Metrics/BlockLength
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'united_states'
10
+ spec.version = UnitedStates::VERSION
11
+ spec.authors = ['Kyle Whittington']
12
+ spec.email = ['kyle.thomas.whittington@gmail.com']
13
+
14
+ spec.summary = 'The United States names and abbreviations.'
15
+ spec.description = 'Allows for getting of state names and abbreviations '\
16
+ 'in various formats.'
17
+ spec.homepage = 'https://github.com/kWhittington/united_states'
18
+ spec.license = 'MIT'
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.13'
28
+ spec.add_development_dependency 'faker'
29
+ spec.add_development_dependency 'pry'
30
+ spec.add_development_dependency 'pry-coolline'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rspec', '~> 3.0'
33
+ spec.add_development_dependency 'rubocop'
34
+ spec.add_development_dependency 'rubocop-rspec'
35
+ spec.add_development_dependency 'yard'
36
+ end
37
+ # rubocop: enable Metrics/BlockLength
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: united_states
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kyle Whittington
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faker
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-coolline
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: yard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Allows for getting of state names and abbreviations in various formats.
140
+ email:
141
+ - kyle.thomas.whittington@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rubocop.yml"
148
+ - ".ruby-gemset"
149
+ - CODE_OF_CONDUCT.md
150
+ - Gemfile
151
+ - LICENSE
152
+ - README.md
153
+ - Rakefile
154
+ - bin/console
155
+ - bin/document
156
+ - bin/setup
157
+ - bin/test
158
+ - circle.yml
159
+ - lib/united_states.rb
160
+ - lib/united_states/state/abbreviation.rb
161
+ - lib/united_states/state/designation.rb
162
+ - lib/united_states/state/name.rb
163
+ - lib/united_states/version.rb
164
+ - united_states.gemspec
165
+ homepage: https://github.com/kWhittington/united_states
166
+ licenses:
167
+ - MIT
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.5.1
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: The United States names and abbreviations.
189
+ test_files: []