ffaker 1.10.1 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -76,8 +76,14 @@ $ cat scripts/benchmark.rb
76
76
  * kichiro (https://github.com/kichiro)
77
77
  * doctorbh (https://github.com/doctorbh)
78
78
 
79
+ * See complete list: https://github.com/EmmanuelOga/ffaker/network
80
+
79
81
  == Changelog
80
82
 
83
+ * 1.11.0
84
+
85
+ Extraction of AddressUK and AddressUS classes. (Thanks doctorbh).
86
+
81
87
  * 1.10.1
82
88
 
83
89
  Added Faker::AddressCA (Thanks doctorbh, https://github.com/EmmanuelOga/ffaker/pull/27)
data/ffaker.gemspec CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.rubygems_version = '1.3.5'
6
6
 
7
7
  s.name = 'ffaker'
8
- s.version = '1.10.1'
9
- s.date = '2011-11-11'
8
+ s.version = '1.11.0'
9
+ s.date = '2012-01-03'
10
10
  s.rubyforge_project = 'ffaker'
11
11
 
12
12
  s.summary = "Faster Faker, generates dummy data."
@@ -32,6 +32,8 @@ Gem::Specification.new do |s|
32
32
  lib/ffaker/address.rb
33
33
  lib/ffaker/address_ca.rb
34
34
  lib/ffaker/address_de.rb
35
+ lib/ffaker/address_uk.rb
36
+ lib/ffaker/address_us.rb
35
37
  lib/ffaker/company.rb
36
38
  lib/ffaker/education.rb
37
39
  lib/ffaker/geolocation.rb
@@ -58,6 +60,8 @@ Gem::Specification.new do |s|
58
60
  test/test_address.rb
59
61
  test/test_address_ca.rb
60
62
  test/test_address_de.rb
63
+ test/test_address_uk.rb
64
+ test/test_address_us.rb
61
65
  test/test_array_utils.rb
62
66
  test/test_company.rb
63
67
  test/test_faker.rb
data/lib/ffaker.rb CHANGED
@@ -1,29 +1,34 @@
1
1
  module Faker
2
- VERSION = "1.10.1"
2
+ VERSION = "1.11.0"
3
3
 
4
+ require 'ffaker/utils/array_utils'
4
5
  require 'ffaker/utils/module_utils'
5
6
 
6
7
  extend ModuleUtils
7
8
 
8
- LETTERS = k('a'..'z')
9
+ LETTERS = k('a'..'z')
9
10
 
10
- def self.numerify(number_string)
11
- number_string.gsub!(/#/) { rand(10).to_s }
12
- number_string
11
+ def self.numerify(*masks)
12
+ mask = ArrayUtils.rand(masks.flatten)
13
+ mask.gsub!(/#/) { rand(10).to_s }
14
+ mask
13
15
  end
14
16
 
15
- def self.letterify(letter_string)
16
- letter_string.gsub!(/\?/) { LETTERS.rand }
17
- letter_string
17
+ def self.letterify(*masks)
18
+ mask = ArrayUtils.rand(masks.flatten)
19
+ mask.gsub!(/\?/) { LETTERS.rand }
20
+ mask
18
21
  end
19
22
 
20
- def self.bothify(string)
21
- letterify(numerify(string))
23
+ def self.bothify(masks)
24
+ letterify(numerify(masks))
22
25
  end
23
26
 
24
27
  autoload :Address, 'ffaker/address'
28
+ autoload :AddressUS, 'ffaker/address_us'
25
29
  autoload :AddressDE, 'ffaker/address_de'
26
30
  autoload :AddressCA, 'ffaker/address_ca'
31
+ autoload :AddressUK, 'ffaker/address_uk'
27
32
  autoload :Company, 'ffaker/company'
28
33
  autoload :Education, 'ffaker/education'
29
34
  autoload :Geolocation, 'ffaker/geolocation'
@@ -3,17 +3,22 @@ module Faker
3
3
  extend ModuleUtils
4
4
  extend self
5
5
 
6
+ # @deprecated US specific address info. Moved into {AddressUS}
6
7
  def zip_code
7
- Faker.numerify ZIP_FORMATS.rand
8
+ warn '[zip_code] is deprecated. For US addresses please use the AddressUS module'
9
+ Faker::AddressUS.zip_code
8
10
  end
9
11
 
10
12
  def us_state
11
- STATE.rand
13
+ warn '[us_state] is deprecated. For US addresses please use the AddressUS module'
14
+ Faker::AddressUS.state
12
15
  end
13
16
 
14
17
  def us_state_abbr
15
- STATE_ABBR.rand
18
+ warn '[state_abbr] is deprecated. For US addresses please use the AddressUS module'
19
+ Faker::AddressUS.state_abbr
16
20
  end
21
+ # end US deprecation
17
22
 
18
23
  def city_prefix
19
24
  CITY_PREFIXES.rand
@@ -54,42 +59,31 @@ module Faker
54
59
  Faker.numerify(SEC_ADDR.rand)
55
60
  end
56
61
 
62
+ # @deprecated UK specific address info. Moved into {AddressUK}
57
63
  # UK Variants
58
64
  def uk_county
59
- UK_COUNTY.rand
65
+ warn '[uk_county] is deprecated. For UK addresses please use the AddressUK module'
66
+ Faker::AddressUK.county
60
67
  end
61
68
 
62
69
  def uk_country
63
- UK_COUNTRY.rand
70
+ warn '[uk_country] is deprecated. For UK addresses please use the AddressUK module'
71
+ Faker::AddressUK.country
64
72
  end
65
73
 
66
74
  def uk_postcode
67
- Faker.bothify(UK_POSTCODE.rand).upcase
75
+ warn '[uk_postcode] is deprecated. For UK addresses please use the AddressUK module'
76
+ Faker::AddressUK.postcode
68
77
  end
69
-
78
+ # end UK deprecation
79
+
70
80
  def neighborhood
71
81
  NEIGHBORHOOD.rand
72
82
  end
73
83
 
74
- ZIP_FORMATS = k ['#####', '#####-####']
75
-
76
- STATE = k ['Alabama', 'Alaska', 'Arizona', 'Arkansas',
77
- 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida',
78
- 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas',
79
- 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts',
80
- 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana',
81
- 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York',
82
- 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon',
83
- 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota',
84
- 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington',
85
- 'West Virginia', 'Wisconsin', 'Wyoming']
86
-
87
- STATE_ABBR = k %w(AL AK AS AZ AR CA CO CT DE DC FM FL GA GU HI ID IL IN IA
88
- KS KY LA ME MH MD MA MI MN MS MO MT NE NV NH NJ NM NY NC
89
- ND MP OH OK OR PW PA PR RI SC SD TN TX UT VT VI VA WA WV
90
- WI WY AE AA AP)
91
84
 
92
85
  COMPASS_DIRECTIONS = k %w(North East West South)
86
+
93
87
  CITY_PREFIXES = k(COMPASS_DIRECTIONS + %w(New Lake Port))
94
88
 
95
89
  CITY_SUFFIXES = k %w(town ton land ville berg burgh borough bury view port
@@ -119,26 +113,6 @@ module Faker
119
113
 
120
114
  SEC_ADDR = k ['Apt. ###', 'Suite ###']
121
115
 
122
- UK_COUNTY = k ['Avon', 'Bedfordshire', 'Berkshire', 'Borders',
123
- 'Buckinghamshire', 'Cambridgeshire', 'Central', 'Cheshire', 'Cleveland',
124
- 'Clwyd', 'Cornwall', 'County Antrim', 'County Armagh', 'County Down',
125
- 'County Fermanagh', 'County Londonderry', 'County Tyrone', 'Cumbria',
126
- 'Derbyshire', 'Devon', 'Dorset', 'Dumfries and Galloway', 'Durham',
127
- 'Dyfed', 'East Sussex', 'Essex', 'Fife', 'Gloucestershire', 'Grampian',
128
- 'Greater Manchester', 'Gwent', 'Gwynedd County', 'Hampshire',
129
- 'Herefordshire', 'Hertfordshire', 'Highlands and Islands', 'Humberside',
130
- 'Isle of Wight', 'Kent', 'Lancashire', 'Leicestershire', 'Lincolnshire',
131
- 'Lothian', 'Merseyside', 'Mid Glamorgan', 'Norfolk', 'North Yorkshire',
132
- 'Northamptonshire', 'Northumberland', 'Nottinghamshire', 'Oxfordshire',
133
- 'Powys', 'Rutland', 'Shropshire', 'Somerset', 'South Glamorgan',
134
- 'South Yorkshire', 'Staffordshire', 'Strathclyde', 'Suffolk', 'Surrey',
135
- 'Tayside', 'Tyne and Wear', 'Warwickshire', 'West Glamorgan', 'West Midlands',
136
- 'West Sussex', 'West Yorkshire', 'Wiltshire', 'Worcestershire']
137
-
138
- UK_COUNTRY = k ['England', 'Scotland', 'Wales', 'Northern Ireland']
139
-
140
- UK_POSTCODE = k ['??# #??', '??## #??']
141
-
142
116
  NEIGHBORHOOD = k ['East of Telegraph Road', 'North Norridge', 'Northwest Midlothian/Midlothian Country Club',
143
117
  'Mott Haven/Port Morris', 'Kingsbridge Heights', 'Bronxdale', 'Pennypack', 'Bridesburg',
144
118
  'Allegheny West', 'Bushwick South', 'Dyker Heights', 'Ocean Parkway South', 'Summerlin North',
@@ -0,0 +1,39 @@
1
+ module Faker
2
+ module AddressUK
3
+ include Faker::Address
4
+ extend ModuleUtils
5
+ extend self
6
+
7
+ def county
8
+ UK_COUNTY.rand
9
+ end
10
+
11
+ def country
12
+ UK_COUNTRY.rand
13
+ end
14
+
15
+ def postcode
16
+ Faker.bothify(UK_POSTCODE.rand).upcase
17
+ end
18
+
19
+ UK_COUNTY = k ['Avon', 'Bedfordshire', 'Berkshire', 'Borders',
20
+ 'Buckinghamshire', 'Cambridgeshire', 'Central', 'Cheshire', 'Cleveland',
21
+ 'Clwyd', 'Cornwall', 'County Antrim', 'County Armagh', 'County Down',
22
+ 'County Fermanagh', 'County Londonderry', 'County Tyrone', 'Cumbria',
23
+ 'Derbyshire', 'Devon', 'Dorset', 'Dumfries and Galloway', 'Durham',
24
+ 'Dyfed', 'East Sussex', 'Essex', 'Fife', 'Gloucestershire', 'Grampian',
25
+ 'Greater Manchester', 'Gwent', 'Gwynedd County', 'Hampshire',
26
+ 'Herefordshire', 'Hertfordshire', 'Highlands and Islands', 'Humberside',
27
+ 'Isle of Wight', 'Kent', 'Lancashire', 'Leicestershire', 'Lincolnshire',
28
+ 'Lothian', 'Merseyside', 'Mid Glamorgan', 'Norfolk', 'North Yorkshire',
29
+ 'Northamptonshire', 'Northumberland', 'Nottinghamshire', 'Oxfordshire',
30
+ 'Powys', 'Rutland', 'Shropshire', 'Somerset', 'South Glamorgan',
31
+ 'South Yorkshire', 'Staffordshire', 'Strathclyde', 'Suffolk', 'Surrey',
32
+ 'Tayside', 'Tyne and Wear', 'Warwickshire', 'West Glamorgan', 'West Midlands',
33
+ 'West Sussex', 'West Yorkshire', 'Wiltshire', 'Worcestershire']
34
+
35
+ UK_COUNTRY = k ['England', 'Scotland', 'Wales', 'Northern Ireland']
36
+
37
+ UK_POSTCODE = k ['??# #??', '??## #??']
38
+ end
39
+ end
@@ -0,0 +1,37 @@
1
+ module Faker
2
+ module AddressUS
3
+ include Faker::Address
4
+ extend ModuleUtils
5
+ extend self
6
+
7
+ def zip_code
8
+ Faker.numerify ZIP_FORMATS.rand
9
+ end
10
+
11
+ def state
12
+ STATE.rand
13
+ end
14
+
15
+ def state_abbr
16
+ STATE_ABBR.rand
17
+ end
18
+
19
+ ZIP_FORMATS = k ['#####', '#####-####']
20
+
21
+ STATE = k ['Alabama', 'Alaska', 'Arizona', 'Arkansas',
22
+ 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida',
23
+ 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas',
24
+ 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts',
25
+ 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana',
26
+ 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York',
27
+ 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon',
28
+ 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota',
29
+ 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington',
30
+ 'West Virginia', 'Wisconsin', 'Wyoming']
31
+
32
+ STATE_ABBR = k %w(AL AK AS AZ AR CA CO CT DE DC FM FL GA GU HI ID IL IN IA
33
+ KS KY LA ME MH MD MA MI MN MS MO MT NE NV NH NJ NM NY NC
34
+ ND MP OH OK OR PW PA PR RI SC SD TN TX UT VT VI VA WA WV
35
+ WI WY AE AA AP)
36
+ end
37
+ end
@@ -2,10 +2,14 @@ require 'helper'
2
2
 
3
3
  class TestAddressDE < Test::Unit::TestCase
4
4
  def test_city
5
- assert_match /[ a-z]+/, Faker::Address.city
5
+ assert_match /[ a-z]+/, Faker::AddressDE.city
6
6
  end
7
7
 
8
8
  def test_state
9
- assert_match /[ a-z]/, Faker::Address.us_state
9
+ assert_match /[ a-z]/, Faker::AddressDE.state
10
+ end
11
+
12
+ def test_zip_code
13
+ assert_match /^\d{5}$/, Faker::AddressDE.zip_code
10
14
  end
11
15
  end
@@ -0,0 +1,15 @@
1
+ require 'helper'
2
+
3
+ class TestAddressUK < Test::Unit::TestCase
4
+ def test_county
5
+ assert_match /[ a-z]/, Faker::AddressUK.county
6
+ end
7
+
8
+ def test_country
9
+ assert_match /[ a-z]/, Faker::AddressUK.country
10
+ end
11
+
12
+ def test_postcode
13
+ assert_match /^[A-Z]{2}\d \d[A-Z]{2}|[A-Z]{2}\d\d \d[A-Z]{2}$/, Faker::AddressUK.postcode
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ require 'helper'
2
+
3
+ class TestAddressUSUS < Test::Unit::TestCase
4
+ def test_us_state
5
+ assert_match /[ a-z]/, Faker::AddressUS.state
6
+ end
7
+
8
+ def test_us_state_abbr
9
+ assert_match /[A-Z]/, Faker::AddressUS.state_abbr
10
+ end
11
+
12
+ def test_zip_code
13
+ assert_match /[0-9]/, Faker::AddressUS.zip_code
14
+ end
15
+
16
+ def test_zip_code_frozen
17
+ assert Faker::AddressUS.zip_code.frozen? == false
18
+ end
19
+ end
data/test/test_faker.rb CHANGED
@@ -4,12 +4,24 @@ class TestFaker < Test::Unit::TestCase
4
4
  def test_numerify
5
5
  assert Faker.numerify('###').match(/\d{3}/)
6
6
  end
7
+
8
+ def test_numerify_with_array
9
+ assert Faker.numerify(['###', '###']).match(/\d{3}/)
10
+ end
7
11
 
8
12
  def test_letterify
9
13
  assert Faker.letterify('???').match(/[a-z]{3}/)
10
14
  end
11
15
 
16
+ def test_letterify_with_array
17
+ assert Faker.letterify(['???', '???']).match(/[a-z]{3}/)
18
+ end
19
+
12
20
  def test_bothify
13
21
  assert Faker.bothify('???###').match(/[a-z]{3}\d{3}/)
14
22
  end
23
+
24
+ def test_bothify
25
+ assert Faker.bothify(['???###', '???###']).match(/[a-z]{3}\d{3}/)
26
+ end
15
27
  end
metadata CHANGED
@@ -1,33 +1,24 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ffaker
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 10
8
- - 1
9
- version: 1.10.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.11.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Emmanuel Oga
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-11-11 00:00:00 -03:00
18
- default_executable:
12
+ date: 2012-01-03 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: Faster Faker, generates dummy data.
22
15
  email: EmmanuelOga@gmail.com
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
- extra_rdoc_files:
18
+ extra_rdoc_files:
28
19
  - README.rdoc
29
20
  - LICENSE
30
- files:
21
+ files:
31
22
  - History.txt
32
23
  - LICENSE
33
24
  - README.rdoc
@@ -37,6 +28,8 @@ files:
37
28
  - lib/ffaker/address.rb
38
29
  - lib/ffaker/address_ca.rb
39
30
  - lib/ffaker/address_de.rb
31
+ - lib/ffaker/address_uk.rb
32
+ - lib/ffaker/address_us.rb
40
33
  - lib/ffaker/company.rb
41
34
  - lib/ffaker/education.rb
42
35
  - lib/ffaker/geolocation.rb
@@ -63,6 +56,8 @@ files:
63
56
  - test/test_address.rb
64
57
  - test/test_address_ca.rb
65
58
  - test/test_address_de.rb
59
+ - test/test_address_uk.rb
60
+ - test/test_address_us.rb
66
61
  - test/test_array_utils.rb
67
62
  - test/test_company.rb
68
63
  - test/test_faker.rb
@@ -81,42 +76,37 @@ files:
81
76
  - test/test_module_utils.rb
82
77
  - test/test_phone_number.rb
83
78
  - test/test_phone_number_sn.rb
84
- has_rdoc: true
85
79
  homepage: http://github.com/emmanueloga/ffaker
86
80
  licenses: []
87
-
88
81
  post_install_message:
89
- rdoc_options:
82
+ rdoc_options:
90
83
  - --charset=UTF-8
91
- require_paths:
84
+ require_paths:
92
85
  - lib
93
- required_ruby_version: !ruby/object:Gem::Requirement
86
+ required_ruby_version: !ruby/object:Gem::Requirement
94
87
  none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- segments:
99
- - 0
100
- version: "0"
101
- required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
93
  none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- segments:
107
- - 0
108
- version: "0"
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
109
98
  requirements: []
110
-
111
99
  rubyforge_project: ffaker
112
- rubygems_version: 1.3.7
100
+ rubygems_version: 1.8.11
113
101
  signing_key:
114
102
  specification_version: 2
115
103
  summary: Faster Faker, generates dummy data.
116
- test_files:
104
+ test_files:
117
105
  - test/test_address.rb
118
106
  - test/test_address_ca.rb
119
107
  - test/test_address_de.rb
108
+ - test/test_address_uk.rb
109
+ - test/test_address_us.rb
120
110
  - test/test_array_utils.rb
121
111
  - test/test_company.rb
122
112
  - test/test_faker.rb