data_seeder 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ {
2
+ key_attribute: 'code',
3
+ line: ->(line) {
4
+ { code: line[0,2], name: line[3...-1] }
5
+ }
6
+ }
@@ -0,0 +1,249 @@
1
+ # This file is configured in the Country model
2
+ AD Andorra
3
+ AE United Arab Emirates
4
+ AF Afghanistan
5
+ AG Antigua and Barbuda
6
+ AI Anguilla
7
+ AL Albania
8
+ AM Armenia
9
+ AO Angola
10
+ AQ Antarctica
11
+ AR Argentina
12
+ AS American Samoa
13
+ AT Austria
14
+ AU Australia
15
+ AW Aruba
16
+ AX Åland Islands
17
+ AZ Azerbaijan
18
+ BA Bosnia and Herzegovina
19
+ BB Barbados
20
+ BD Bangladesh
21
+ BE Belgium
22
+ BF Burkina Faso
23
+ BG Bulgaria
24
+ BH Bahrain
25
+ BI Burundi
26
+ BJ Benin
27
+ BL Saint Barthélemy
28
+ BM Bermuda
29
+ BN Brunei Darussalam
30
+ BO Bolivia, Plurinational State of
31
+ BQ Bonaire, Sint Eustatius and Saba
32
+ BR Brazil
33
+ BS Bahamas
34
+ BT Bhutan
35
+ BV Bouvet Island
36
+ BW Botswana
37
+ BY Belarus
38
+ BZ Belize
39
+ CA Canada
40
+ CC Cocos (Keeling) Islands
41
+ CD Congo, the Democratic Republic of the
42
+ CF Central African Republic
43
+ CG Congo
44
+ CH Switzerland
45
+ CI Côte d'Ivoire
46
+ CK Cook Islands
47
+ CL Chile
48
+ CM Cameroon
49
+ CN China
50
+ CO Colombia
51
+ CR Costa Rica
52
+ CU Cuba
53
+ CV Cape Verde
54
+ CW Curaçao
55
+ CX Christmas Island
56
+ CY Cyprus
57
+ CZ Czech Republic
58
+ DE Germany
59
+ DJ Djibouti
60
+ DK Denmark
61
+ DM Dominica
62
+ DO Dominican Republic
63
+ DZ Algeria
64
+ EC Ecuador
65
+ EE Estonia
66
+ EG Egypt
67
+ EH Western Sahara
68
+ ER Eritrea
69
+ ES Spain
70
+ ET Ethiopia
71
+ FI Finland
72
+ FJ Fiji
73
+ FK Falkland Islands (Malvinas)
74
+ FM Micronesia, Federated States of
75
+ FO Faroe Islands
76
+ FR France
77
+ GA Gabon
78
+ GB United Kingdom
79
+ GD Grenada
80
+ GE Georgia
81
+ GF French Guiana
82
+ GG Guernsey
83
+ GH Ghana
84
+ GI Gibraltar
85
+ GL Greenland
86
+ GM Gambia
87
+ GN Guinea
88
+ GP Guadeloupe
89
+ GQ Equatorial Guinea
90
+ GR Greece
91
+ GS South Georgia and the South Sandwich Islands
92
+ GT Guatemala
93
+ GU Guam
94
+ GW Guinea-Bissau
95
+ GY Guyana
96
+ HK Hong Kong
97
+ HM Heard Island and McDonald Islands
98
+ HN Honduras
99
+ HR Croatia
100
+ HT Haiti
101
+ HU Hungary
102
+ ID Indonesia
103
+ IE Ireland
104
+ IL Israel
105
+ IM Isle of Man
106
+ IN India
107
+ IO British Indian Ocean Territory
108
+ IQ Iraq
109
+ IR Iran, Islamic Republic of
110
+ IS Iceland
111
+ IT Italy
112
+ JE Jersey
113
+ JM Jamaica
114
+ JO Jordan
115
+ JP Japan
116
+ KE Kenya
117
+ KG Kyrgyzstan
118
+ KH Cambodia
119
+ KI Kiribati
120
+ KM Comoros
121
+ KN Saint Kitts and Nevis
122
+ KP Korea, Democratic People's Republic of
123
+ KR Korea, Republic of
124
+ KW Kuwait
125
+ KY Cayman Islands
126
+ KZ Kazakhstan
127
+ LA Lao People's Democratic Republic
128
+ LB Lebanon
129
+ LC Saint Lucia
130
+ LI Liechtenstein
131
+ LK Sri Lanka
132
+ LR Liberia
133
+ LS Lesotho
134
+ LT Lithuania
135
+ LU Luxembourg
136
+ LV Latvia
137
+ LY Libya
138
+ MA Morocco
139
+ MC Monaco
140
+ MD Moldova, Republic of
141
+ ME Montenegro
142
+ MF Saint Martin (French part)
143
+ MG Madagascar
144
+ MH Marshall Islands
145
+ MK Macedonia, the former Yugoslav Republic of
146
+ ML Mali
147
+ MM Myanmar
148
+ MN Mongolia
149
+ MO Macao
150
+ MP Northern Mariana Islands
151
+ MQ Martinique
152
+ MR Mauritania
153
+ MS Montserrat
154
+ MT Malta
155
+ MU Mauritius
156
+ MV Maldives
157
+ MW Malawi
158
+ MX Mexico
159
+ MY Malaysia
160
+ MZ Mozambique
161
+ NA Namibia
162
+ NC New Caledonia
163
+ NE Niger
164
+ NF Norfolk Island
165
+ NG Nigeria
166
+ NI Nicaragua
167
+ NL Netherlands
168
+ NO Norway
169
+ NP Nepal
170
+ NR Nauru
171
+ NU Niue
172
+ NZ New Zealand
173
+ OM Oman
174
+ PA Panama
175
+ PE Peru
176
+ PF French Polynesia
177
+ PG Papua New Guinea
178
+ PH Philippines
179
+ PK Pakistan
180
+ PL Poland
181
+ PM Saint Pierre and Miquelon
182
+ PN Pitcairn
183
+ PR Puerto Rico
184
+ PS Palestine, State of
185
+ PT Portugal
186
+ PW Palau
187
+ PY Paraguay
188
+ QA Qatar
189
+ RE Réunion
190
+ RO Romania
191
+ RS Serbia
192
+ RU Russian Federation
193
+ RW Rwanda
194
+ SA Saudi Arabia
195
+ SB Solomon Islands
196
+ SC Seychelles
197
+ SD Sudan
198
+ SE Sweden
199
+ SG Singapore
200
+ SH Saint Helena, Ascension and Tristan da Cunha
201
+ SI Slovenia
202
+ SJ Svalbard and Jan Mayen
203
+ SK Slovakia
204
+ SL Sierra Leone
205
+ SM San Marino
206
+ SN Senegal
207
+ SO Somalia
208
+ SR Suriname
209
+ SS South Sudan
210
+ ST Sao Tome and Principe
211
+ SV El Salvador
212
+ SX Sint Maarten (Dutch part)
213
+ SY Syrian Arab Republic
214
+ SZ Swaziland
215
+ TC Turks and Caicos Islands
216
+ TD Chad
217
+ TF French Southern Territories
218
+ TG Togo
219
+ TH Thailand
220
+ TJ Tajikistan
221
+ TK Tokelau
222
+ TL Timor-Leste
223
+ TM Turkmenistan
224
+ TN Tunisia
225
+ TO Tonga
226
+ TR Turkey
227
+ TT Trinidad and Tobago
228
+ TV Tuvalu
229
+ TW Taiwan, Province of China
230
+ TZ Tanzania, United Republic of
231
+ UA Ukraine
232
+ UG Uganda
233
+ UM United States Minor Outlying Islands
234
+ US United States
235
+ UY Uruguay
236
+ UZ Uzbekistan
237
+ VA Holy See (Vatican City State)
238
+ VC Saint Vincent and the Grenadines
239
+ VE Venezuela, Bolivarian Republic of
240
+ VG Virgin Islands, British
241
+ VI Virgin Islands, U.S.
242
+ VN Viet Nam
243
+ VU Vanuatu
244
+ WF Wallis and Futuna
245
+ WS Samoa
246
+ YE Yemen
247
+ YT Mayotte
248
+ ZA South Africa
249
+ ZM Zambia
@@ -0,0 +1,6 @@
1
+ {
2
+ key_attribute: 'code',
3
+ line: ->(line) {
4
+ { code: line[0,2], name: line[3...-1] }
5
+ }
6
+ }
@@ -21,13 +21,17 @@ describe DataSeeder, :model do
21
21
  assert_equal 'Kentucky', State.find_by(code: 'KV').try(:name)
22
22
  assert_equal 'Vermount', State.find_by(code: 'VT').try(:name)
23
23
  modify_seed_file(@name, 'states_txt/states.txt') do |body|
24
- body.sub('KV Kentucky', 'KY Kentucky').sub('VT Vermount', 'VT Vermont')
24
+ body.sub('KV Kentucky', 'KY Kentucky').
25
+ sub('VT Vermount', 'VT Vermont').
26
+ sub("TX Texas\n", '')
25
27
  end
26
28
  DataSeeder.run
27
- assert_equal 50, State.count
29
+ assert_equal 49, State.count
28
30
  assert_equal 'Kentucky', State.find_by(code: 'KY').try(:name)
29
31
  assert_equal 'Vermont', State.find_by(code: 'VT').try(:name)
30
32
  assert_nil State.find_by(code: 'KV')
33
+ # Oh no! Texas seceded
34
+ assert_nil State.find_by(code: 'TX')
31
35
  end
32
36
  end
33
37
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_seeder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Pardee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-16 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -85,6 +85,10 @@ files:
85
85
  - test/dummy/db/test.sqlite3
86
86
  - test/dummy/log/development.log
87
87
  - test/dummy/log/test.log
88
+ - test/dummy/tmp/db.seed.test.txt.20720/countries_txt/countries.cfg
89
+ - test/dummy/tmp/db.seed.test.txt.20720/countries_txt/countries.txt
90
+ - test/dummy/tmp/db.seed.test.txt.20720/states_txt/states.cfg
91
+ - test/dummy/tmp/db.seed.test.txt.20720/states_txt/states.txt
88
92
  - test/dummy/tmp/db.seed.test.use_line_number_as_id.5816/states.cfg
89
93
  - test/dummy/tmp/db.seed.test.use_line_number_as_id.5816/states.csv
90
94
  - test/dummy/tmp/db.seed.test.use_line_number_as_id.5907/states.cfg
@@ -161,6 +165,10 @@ test_files:
161
165
  - test/dummy/log/development.log
162
166
  - test/dummy/log/test.log
163
167
  - test/dummy/Rakefile
168
+ - test/dummy/tmp/db.seed.test.txt.20720/countries_txt/countries.cfg
169
+ - test/dummy/tmp/db.seed.test.txt.20720/countries_txt/countries.txt
170
+ - test/dummy/tmp/db.seed.test.txt.20720/states_txt/states.cfg
171
+ - test/dummy/tmp/db.seed.test.txt.20720/states_txt/states.txt
164
172
  - test/dummy/tmp/db.seed.test.use_line_number_as_id.5816/states.cfg
165
173
  - test/dummy/tmp/db.seed.test.use_line_number_as_id.5816/states.csv
166
174
  - test/dummy/tmp/db.seed.test.use_line_number_as_id.5907/states.cfg