mannequin 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -43,6 +43,17 @@ Currently the following test data classes and attributes have been implemented:
43
43
  * `middle_initial` *(ex. A)*
44
44
  * `email_address` *(ex. john@doe.com)*
45
45
 
46
+ * `Mannequin::Address`
47
+
48
+ * `street_address` *(ex. 123 Maple St)*
49
+ * `street_number` *(ex. 123)*
50
+ * `street_name` *(ex. Maple)*
51
+ * `street_type` *(ex. St)*
52
+ * `city` *(ex. New York City)*
53
+ * `state` *(ex. New York)*
54
+ * `state_code` *(ex. NY)*
55
+ * `country` *(ex. United States)*
56
+
46
57
  ## Contributing
47
58
 
48
59
  1. Fork it
@@ -0,0 +1,362 @@
1
+ module Mannequin
2
+ class Address
3
+ attr_reader :street_address, :street_number, :street_name, :street_type, :city, :state, :state_code, :country
4
+
5
+ def initialize
6
+ # Set variables from functions
7
+ street_number = generated_street_number
8
+ street_name = generated_street_name
9
+ street_type = generated_street_type
10
+ street_address = "#{street_number} #{street_name} #{street_type}"
11
+ city = generated_city
12
+ state = generated_state
13
+ country = generated_country
14
+
15
+ # Initialize attributes
16
+ @street_address = street_address
17
+ @street_number = street_number
18
+ @street_name = street_name
19
+ @street_type = street_type
20
+ @city = city
21
+ @state = state[1]
22
+ @state_code = state[0]
23
+ @country = country
24
+ end
25
+
26
+ private
27
+
28
+ def generated_street_number
29
+ array_of_street_numbers = (1..2000).to_a
30
+ return array_of_street_numbers.sample.to_s
31
+ end
32
+
33
+ def generated_street_name
34
+ array_of_street_names = ["Maple", "Oak", "Poplar", "Cherry", "Dogwood"]
35
+ return array_of_street_names.sample
36
+ end
37
+
38
+ def generated_street_type
39
+ array_of_street_types = ["St", "Rd", "Cir", "Ct", "Way", "Ave"]
40
+ return array_of_street_types.sample
41
+ end
42
+
43
+ def generated_city
44
+ array_of_cities = ["Beijing", "Bogota", "Buenos Aires", "Cairo", "Delhi", "Dhaka", "Guangzhou", "Istanbul", "Jakarta", "Karachi", "Kinshasa", "Kolkata", "Lagos", "Lima", "London", "Los Angeles", "Manila", "Mexico City", "Moscow", "Mumbai", "New York City", "Osaka", "Rio de Janeiro", "Sao Paulo", "Seoul", "Shanghai", "Shenzhen", "Tehran", "Tianjin", "Tokyo"]
45
+ return array_of_cities.sample
46
+ end
47
+
48
+ def generated_state
49
+ # List of states from https://gist.github.com/2991970
50
+ array_of_states = [
51
+ ["AK", "Alaska"],
52
+ ["AL", "Alabama"],
53
+ ["AR", "Arkansas"],
54
+ ["AS", "American Samoa"],
55
+ ["AZ", "Arizona"],
56
+ ["CA", "California"],
57
+ ["CO", "Colorado"],
58
+ ["CT", "Connecticut"],
59
+ ["DC", "District of Columbia"],
60
+ ["DE", "Delaware"],
61
+ ["FL", "Florida"],
62
+ ["GA", "Georgia"],
63
+ ["GU", "Guam"],
64
+ ["HI", "Hawaii"],
65
+ ["IA", "Iowa"],
66
+ ["ID", "Idaho"],
67
+ ["IL", "Illinois"],
68
+ ["IN", "Indiana"],
69
+ ["KS", "Kansas"],
70
+ ["KY", "Kentucky"],
71
+ ["LA", "Louisiana"],
72
+ ["MA", "Massachusetts"],
73
+ ["MD", "Maryland"],
74
+ ["ME", "Maine"],
75
+ ["MI", "Michigan"],
76
+ ["MN", "Minnesota"],
77
+ ["MO", "Missouri"],
78
+ ["MS", "Mississippi"],
79
+ ["MT", "Montana"],
80
+ ["NC", "North Carolina"],
81
+ ["ND", "North Dakota"],
82
+ ["NE", "Nebraska"],
83
+ ["NH", "New Hampshire"],
84
+ ["NJ", "New Jersey"],
85
+ ["NM", "New Mexico"],
86
+ ["NV", "Nevada"],
87
+ ["NY", "New York"],
88
+ ["OH", "Ohio"],
89
+ ["OK", "Oklahoma"],
90
+ ["OR", "Oregon"],
91
+ ["PA", "Pennsylvania"],
92
+ ["PR", "Puerto Rico"],
93
+ ["RI", "Rhode Island"],
94
+ ["SC", "South Carolina"],
95
+ ["SD", "South Dakota"],
96
+ ["TN", "Tennessee"],
97
+ ["TX", "Texas"],
98
+ ["UT", "Utah"],
99
+ ["VA", "Virginia"],
100
+ ["VI", "Virgin Islands"],
101
+ ["VT", "Vermont"],
102
+ ["WA", "Washington"],
103
+ ["WI", "Wisconsin"],
104
+ ["WV", "West Virginia"],
105
+ ["WY", "Wyoming"]
106
+ ]
107
+ return array_of_states.sample
108
+ end
109
+
110
+ def generated_country
111
+ # List of countries from https://gist.github.com/370774
112
+ array_of_countries = [
113
+ "Afghanistan",
114
+ "Aland Islands",
115
+ "Albania",
116
+ "Algeria",
117
+ "American Samoa",
118
+ "Andorra",
119
+ "Angola",
120
+ "Anguilla",
121
+ "Antarctica",
122
+ "Antigua And Barbuda",
123
+ "Argentina",
124
+ "Armenia",
125
+ "Aruba",
126
+ "Australia",
127
+ "Austria",
128
+ "Azerbaijan",
129
+ "Bahamas",
130
+ "Bahrain",
131
+ "Bangladesh",
132
+ "Barbados",
133
+ "Belarus",
134
+ "Belgium",
135
+ "Belize",
136
+ "Benin",
137
+ "Bermuda",
138
+ "Bhutan",
139
+ "Bolivia",
140
+ "Bosnia and Herzegowina",
141
+ "Botswana",
142
+ "Bouvet Island",
143
+ "Brazil",
144
+ "British Indian Ocean Territory",
145
+ "Brunei Darussalam",
146
+ "Bulgaria",
147
+ "Burkina Faso",
148
+ "Burundi",
149
+ "Cambodia",
150
+ "Cameroon",
151
+ "Canada",
152
+ "Cape Verde",
153
+ "Cayman Islands",
154
+ "Central African Republic",
155
+ "Chad",
156
+ "Chile",
157
+ "China",
158
+ "Christmas Island",
159
+ "Cocos (Keeling) Islands",
160
+ "Colombia",
161
+ "Comoros",
162
+ "Congo",
163
+ "Congo, the Democratic Republic of the",
164
+ "Cook Islands",
165
+ "Costa Rica",
166
+ "Cote d'Ivoire",
167
+ "Croatia",
168
+ "Cuba",
169
+ "Cyprus",
170
+ "Czech Republic",
171
+ "Denmark",
172
+ "Djibouti",
173
+ "Dominica",
174
+ "Dominican Republic",
175
+ "Ecuador",
176
+ "Egypt",
177
+ "El Salvador",
178
+ "Equatorial Guinea",
179
+ "Eritrea",
180
+ "Estonia",
181
+ "Ethiopia",
182
+ "Falkland Islands (Malvinas)",
183
+ "Faroe Islands",
184
+ "Fiji",
185
+ "Finland",
186
+ "France",
187
+ "French Guiana",
188
+ "French Polynesia",
189
+ "French Southern Territories",
190
+ "Gabon",
191
+ "Gambia",
192
+ "Georgia",
193
+ "Germany",
194
+ "Ghana",
195
+ "Gibraltar",
196
+ "Greece",
197
+ "Greenland",
198
+ "Grenada",
199
+ "Guadeloupe",
200
+ "Guam",
201
+ "Guatemala",
202
+ "Guernsey",
203
+ "Guinea",
204
+ "Guinea-Bissau",
205
+ "Guyana",
206
+ "Haiti",
207
+ "Heard and McDonald Islands",
208
+ "Holy See (Vatican City State)",
209
+ "Honduras",
210
+ "Hong Kong",
211
+ "Hungary",
212
+ "Iceland",
213
+ "India",
214
+ "Indonesia",
215
+ "Iran, Islamic Republic of",
216
+ "Iraq",
217
+ "Ireland",
218
+ "Isle of Man",
219
+ "Israel",
220
+ "Italy",
221
+ "Jamaica",
222
+ "Japan",
223
+ "Jersey",
224
+ "Jordan",
225
+ "Kazakhstan",
226
+ "Kenya",
227
+ "Kiribati",
228
+ "Korea, Democratic People's Republic of",
229
+ "Korea, Republic of",
230
+ "Kuwait",
231
+ "Kyrgyzstan",
232
+ "Lao People's Democratic Republic",
233
+ "Latvia",
234
+ "Lebanon",
235
+ "Lesotho",
236
+ "Liberia",
237
+ "Libyan Arab Jamahiriya",
238
+ "Liechtenstein",
239
+ "Lithuania",
240
+ "Luxembourg",
241
+ "Macao",
242
+ "Macedonia, The Former Yugoslav Republic Of",
243
+ "Madagascar",
244
+ "Malawi",
245
+ "Malaysia",
246
+ "Maldives",
247
+ "Mali",
248
+ "Malta",
249
+ "Marshall Islands",
250
+ "Martinique",
251
+ "Mauritania",
252
+ "Mauritius",
253
+ "Mayotte",
254
+ "Mexico",
255
+ "Micronesia, Federated States of",
256
+ "Moldova, Republic of",
257
+ "Monaco",
258
+ "Mongolia",
259
+ "Montenegro",
260
+ "Montserrat",
261
+ "Morocco",
262
+ "Mozambique",
263
+ "Myanmar",
264
+ "Namibia",
265
+ "Nauru",
266
+ "Nepal",
267
+ "Netherlands",
268
+ "Netherlands Antilles",
269
+ "New Caledonia",
270
+ "New Zealand",
271
+ "Nicaragua",
272
+ "Niger",
273
+ "Nigeria",
274
+ "Niue",
275
+ "Norfolk Island",
276
+ "Northern Mariana Islands",
277
+ "Norway",
278
+ "Oman",
279
+ "Pakistan",
280
+ "Palau",
281
+ "Palestinian Territory, Occupied",
282
+ "Panama",
283
+ "Papua New Guinea",
284
+ "Paraguay",
285
+ "Peru",
286
+ "Philippines",
287
+ "Pitcairn",
288
+ "Poland",
289
+ "Portugal",
290
+ "Puerto Rico",
291
+ "Qatar",
292
+ "Reunion",
293
+ "Romania",
294
+ "Russian Federation",
295
+ "Rwanda",
296
+ "Saint Barthelemy",
297
+ "Saint Helena",
298
+ "Saint Kitts and Nevis",
299
+ "Saint Lucia",
300
+ "Saint Pierre and Miquelon",
301
+ "Saint Vincent and the Grenadines",
302
+ "Samoa",
303
+ "San Marino",
304
+ "Sao Tome and Principe",
305
+ "Saudi Arabia",
306
+ "Senegal",
307
+ "Serbia",
308
+ "Seychelles",
309
+ "Sierra Leone",
310
+ "Singapore",
311
+ "Slovakia",
312
+ "Slovenia",
313
+ "Solomon Islands",
314
+ "Somalia",
315
+ "South Africa",
316
+ "South Georgia and the South Sandwich Islands",
317
+ "Spain",
318
+ "Sri Lanka",
319
+ "Sudan",
320
+ "Suriname",
321
+ "Svalbard and Jan Mayen",
322
+ "Swaziland",
323
+ "Sweden",
324
+ "Switzerland",
325
+ "Syrian Arab Republic",
326
+ "Taiwan, Province of China",
327
+ "Tajikistan",
328
+ "Tanzania, United Republic of",
329
+ "Thailand",
330
+ "Timor-Leste",
331
+ "Togo",
332
+ "Tokelau",
333
+ "Tonga",
334
+ "Trinidad and Tobago",
335
+ "Tunisia",
336
+ "Turkey",
337
+ "Turkmenistan",
338
+ "Turks and Caicos Islands",
339
+ "Tuvalu",
340
+ "Uganda",
341
+ "Ukraine",
342
+ "United Arab Emirates",
343
+ "United Kingdom",
344
+ "United States",
345
+ "United States Minor Outlying Islands",
346
+ "Uruguay",
347
+ "Uzbekistan",
348
+ "Vanuatu",
349
+ "Venezuela",
350
+ "Viet Nam",
351
+ "Virgin Islands, British",
352
+ "Virgin Islands, U.S.",
353
+ "Wallis and Futuna",
354
+ "Western Sahara",
355
+ "Yemen",
356
+ "Zambia",
357
+ "Zimbabwe"
358
+ ]
359
+ return array_of_countries.sample
360
+ end
361
+ end
362
+ end
@@ -3,11 +3,19 @@ module Mannequin
3
3
  attr_reader :first_name, :middle_name, :middle_initial, :last_name, :email_address
4
4
 
5
5
  def initialize
6
- @first_name = generated_first_name
7
- @middle_name = generated_middle_name
8
- @middle_initial = @middle_name[0,1]
9
- @last_name = generated_last_name
10
- @email_address = "#{@first_name.downcase}@#{@last_name.downcase}.#{['com', 'net', 'org'].sample}"
6
+ # Set variables from functions
7
+ first_name = generated_first_name
8
+ middle_name = generated_middle_name
9
+ middle_initial = middle_name[0,1]
10
+ last_name = generated_last_name
11
+ email_address = "#{first_name.downcase}@#{last_name.downcase}.#{['com', 'net', 'org'].sample}"
12
+
13
+ # Initialize attributes
14
+ @first_name = first_name
15
+ @middle_name = middle_name
16
+ @middle_initial = middle_initial
17
+ @last_name = last_name
18
+ @email_address = email_address
11
19
  end
12
20
 
13
21
  private
@@ -1,3 +1,3 @@
1
1
  module Mannequin
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/mannequin.rb CHANGED
@@ -2,6 +2,7 @@ require "backports"
2
2
 
3
3
  require "mannequin/version"
4
4
  require "mannequin/person"
5
+ require "mannequin/address"
5
6
 
6
7
  module Mannequin
7
8
  # Your code goes here...
@@ -0,0 +1,39 @@
1
+ require 'pathname'
2
+ require Pathname(__FILE__).ascend{|d| h=d+'test_helper.rb'; break h if h.file?}
3
+
4
+ describe Mannequin::Address.new do
5
+ subject { Mannequin::Address.new }
6
+ describe "creating an address" do
7
+ it "must have a street address" do
8
+ subject.must_respond_to(:street_address)
9
+ end
10
+
11
+ it "must have a street number" do
12
+ subject.must_respond_to(:street_number)
13
+ end
14
+
15
+ it "must have a street name" do
16
+ subject.must_respond_to(:street_name)
17
+ end
18
+
19
+ it "must have a street type" do
20
+ subject.must_respond_to(:street_type)
21
+ end
22
+
23
+ it "must have a city" do
24
+ subject.must_respond_to(:city)
25
+ end
26
+
27
+ it "must have a state" do
28
+ subject.must_respond_to(:state)
29
+ end
30
+
31
+ it "must have a state code" do
32
+ subject.must_respond_to(:state_code)
33
+ end
34
+
35
+ it "must have a country" do
36
+ subject.must_respond_to(:country)
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mannequin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-14 00:00:00.000000000 Z
12
+ date: 2013-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -74,9 +74,11 @@ files:
74
74
  - README.md
75
75
  - Rakefile
76
76
  - lib/mannequin.rb
77
+ - lib/mannequin/address.rb
77
78
  - lib/mannequin/person.rb
78
79
  - lib/mannequin/version.rb
79
80
  - mannequin.gemspec
81
+ - test/lib/mannequin/address_test.rb
80
82
  - test/lib/mannequin/person_test.rb
81
83
  - test/lib/mannequin/version_test.rb
82
84
  - test/test_helper.rb
@@ -105,6 +107,7 @@ signing_key:
105
107
  specification_version: 3
106
108
  summary: A simple test data generator
107
109
  test_files:
110
+ - test/lib/mannequin/address_test.rb
108
111
  - test/lib/mannequin/person_test.rb
109
112
  - test/lib/mannequin/version_test.rb
110
113
  - test/test_helper.rb