looky-lu 0.0.2 → 0.0.3
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.
- checksums.yaml +8 -8
- data/README.md +25 -22
- data/lib/data/lu/countries.yml +196 -0
- data/lib/data/lu/states.rb +16 -0
- data/lib/generators/lookylu/state_data_generator.rb +9 -24
- data/lib/generators/lookylu/state_generator.rb +1 -1
- data/lib/looky-lu/version.rb +1 -1
- data/spec/data/state_data_spec.rb +15 -0
- data/spec/generators/state_data_generator_spec.rb +19 -29
- data/spec/generators/state_generator_spec.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODcwZmI4M2U3MjUxMGRjZTkxZmQ2M2NiMzIyODEyM2I1ZjA5ZDZiNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzE3NmQ0MGE4YjM5NjU4OTQ5N2JhMzNmNDdkNzBkYjZiYjBlYjk3OA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Njc5NjZlZTVlZmM1ZDA5Mjk2YmEyMjJmODdkMzQ1ZGI5Mjk0YjIzMDIyZjUx
|
10
|
+
YWRhZjFlYWE3YTg3OTJhODNkNzZlN2U5YzA2YjViZmQ0ZDg3NTQ3ZTk3NWI0
|
11
|
+
MmZjNzgxYTE1NTZhM2YwM2NhYjQ3YjJmMWU3ZTE2Nzc0NjJhZWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDIwZTViYjRkMGQ0ZWY4ODA0ODcxMWU5MDJiMGNiOTNjN2JjMzhiMzBiZDdh
|
14
|
+
YjQ0MmY1MWU3MTMxMDVkOWQwYTI0OWQ2ZTBlOTIxNGYxY2Q4MmU3YTE5OGFi
|
15
|
+
NzBhOGE3ZGY0NWExYjc3YmYzYWMzYzE0NzdkZDkyZjM0YTNkMjc=
|
data/README.md
CHANGED
@@ -13,40 +13,43 @@ For example, you need a State object that is an LU table for all of the states i
|
|
13
13
|
Using my example above of needing a State object:
|
14
14
|
|
15
15
|
Install LookyLu
|
16
|
-
|
17
|
-
gem install looky-lu
|
18
|
-
|
16
|
+
|
17
|
+
gem install looky-lu
|
18
|
+
|
19
19
|
Or add to your gemfile
|
20
|
-
|
21
|
-
gem 'looky-lu'
|
22
|
-
|
20
|
+
|
21
|
+
gem 'looky-lu'
|
22
|
+
|
23
23
|
|
24
24
|
Generate the ActiveRecord model and the needed migration
|
25
|
-
```
|
26
|
-
rails g lookylu:state
|
27
|
-
```
|
28
25
|
|
26
|
+
rails g lookylu:state
|
27
|
+
|
28
|
+
|
29
|
+
Populate the database with the 50 states plus D.C.
|
30
|
+
|
31
|
+
rails g lookylu:state_data State united_states
|
32
|
+
|
29
33
|
Migrate your database
|
30
|
-
```
|
31
|
-
rake db:migrate
|
32
|
-
```
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
rake db:migrate
|
36
|
+
|
37
|
+
Seed your database
|
38
|
+
|
39
|
+
rake db:seed
|
40
|
+
|
38
41
|
|
39
42
|
## Additional Options ##
|
40
43
|
|
41
44
|
For generating the Model and migration
|
42
|
-
|
43
|
-
rails g lookylu:state -h
|
44
|
-
|
45
|
+
|
46
|
+
rails g lookylu:state -h
|
47
|
+
|
45
48
|
|
46
49
|
For generating the LU data
|
47
|
-
|
48
|
-
rails g lookylu:state_data -h
|
49
|
-
|
50
|
+
|
51
|
+
rails g lookylu:state_data -h
|
52
|
+
|
50
53
|
|
51
54
|
## Current LU Data Available ##
|
52
55
|
|
@@ -0,0 +1,196 @@
|
|
1
|
+
countries: [
|
2
|
+
{name: 'Afghanistan', abbreviation: 'AF'},
|
3
|
+
{name: 'Albania', abbreviation: 'AL'},
|
4
|
+
{name: 'Algeria', abbreviation: 'AG'},
|
5
|
+
{name: 'Andorra', abbreviation: 'AN'},
|
6
|
+
{name: 'Angola', abbreviation: 'AO'},
|
7
|
+
{name: 'Antigua and Barbuda', abbreviation: 'AC'},
|
8
|
+
{name: 'Argentina', abbreviation: 'AR'},
|
9
|
+
{name: 'Armenia', abbreviation: 'AM'},
|
10
|
+
{name: 'Australia', abbreviation: 'AS'},
|
11
|
+
{name: 'Austria', abbreviation: 'AU'},
|
12
|
+
{name: 'Azerbaijan', abbreviation: 'AJ'},
|
13
|
+
{name: 'Bahamas, The', abbreviation: 'BF'},
|
14
|
+
{name: 'Bahrain', abbreviation: 'BA'},
|
15
|
+
{name: 'Bangladesh', abbreviation: 'BG'},
|
16
|
+
{name: 'Barbados', abbreviation: 'BB'},
|
17
|
+
{name: 'Belarus', abbreviation: 'BO'},
|
18
|
+
{name: 'Belgium', abbreviation: 'BE'},
|
19
|
+
{name: 'Belize', abbreviation: 'BH'},
|
20
|
+
{name: 'Benin', abbreviation: 'BN'},
|
21
|
+
{name: 'Bhutan', abbreviation: 'BT'},
|
22
|
+
{name: 'Bolivia', abbreviation: 'BL'},
|
23
|
+
{name: 'Bosnia and Herzegovina', abbreviation: 'BK'},
|
24
|
+
{name: 'Botswana', abbreviation: 'BC'},
|
25
|
+
{name: 'Brazil', abbreviation: 'BR'},
|
26
|
+
{name: 'Brunei', abbreviation: 'BX'},
|
27
|
+
{name: 'Bulgaria', abbreviation: 'BU'},
|
28
|
+
{name: 'Burkina Faso', abbreviation: 'UV'},
|
29
|
+
{name: 'Burma', abbreviation: 'BM'},
|
30
|
+
{name: 'Burundi', abbreviation: 'BY'},
|
31
|
+
{name: 'Cambodia', abbreviation: 'CB'},
|
32
|
+
{name: 'Cameroon', abbreviation: 'CM'},
|
33
|
+
{name: 'Canada', abbreviation: 'CA'},
|
34
|
+
{name: 'Cape Verde', abbreviation: 'CV'},
|
35
|
+
{name: 'Central African Republic', abbreviation: 'CT'},
|
36
|
+
{name: 'Chad', abbreviation: 'CD'},
|
37
|
+
{name: 'Chile', abbreviation: 'CI'},
|
38
|
+
{name: 'China', abbreviation: 'CH'},
|
39
|
+
{name: 'Colombia', abbreviation: 'CO'},
|
40
|
+
{name: 'Comoros', abbreviation: 'CN'},
|
41
|
+
{name: 'Congo', abbreviation: 'CG'},
|
42
|
+
{name: 'Costa Rica', abbreviation: 'CS'},
|
43
|
+
{name: "Côte d'Ivoire", abbreviation: 'IV'},
|
44
|
+
{name: 'Croatia', abbreviation: 'HR'},
|
45
|
+
{name: 'Cuba', abbreviation: 'CU'},
|
46
|
+
{name: 'Cyprus', abbreviation: 'CY'},
|
47
|
+
{name: 'Czech Republic', abbreviation: 'EZ'},
|
48
|
+
{name: 'Denmark', abbreviation: 'DA'},
|
49
|
+
{name: 'Djibouti', abbreviation: 'DJ'},
|
50
|
+
{name: 'Dominica', abbreviation: 'DO'},
|
51
|
+
{name: 'Dominican Republic', abbreviation: 'DR'},
|
52
|
+
{name: 'Ecuador', abbreviation: 'EC'},
|
53
|
+
{name: 'Egypt', abbreviation: 'EG'},
|
54
|
+
{name: 'El Salvador', abbreviation: 'ES'},
|
55
|
+
{name: 'Equatorial Guinea', abbreviation: 'EK'},
|
56
|
+
{name: 'Eritrea', abbreviation: 'ER'},
|
57
|
+
{name: 'Estonia', abbreviation: 'EN'},
|
58
|
+
{name: 'Ethiopia', abbreviation: 'ET'},
|
59
|
+
{name: 'Fiji', abbreviation: 'FJ'},
|
60
|
+
{name: 'Finland', abbreviation: 'FI'},
|
61
|
+
{name: 'France', abbreviation: 'FR'},
|
62
|
+
{name: 'Gabon', abbreviation: 'GB'},
|
63
|
+
{name: 'Gambia, The', abbreviation: 'GA'},
|
64
|
+
{name: 'Georgia', abbreviation: 'GG'},
|
65
|
+
{name: 'Germany', abbreviation: 'GM'},
|
66
|
+
{name: 'Ghana', abbreviation: 'GH'},
|
67
|
+
{name: 'Greece', abbreviation: 'GR'},
|
68
|
+
{name: 'Grenada', abbreviation: 'GJ'},
|
69
|
+
{name: 'Guatemala', abbreviation: 'GT'},
|
70
|
+
{name: 'Guinea', abbreviation: 'GV'},
|
71
|
+
{name: 'Guinea-Bissau', abbreviation: 'PU'},
|
72
|
+
{name: 'Guyana', abbreviation: 'GY'},
|
73
|
+
{name: 'Haiti', abbreviation: 'HA'},
|
74
|
+
{name: 'Holy See', abbreviation: 'VT'},
|
75
|
+
{name: 'Honduras', abbreviation: 'HO'},
|
76
|
+
{name: 'Hungary', abbreviation: 'HU'},
|
77
|
+
{name: 'Iceland', abbreviation: 'IC'},
|
78
|
+
{name: 'India', abbreviation: 'IN'},
|
79
|
+
{name: 'Indonesia', abbreviation: 'ID'},
|
80
|
+
{name: 'Iran', abbreviation: 'IR'},
|
81
|
+
{name: 'Iraq', abbreviation: 'IZ'},
|
82
|
+
{name: 'Ireland', abbreviation: 'EI'},
|
83
|
+
{name: 'Israel', abbreviation: 'IS'},
|
84
|
+
{name: 'Italy', abbreviation: 'IT'},
|
85
|
+
{name: 'Jamaica', abbreviation: 'JM'},
|
86
|
+
{name: 'Japan', abbreviation: 'JA'},
|
87
|
+
{name: 'Jordan', abbreviation: 'JO'},
|
88
|
+
{name: 'Kazakhstan', abbreviation: 'KZ'},
|
89
|
+
{name: 'Kenya', abbreviation: 'KE'},
|
90
|
+
{name: 'Kiribati', abbreviation: 'KR'},
|
91
|
+
{name: 'Korea, North', abbreviation: 'KN'},
|
92
|
+
{name: 'Korea, South', abbreviation: 'KS'},
|
93
|
+
{name: 'Kosovo', abbreviation: 'KV'},
|
94
|
+
{name: 'Kuwait', abbreviation: 'KU'},
|
95
|
+
{name: 'Kyrgyzstan', abbreviation: 'KG'},
|
96
|
+
{name: 'Laos', abbreviation: 'LA'},
|
97
|
+
{name: 'Latvia', abbreviation: 'LG'},
|
98
|
+
{name: 'Lebanon', abbreviation: 'LE'},
|
99
|
+
{name: 'Lesotho', abbreviation: 'LT'},
|
100
|
+
{name: 'Liberia', abbreviation: 'LI'},
|
101
|
+
{name: 'Libya', abbreviation: 'LY'},
|
102
|
+
{name: 'Liechtenstein', abbreviation: 'LS'},
|
103
|
+
{name: 'Lithuania', abbreviation: 'LH'},
|
104
|
+
{name: 'Luxembourg', abbreviation: 'LU'},
|
105
|
+
{name: 'Macedonia', abbreviation: 'MK'},
|
106
|
+
{name: 'Madagascar', abbreviation: 'MA'},
|
107
|
+
{name: 'Malawi', abbreviation: 'MI'},
|
108
|
+
{name: 'Malaysia', abbreviation: 'MY'},
|
109
|
+
{name: 'Maldives', abbreviation: 'MV'},
|
110
|
+
{name: 'Mali', abbreviation: 'ML'},
|
111
|
+
{name: 'Malta', abbreviation: 'MT'},
|
112
|
+
{name: 'Marshall Islands', abbreviation: 'RM'},
|
113
|
+
{name: 'Mauritania', abbreviation: 'MR'},
|
114
|
+
{name: 'Mauritius', abbreviation: 'MP'},
|
115
|
+
{name: 'Mexico', abbreviation: 'MX'},
|
116
|
+
{name: 'Micronesia, Federated States of', abbreviation: 'FM'},
|
117
|
+
{name: 'Moldova', abbreviation: 'MD'},
|
118
|
+
{name: 'Monaco', abbreviation: 'MN'},
|
119
|
+
{name: 'Mongolia', abbreviation: 'MG'},
|
120
|
+
{name: 'Montenegro', abbreviation: 'MJ'},
|
121
|
+
{name: 'Morocco', abbreviation: 'MO'},
|
122
|
+
{name: 'Mozambique', abbreviation: 'MZ'},
|
123
|
+
{name: 'Namibia', abbreviation: 'WA'},
|
124
|
+
{name: 'Nauru', abbreviation: 'NR'},
|
125
|
+
{name: 'Nepal', abbreviation: 'NP'},
|
126
|
+
{name: 'Netherlands', abbreviation: 'NL'},
|
127
|
+
{name: 'New Zealand', abbreviation: 'NZ'},
|
128
|
+
{name: 'Nicaragua', abbreviation: 'NU'},
|
129
|
+
{name: 'Niger', abbreviation: 'NG'},
|
130
|
+
{name: 'Nigeria', abbreviation: 'NI'},
|
131
|
+
{name: 'Norway', abbreviation: 'NO'},
|
132
|
+
{name: 'Oman', abbreviation: 'MU'},
|
133
|
+
{name: 'Pakistan', abbreviation: 'PK'},
|
134
|
+
{name: 'Palau', abbreviation: 'PS'},
|
135
|
+
{name: 'Panama', abbreviation: 'PM'},
|
136
|
+
{name: 'Papua New Guinea', abbreviation: 'PP'},
|
137
|
+
{name: 'Paraguay', abbreviation: 'PA'},
|
138
|
+
{name: 'Peru', abbreviation: 'PE'},
|
139
|
+
{name: 'Philippines', abbreviation: 'RP'},
|
140
|
+
{name: 'Poland', abbreviation: 'PL'},
|
141
|
+
{name: 'Portugal', abbreviation: 'PO'},
|
142
|
+
{name: 'Qatar', abbreviation: 'QA'},
|
143
|
+
{name: 'Romania', abbreviation: 'RO'},
|
144
|
+
{name: 'Russia', abbreviation: 'RS'},
|
145
|
+
{name: 'Rwanda', abbreviation: 'RW'},
|
146
|
+
{name: 'Saint Kitts and Nevis', abbreviation: 'SC'},
|
147
|
+
{name: 'Saint Lucia', abbreviation: 'ST'},
|
148
|
+
{name: 'Saint Vincent and the Grenadines', abbreviation: 'VC'},
|
149
|
+
{name: 'Samoa', abbreviation: 'WS'},
|
150
|
+
{name: 'San Marino', abbreviation: 'SM'},
|
151
|
+
{name: 'Sao Tome and Principe', abbreviation: 'TP'},
|
152
|
+
{name: 'Saudi Arabia', abbreviation: 'SA'},
|
153
|
+
{name: 'Senegal', abbreviation: 'SG'},
|
154
|
+
{name: 'Serbia', abbreviation: 'RI'},
|
155
|
+
{name: 'Seychelles', abbreviation: 'SE'},
|
156
|
+
{name: 'Sierra Leone', abbreviation: 'SL'},
|
157
|
+
{name: 'Singapore', abbreviation: 'SN'},
|
158
|
+
{name: 'Slovakia', abbreviation: 'LO'},
|
159
|
+
{name: 'Slovenia', abbreviation: 'SI'},
|
160
|
+
{name: 'Solomon Islands', abbreviation: 'BP'},
|
161
|
+
{name: 'Somalia', abbreviation: 'SO'},
|
162
|
+
{name: 'South Africa', abbreviation: 'SF'},
|
163
|
+
{name: 'South Sudan', abbreviation: 'OD'},
|
164
|
+
{name: 'Spain', abbreviation: 'SP'},
|
165
|
+
{name: 'Sri Lanka', abbreviation: 'CE'},
|
166
|
+
{name: 'Sudan', abbreviation: 'SU'},
|
167
|
+
{name: 'Suriname', abbreviation: 'NS'},
|
168
|
+
{name: 'Swaziland', abbreviation: 'WZ'},
|
169
|
+
{name: 'Sweden', abbreviation: 'SW'},
|
170
|
+
{name: 'Switzerland', abbreviation: 'SZ'},
|
171
|
+
{name: 'Syria', abbreviation: 'SY'},
|
172
|
+
{name: 'Tajikistan', abbreviation: 'TI'},
|
173
|
+
{name: 'Tanzania', abbreviation: 'TZ'},
|
174
|
+
{name: 'Thailand', abbreviation: 'TH'},
|
175
|
+
{name: 'Timor-Leste', abbreviation: 'TT'},
|
176
|
+
{name: 'Togo', abbreviation: 'TO'},
|
177
|
+
{name: 'Tonga', abbreviation: 'TN'},
|
178
|
+
{name: 'Trinidad and Tobago', abbreviation: 'TD'},
|
179
|
+
{name: 'Tunisia', abbreviation: 'TS'},
|
180
|
+
{name: 'Turkey', abbreviation: 'TU'},
|
181
|
+
{name: 'Turkmenistan', abbreviation: 'TX'},
|
182
|
+
{name: 'Tuvalu', abbreviation: 'TV'},
|
183
|
+
{name: 'Uganda', abbreviation: 'UG'},
|
184
|
+
{name: 'Ukraine', abbreviation: 'UP'},
|
185
|
+
{name: 'United Arab Emirates', abbreviation: 'AE'},
|
186
|
+
{name: 'United Kingdom', abbreviation: 'UK'},
|
187
|
+
{name: 'United States', abbreviation: 'US'},
|
188
|
+
{name: 'Uruguay', abbreviation: 'UY'},
|
189
|
+
{name: 'Uzbekistan', abbreviation: 'UZ'},
|
190
|
+
{name: 'Vanuatu', abbreviation: 'NH'},
|
191
|
+
{name: 'Venezuela', abbreviation: 'VE'},
|
192
|
+
{name: 'Vietnam', abbreviation: 'VM'},
|
193
|
+
{name: 'Yemen', abbreviation: 'YM'},
|
194
|
+
{name: 'Zambia', abbreviation: 'ZA'},
|
195
|
+
{name: 'Zimbabwe', abbreviation: 'ZI'}
|
196
|
+
]
|
data/lib/data/lu/states.rb
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
module LookyLu
|
2
2
|
class States
|
3
3
|
|
4
|
+
def self.insert_data(country_name, object_name)
|
5
|
+
|
6
|
+
states = from_country country_name
|
7
|
+
begin
|
8
|
+
class_object = eval(object_name.camelize)
|
9
|
+
|
10
|
+
states.each do |s|
|
11
|
+
class_object.create(s)
|
12
|
+
end
|
13
|
+
rescue => e
|
14
|
+
raise "Could not find object for #{object_name.camelize}"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
4
20
|
def self.from_country(country_name)
|
5
21
|
|
6
22
|
yml = YAML.load_file(File.dirname(__FILE__) + "/states.yml")
|
@@ -6,34 +6,19 @@ module Lookylu
|
|
6
6
|
class StateDataGenerator < Lookylu::Generators::BaseGenerator
|
7
7
|
class_option :country_name, type: :string, default: 'united_states', desc: "Choose a country: united_states, canada, or all."
|
8
8
|
|
9
|
-
def
|
10
|
-
connect_to_db
|
11
|
-
unless ActiveRecord::Base.connection.table_exists? plural_name
|
12
|
-
raise "Table #{plural_name} does not exist. Please build the needed migration and migrate your database"
|
13
|
-
end
|
14
|
-
begin
|
15
|
-
class_object = eval(object_name.capitalize)
|
9
|
+
def append_seeds
|
16
10
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
11
|
+
the_file = 'db/seeds.rb'
|
12
|
+
to_append = "\nLookyLu::States.insert_data('#{options.country_name}', '#{object_name}')\n"
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
14
|
+
#File.open(the_file, 'a') do |file|
|
15
|
+
# file.write "\nLookyLu::States.insert_data('#{options.country_name}', '#{object_name}')\n"
|
16
|
+
#end
|
25
17
|
|
26
|
-
|
27
|
-
|
28
|
-
private
|
18
|
+
FileUtils.touch the_file
|
19
|
+
append_file(the_file, to_append)
|
29
20
|
|
30
|
-
|
31
|
-
ActiveRecord::Base.establish_connection db_config
|
32
|
-
end
|
33
|
-
|
34
|
-
def db_config
|
35
|
-
Rails.configuration.database_configuration[::Rails.env]
|
36
|
-
end
|
21
|
+
end
|
37
22
|
|
38
23
|
end
|
39
24
|
end
|
data/lib/looky-lu/version.rb
CHANGED
@@ -1,8 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'data/lu/states'
|
3
|
+
require 'app/models/State'
|
3
4
|
|
4
5
|
describe LookyLu::States do
|
5
6
|
|
7
|
+
describe 'insert data' do
|
8
|
+
|
9
|
+
it 'should insert some data' do
|
10
|
+
LookyLu::States.insert_data('united_states', 'state')
|
11
|
+
State.count.should == 51
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should properly error when object does not exist' do
|
15
|
+
expect {LookyLu::States.insert_data('united_states', 'not_there')}.
|
16
|
+
to raise_error 'Could not find object for NotThere'
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
6
21
|
describe 'from country' do
|
7
22
|
|
8
23
|
it 'should pull only united states' do
|
@@ -10,45 +10,35 @@ describe Lookylu::Generators::StateDataGenerator do
|
|
10
10
|
@gen.object_name = 'State'
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
Rails.should_receive(:configuration).and_return(double('configuration', database_configuration: {}))
|
15
|
-
@gen.send(:db_config)
|
16
|
-
end
|
13
|
+
describe 'execute generator' do
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
after(:each) do
|
16
|
+
FileUtils.rm_rf 'db'
|
17
|
+
end
|
21
18
|
|
22
|
-
|
19
|
+
it 'should append to file' do
|
20
|
+
Dir.mkdir('db')
|
21
|
+
@gen.append_seeds
|
23
22
|
|
24
|
-
|
25
|
-
|
23
|
+
File.open('db/seeds.rb') do |file|
|
24
|
+
file.read.should == "\nLookyLu::States.insert_data('united_states', 'State')\n"
|
25
|
+
end
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
load_db
|
30
|
-
end
|
28
|
+
it 'should append to existing file' do
|
31
29
|
|
32
|
-
|
33
|
-
@gen.send(:connect_to_db)
|
34
|
-
ActiveRecord::Base.connection.drop_table @gen.plural_name
|
30
|
+
Dir.mkdir('db')
|
35
31
|
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
File.open('db/seeds.rb', 'w') do |file|
|
33
|
+
file.write 'This is a test'
|
34
|
+
end
|
39
35
|
|
40
|
-
|
41
|
-
Object.any_instance.should_receive(:puts).with("There are now #{@gen.pluralize(LookyLu::States.from_country('united_states').count, @gen.plural_model_name)}")
|
36
|
+
@gen.append_seeds
|
42
37
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
38
|
+
File.open('db/seeds.rb') do |file|
|
39
|
+
file.read.should == "This is a test\nLookyLu::States.insert_data('united_states', 'State')\n"
|
40
|
+
end
|
47
41
|
|
48
|
-
it 'should not fail if object does not exist' do
|
49
|
-
@gen.object_name = 'no_model'
|
50
|
-
expect {@gen.populate_data}.
|
51
|
-
to raise_error "Could not find object for #{@gen.model_name}"
|
52
42
|
end
|
53
43
|
|
54
44
|
end
|
@@ -14,7 +14,7 @@ describe Lookylu::Generators::StateGenerator do
|
|
14
14
|
#.send(:method_name, args)
|
15
15
|
|
16
16
|
it 'should get model location' do
|
17
|
-
@gen.send(:model_location).should == "app/models/
|
17
|
+
@gen.send(:model_location).should == "app/models/object_name.rb"
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should get migration_location' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: looky-lu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Hopp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- README.md
|
195
195
|
- Rakefile
|
196
196
|
- lib/app/models/State.rb
|
197
|
+
- lib/data/lu/countries.yml
|
197
198
|
- lib/data/lu/states.rb
|
198
199
|
- lib/data/lu/states.yml
|
199
200
|
- lib/db/migrations/create_states.rb.erb
|