geographer 1.0.0 → 1.1.0

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/README.rdoc CHANGED
@@ -29,42 +29,45 @@ Add to environment file:
29
29
 
30
30
  config.gem "geographer", :version => '1.0.0', :source => 'http://gemcutter.org'
31
31
 
32
- You may also want to create an initializer at config/initilaizer/geographer.rb:
32
+ You will need to create classes and include modules in order to use geographer. You can do this in the lib directory,
33
+ an initializer, etc.:
33
34
 
34
- $STATES = Geographer::Us::States
35
-
36
- This will allow you to use $STATES as opposed to Geographer::Us::States when using geographer within your application.
35
+ class States
36
+ include Geographer::Us::States
37
+ end
37
38
 
38
39
 
39
40
  == USAGE
40
41
 
42
+ The examples are based on the States class created above.
43
+
41
44
  For a list (array) of state abbreviations:
42
45
 
43
- Geographer::Us::States.abbreviations
46
+ States.abbreviations
44
47
 
45
48
  For a list (array) of state names:
46
49
 
47
- Geographer::Us::States.names
50
+ States.names
48
51
 
49
52
  For a list (array) of state abbreviations with US territories:
50
53
 
51
- Geographer::Us::States.abbreviations_with_territories
54
+ States.abbreviations_with_territories
52
55
 
53
56
  For a list (array) of state names with US territories:
54
57
 
55
- Geographer::Us::States.names_with_territories
58
+ States.names_with_territories
56
59
 
57
60
  For a list (array) of territory abbreviations:
58
61
 
59
- Geographer::Us::States.territories_abbreviations
62
+ States.territories_abbreviations
60
63
 
61
64
  For a list (array) of territory names:
62
65
 
63
- Geographer::Us::States.territories_names
66
+ States.territories_names
64
67
 
65
68
  To look up the full name from the abbreviation:
66
69
 
67
- Geographer::Us::States.abbreviations_name_map['AL'] # returns 'Alabama'
70
+ States.abbreviations_name_map['AL'] # returns 'Alabama'
68
71
 
69
72
 
70
73
  == LICENSE
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
data/geographer.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{geographer}
8
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["C. Jason Harrelson (midas)"]
@@ -4,105 +4,111 @@ module Geographer
4
4
  # Provides a list of US States abbreviations (with and without territories), names and a map of
5
5
  # abbreviations to names.
6
6
  #
7
- class States
7
+ module States
8
8
 
9
- # A list of abbreviatons of US States and territories.
10
- #
11
- def self.abbreviations
12
- self.abbreviations_with_territories - self.territories_abbreviations
9
+ def self.included( base )
10
+ base.extend( ClassMethods )
13
11
  end
12
+
13
+ module ClassMethods
14
+ # A list of abbreviatons of US States and territories.
15
+ #
16
+ def abbreviations
17
+ self.abbreviations_with_territories - self.territories_abbreviations
18
+ end
14
19
 
15
- # A list of names of US States only (no territories).
16
- #
17
- def self.names
18
- self.names_with_territories - self.territories_names
19
- end
20
+ # A list of names of US States only (no territories).
21
+ #
22
+ def names
23
+ self.names_with_territories - self.territories_names
24
+ end
20
25
 
21
- # A list of abbreviatons of US States and territories.
22
- #
23
- def self.abbreviations_with_territories
24
- self.abbreviations_name_map.keys.sort
25
- end
26
+ # A list of abbreviatons of US States and territories.
27
+ #
28
+ def abbreviations_with_territories
29
+ self.abbreviations_name_map.keys.sort
30
+ end
26
31
 
27
- # A list of names of US States and territories.
28
- #
29
- def self.names_with_territories
30
- self.abbreviations_name_map.values.sort
31
- end
32
+ # A list of names of US States and territories.
33
+ #
34
+ def names_with_territories
35
+ self.abbreviations_name_map.values.sort
36
+ end
32
37
 
33
- # A list of abbreviatons of US territories.
34
- #
35
- def self.territories_abbreviations
36
- %w( AS FM GU MH PW PR VI )
37
- end
38
+ # A list of abbreviatons of US territories.
39
+ #
40
+ def territories_abbreviations
41
+ %w( AS FM GU MH PW PR VI )
42
+ end
38
43
 
39
- def self.territories_names
40
- [ "American Samoa", "Guam", "Islands", "Micronesia", "Palau", "Puerto Rico", "Virgin Island" ]
41
- end
44
+ def territories_names
45
+ [ "American Samoa", "Guam", "Islands", "Micronesia", "Palau", "Puerto Rico", "Virgin Island" ]
46
+ end
42
47
 
43
- # An index (map) of US States and territories abbreviations and full names.
44
- #
45
- def self.abbreviations_name_map
46
- {
47
- 'AL' => 'Alabama',
48
- 'AK' => 'Alaska',
49
- 'AS' => 'American Samoa',
50
- 'AZ' => 'Arizona',
51
- 'AR' => 'Arkansas',
52
- 'CA' => 'California',
53
- 'CO' => 'Colorado',
54
- 'CT' => 'Connecticut',
55
- 'DE' => 'Delaware',
56
- 'DC' => 'District of Columbia',
57
- 'FM' => 'Micronesia',
58
- 'FL' => 'Florida',
59
- 'GA' => 'Georgia',
60
- 'GU' => 'Guam',
61
- 'HI' => 'Hawaii',
62
- 'ID' => 'Idaho',
63
- 'IL' => 'Illinois',
64
- 'IN' => 'Indiana',
65
- 'IA' => 'Iowa',
66
- 'KS' => 'Kansas',
67
- 'KY' => 'Kentucky',
68
- 'LA' => 'Louisiana',
69
- 'ME' => 'Maine',
70
- 'MH' => 'Islands',
71
- 'MD' => 'Maryland',
72
- 'MA' => 'Massachusetts',
73
- 'MI' => 'Michigan',
74
- 'MN' => 'Minnesota',
75
- 'MS' => 'Mississippi',
76
- 'MO' => 'Missouri',
77
- 'MT' => 'Montana',
78
- 'NE' => 'Nebraska',
79
- 'NV' => 'Nevada',
80
- 'NH' => 'New Hampshire',
81
- 'NJ' => 'New Jersey',
82
- 'NM' => 'New Mexico',
83
- 'NY' => 'New York',
84
- 'NC' => 'North Carolina',
85
- 'ND' => 'North Dakota',
86
- 'OH' => 'Ohio',
87
- 'OK' => 'Oklahoma',
88
- 'OR' => 'Oregon',
89
- 'PW' => 'Palau',
90
- 'PA' => 'Pennsylvania',
91
- 'PR' => 'Puerto Rico',
92
- 'RI' => 'Rhode Island',
93
- 'SC' => 'South Carolina',
94
- 'SD' => 'South Dakota',
95
- 'TN' => 'Tennessee',
96
- 'TX' => 'Texas',
97
- 'UT' => 'Utah',
98
- 'VT' => 'Vermont',
99
- 'VI' => 'Virgin Island',
100
- 'VA' => 'Virginia',
101
- 'WA' => 'Washington',
102
- 'WV' => 'West Virginia',
103
- 'WI' => 'Wisconsin',
104
- 'WY' => 'Wyoming'
105
- }
48
+ # An index (map) of US States and territories abbreviations and full names.
49
+ #
50
+ def abbreviations_name_map
51
+ {
52
+ 'AL' => 'Alabama',
53
+ 'AK' => 'Alaska',
54
+ 'AS' => 'American Samoa',
55
+ 'AZ' => 'Arizona',
56
+ 'AR' => 'Arkansas',
57
+ 'CA' => 'California',
58
+ 'CO' => 'Colorado',
59
+ 'CT' => 'Connecticut',
60
+ 'DE' => 'Delaware',
61
+ 'DC' => 'District of Columbia',
62
+ 'FM' => 'Micronesia',
63
+ 'FL' => 'Florida',
64
+ 'GA' => 'Georgia',
65
+ 'GU' => 'Guam',
66
+ 'HI' => 'Hawaii',
67
+ 'ID' => 'Idaho',
68
+ 'IL' => 'Illinois',
69
+ 'IN' => 'Indiana',
70
+ 'IA' => 'Iowa',
71
+ 'KS' => 'Kansas',
72
+ 'KY' => 'Kentucky',
73
+ 'LA' => 'Louisiana',
74
+ 'ME' => 'Maine',
75
+ 'MH' => 'Islands',
76
+ 'MD' => 'Maryland',
77
+ 'MA' => 'Massachusetts',
78
+ 'MI' => 'Michigan',
79
+ 'MN' => 'Minnesota',
80
+ 'MS' => 'Mississippi',
81
+ 'MO' => 'Missouri',
82
+ 'MT' => 'Montana',
83
+ 'NE' => 'Nebraska',
84
+ 'NV' => 'Nevada',
85
+ 'NH' => 'New Hampshire',
86
+ 'NJ' => 'New Jersey',
87
+ 'NM' => 'New Mexico',
88
+ 'NY' => 'New York',
89
+ 'NC' => 'North Carolina',
90
+ 'ND' => 'North Dakota',
91
+ 'OH' => 'Ohio',
92
+ 'OK' => 'Oklahoma',
93
+ 'OR' => 'Oregon',
94
+ 'PW' => 'Palau',
95
+ 'PA' => 'Pennsylvania',
96
+ 'PR' => 'Puerto Rico',
97
+ 'RI' => 'Rhode Island',
98
+ 'SC' => 'South Carolina',
99
+ 'SD' => 'South Dakota',
100
+ 'TN' => 'Tennessee',
101
+ 'TX' => 'Texas',
102
+ 'UT' => 'Utah',
103
+ 'VT' => 'Vermont',
104
+ 'VI' => 'Virgin Island',
105
+ 'VA' => 'Virginia',
106
+ 'WA' => 'Washington',
107
+ 'WV' => 'West Virginia',
108
+ 'WI' => 'Wisconsin',
109
+ 'WY' => 'Wyoming'
110
+ }
111
+ end
106
112
  end
107
113
  end
108
114
  end
data/lib/geographer.rb CHANGED
@@ -4,5 +4,5 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'geographer/us/states'
5
5
 
6
6
  module Geographer
7
- VERSION = '1.0.0'
7
+ VERSION = '1.1.0'
8
8
  end
@@ -2,6 +2,12 @@ require 'test_helper'
2
2
 
3
3
  class StatesTest < Test::Unit::TestCase
4
4
  context "states" do
5
+ setup do
6
+ class States
7
+ include Geographer::Us::States
8
+ end
9
+ end
10
+
5
11
  context "abbreviations" do
6
12
  setup do
7
13
  @states = %w( AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geographer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - C. Jason Harrelson (midas)