ffaker 1.9.1 → 1.10.1

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
@@ -74,9 +74,14 @@ $ cat scripts/benchmark.rb
74
74
  * Chris Bloom (https://github.com/chrisbloom7)
75
75
  * SENE (https://github.com/PapePathe)
76
76
  * kichiro (https://github.com/kichiro)
77
+ * doctorbh (https://github.com/doctorbh)
77
78
 
78
79
  == Changelog
79
80
 
81
+ * 1.10.1
82
+
83
+ Added Faker::AddressCA (Thanks doctorbh, https://github.com/EmmanuelOga/ffaker/pull/27)
84
+
80
85
  * 1.9.1
81
86
 
82
87
  Added Faker::NameSN, Faker::PhoneNumberSN (Thanks SENE, https://github.com/EmmanuelOga/ffaker/pull/26)
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.9.1'
9
- s.date = '2011-11-06'
8
+ s.version = '1.10.1'
9
+ s.date = '2011-11-11'
10
10
  s.rubyforge_project = 'ffaker'
11
11
 
12
12
  s.summary = "Faster Faker, generates dummy data."
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  ffaker.gemspec
31
31
  lib/ffaker.rb
32
32
  lib/ffaker/address.rb
33
+ lib/ffaker/address_ca.rb
33
34
  lib/ffaker/address_de.rb
34
35
  lib/ffaker/company.rb
35
36
  lib/ffaker/education.rb
@@ -55,6 +56,7 @@ Gem::Specification.new do |s|
55
56
  scripts/profiling.rb
56
57
  test/helper.rb
57
58
  test/test_address.rb
59
+ test/test_address_ca.rb
58
60
  test/test_address_de.rb
59
61
  test/test_array_utils.rb
60
62
  test/test_company.rb
data/lib/ffaker.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Faker
2
- VERSION = "1.9.1"
2
+ VERSION = "1.10.1"
3
3
 
4
4
  require 'ffaker/utils/module_utils'
5
5
 
@@ -23,6 +23,7 @@ module Faker
23
23
 
24
24
  autoload :Address, 'ffaker/address'
25
25
  autoload :AddressDE, 'ffaker/address_de'
26
+ autoload :AddressCA, 'ffaker/address_ca'
26
27
  autoload :Company, 'ffaker/company'
27
28
  autoload :Education, 'ffaker/education'
28
29
  autoload :Geolocation, 'ffaker/geolocation'
@@ -0,0 +1,30 @@
1
+ module Faker
2
+ module AddressCA
3
+ include Faker::Address
4
+ extend ModuleUtils
5
+ extend self
6
+
7
+ def postal_code
8
+ Faker.bothify(POSTAL_CODE_FORMATS.rand).upcase
9
+ end
10
+
11
+ def province
12
+ PROVINCE.rand
13
+ end
14
+
15
+ def province_abbr
16
+ PROVINCE_ABBRS.rand
17
+ end
18
+
19
+ POSTAL_CODE_FORMATS = k ['?#? #?#']
20
+
21
+ PROVINCE = k [
22
+ 'Newfoundland and Labrador', 'Nova Scotia', 'Prince Edward Island',
23
+ 'New Brunswick', 'Quebec', 'Ontario', 'Manitoba', 'Saskatchewan',
24
+ 'Alberta', 'British Columbia', 'Yukon', 'Northwest Territories',
25
+ 'Nunavut'
26
+ ]
27
+
28
+ PROVINCE_ABBRS = k %w(NL NS PE NB QC ON MB SK AB BC YT NT NU)
29
+ end
30
+ end
data/test/test_address.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'helper'
2
2
 
3
-
4
3
  class TestAddress < Test::Unit::TestCase
5
4
  def test_city
6
5
  assert_match /[ a-z]+/, Faker::Address.city
@@ -0,0 +1,15 @@
1
+ require 'helper'
2
+
3
+ class TestAddressCA < Test::Unit::TestCase
4
+ def test_province
5
+ assert_match /[ a-z]/, Faker::AddressCA.province
6
+ end
7
+
8
+ def test_province_abbr
9
+ assert_match /[A-Z][A-Z]/, Faker::AddressCA.province_abbr
10
+ end
11
+
12
+ def test_postal_code
13
+ assert_match /[A-Z]\d[A-Z]\W\d[A-Z]\d/, Faker::AddressCA.postal_code
14
+ end
15
+ end
@@ -1,6 +1,5 @@
1
1
  require 'helper'
2
2
 
3
-
4
3
  class TestAddressDE < Test::Unit::TestCase
5
4
  def test_city
6
5
  assert_match /[ a-z]+/, Faker::Address.city
@@ -9,5 +8,4 @@ class TestAddressDE < Test::Unit::TestCase
9
8
  def test_state
10
9
  assert_match /[ a-z]/, Faker::Address.us_state
11
10
  end
12
-
13
11
  end
@@ -18,8 +18,7 @@ class TestFakerInternet < Test::Unit::TestCase
18
18
  end
19
19
 
20
20
  def test_disposable_email
21
- assert @tester.disposable_email.match(
22
- /.+@(mailinator\.com|suremail\.info|spamherelots\.com|binkmail\.com|safetymail\.info)/)
21
+ assert @tester.disposable_email.match(/.+@(mailinator\.com|suremail\.info|spamherelots\.com|binkmail\.com|safetymail\.info)/)
23
22
  end
24
23
 
25
24
  def test_user_name
@@ -9,5 +9,4 @@ class TestFakerNameCN < Test::Unit::TestCase
9
9
  def test_name
10
10
  assert Faker::NameCN.name.length > 2
11
11
  end
12
-
13
12
  end
@@ -2,111 +2,94 @@
2
2
  require 'helper'
3
3
 
4
4
  class TestFakerNameSn < Test::Unit::TestCase
5
-
6
5
  def setup
7
6
  @tester = Faker::NameSN
8
7
  end
9
-
8
+
10
9
  def test_last_name
11
10
  assert Faker::NameSN::LAST_NAMES.include?(@tester.last_name)
12
11
  end
13
-
12
+
14
13
  def test_first_name_male
15
14
  assert Faker::NameSN::FIRST_NAMES_MALE.include?(@tester.first_name_male)
16
15
  end
17
-
16
+
18
17
  def test_first_name_female
19
18
  assert Faker::NameSN::FIRST_NAMES_FEMALE.include?(@tester.first_name_female)
20
- end
21
-
22
- def test_prefix_male
19
+ end
20
+
21
+ def test_prefix_male
23
22
  assert Faker::NameSN::PREFIX_MALE.include?(@tester.prefix_male)
24
23
  end
25
-
26
- def test_prefix_female
24
+
25
+ def test_prefix_female
27
26
  assert Faker::NameSN::PREFIX_FEMALE.include?(@tester.prefix_female)
28
27
  end
29
-
28
+
30
29
  def test_name_male
31
-
32
- # => split the name_male into an array of words
30
+ # => split the name_male into an array of words
33
31
  parts = @tester.name_male.split(' ')
34
-
32
+
35
33
  if parts.count == 3
36
-
37
34
  # the value at the index 0 should be a valid! male_prefix
38
35
  assert Faker::NameSN::PREFIX_MALE.include?(parts[0])
39
-
36
+
40
37
  # the value at the index 1 should be a valid! male_first_name
41
38
  assert Faker::NameSN::FIRST_NAMES_MALE.include?(parts[1])
42
-
39
+
43
40
  # the value at the index 2 should be a valid! last_name
44
41
  assert Faker::NameSN::LAST_NAMES.include?(parts[2])
45
-
42
+
46
43
  elsif parts.count == 2
47
44
  # the value at the index 0 should be a valid! male_prefix
48
- assert Faker::NameSN::FIRST_NAMES_MALE.include?(parts[0])
49
-
45
+ assert Faker::NameSN::FIRST_NAMES_MALE.include?(parts[0])
46
+
50
47
  # the value at the index 1 should be a valid! last_name
51
- assert Faker::NameSN::LAST_NAMES.include?(parts[1])
52
-
48
+ assert Faker::NameSN::LAST_NAMES.include?(parts[1])
53
49
  end
54
-
55
50
  end
56
-
51
+
57
52
  def test_name_female
58
-
59
- # => split the name_female into an array of words
53
+ # => split the name_female into an array of words
60
54
  parts = @tester.name_female.split(' ')
61
-
55
+
62
56
  if parts.count == 3
63
-
64
57
  # the value at the index 0 should be a valid! male_prefix
65
58
  assert Faker::NameSN::PREFIX_FEMALE.include?(parts[0])
66
-
59
+
67
60
  # the value at the index 1 should be a valid! male_first_name
68
61
  assert Faker::NameSN::FIRST_NAMES_FEMALE.include?(parts[1])
69
-
62
+
70
63
  # the value at the index 2 should be a valid! last_name
71
64
  assert Faker::NameSN::LAST_NAMES.include?(parts[2])
72
-
73
65
  elsif parts.count == 2
74
66
  # the value at the index 0 should be a valid! male_prefix
75
- assert Faker::NameSN::FIRST_NAMES_FEMALE.include?(parts[0])
76
-
67
+ assert Faker::NameSN::FIRST_NAMES_FEMALE.include?(parts[0])
68
+
77
69
  # the value at the index 1 should be a valid! last_name
78
- assert Faker::NameSN::LAST_NAMES.include?(parts[1])
79
-
70
+ assert Faker::NameSN::LAST_NAMES.include?(parts[1])
80
71
  end
81
-
82
72
  end
83
-
73
+
84
74
  def test_senegalese_name
85
-
86
- # => split the name into an array of words
75
+ # => split the name into an array of words
87
76
  parts = @tester.name_sn.split(' ')
88
-
77
+
89
78
  if parts.count == 3
90
-
91
79
  # the value at the index 0 should be a valid! male or female prefix
92
- assert Faker::NameSN::PREFIX_FEMALE.include?(parts[0]) || Faker::NameSN::PREFIX_MALE.include?(parts[0])
93
-
80
+ assert Faker::NameSN::PREFIX_FEMALE.include?(parts[0]) || Faker::NameSN::PREFIX_MALE.include?(parts[0])
81
+
94
82
  # the value at the index 1 should be a valid! firstname male or female
95
- assert Faker::NameSN::FIRST_NAMES_FEMALE.include?(parts[1]) || Faker::NameSN::FIRST_NAMES_MALE.include?(parts[1])
96
-
83
+ assert Faker::NameSN::FIRST_NAMES_FEMALE.include?(parts[1]) || Faker::NameSN::FIRST_NAMES_MALE.include?(parts[1])
84
+
97
85
  # the value at the index 2 should be a valid! firstname male or female
98
86
  assert Faker::NameSN::LAST_NAMES.include?(parts[2])
99
-
100
-
101
87
  elsif parts.count == 2
102
-
103
88
  # the value at the index 0 should be a valid! firstname male or female
104
- assert Faker::NameSN::FIRST_NAMES_FEMALE.include?(parts[0]) || Faker::NameSN::FIRST_NAMES_MALE.include?(parts[0])
105
-
89
+ assert Faker::NameSN::FIRST_NAMES_FEMALE.include?(parts[0]) || Faker::NameSN::FIRST_NAMES_MALE.include?(parts[0])
90
+
106
91
  # the value at the index 0 should be a valid! firstname male or female
107
92
  assert Faker::NameSN::LAST_NAMES.include?(parts[1])
108
93
  end
109
-
110
94
  end
111
-
112
95
  end
@@ -1,8 +1,6 @@
1
1
  require 'helper'
2
2
 
3
-
4
3
  class TestGeolocation < Test::Unit::TestCase
5
-
6
4
  def test_lat
7
5
  assert_match /[0-9]+/, Faker::Geolocation.lat.to_s
8
6
  end
@@ -10,4 +8,4 @@ class TestGeolocation < Test::Unit::TestCase
10
8
  def test_lng
11
9
  assert_match /[0-9]+/, Faker::Geolocation.lng.to_s
12
10
  end
13
- end
11
+ end
@@ -1,7 +1,6 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestHipsterIpsum < Test::Unit::TestCase
4
-
5
4
  def test_paragraph
6
5
  assert_match /1\+|[ a-z]+/i, Faker::HipsterIpsum.paragraph
7
6
  end
@@ -25,5 +24,4 @@ class TestHipsterIpsum < Test::Unit::TestCase
25
24
  def test_word
26
25
  assert_match /1\+|[a-z]+/i, Faker::HipsterIpsum.word
27
26
  end
28
-
29
27
  end
@@ -8,7 +8,7 @@ class TestHTMLIpsum < Test::Unit::TestCase
8
8
  def test_a
9
9
  assert_match /^<a href="#\w+" title="[ \w]+">[ \w]+<\/a>$/i, Faker::HTMLIpsum.a
10
10
  end
11
-
11
+
12
12
  def test_p
13
13
  # We can't predict the number of times the sentence pattern will repeat
14
14
  # because the Faker::Lorem methods that we are using adds a random
@@ -24,25 +24,25 @@ class TestHTMLIpsum < Test::Unit::TestCase
24
24
  def test_p_fancy
25
25
  # We can't predict the number of times the sentence pattern will repeat
26
26
  # because the Faker::Lorem methods that we are using adds a random
27
- # number on top of what we specify for the count argument. We also have to
27
+ # number on top of what we specify for the count argument. We also have to
28
28
  # account for the other HTML that is being returned.
29
29
  assert_match /^<p>[[:alnum:][:punct:] <>\/]+<\/p>$/i, Faker::HTMLIpsum.p(5, {:fancy => true})
30
30
  end
31
-
31
+
32
32
  def test_p_fancy_breaks
33
- # Here we can at least test how many <br> tags there are. We also have to
33
+ # Here we can at least test how many <br> tags there are. We also have to
34
34
  # account for the other HTML that is being returned.
35
35
  assert_match /^<p>(?:[[:alnum:][:punct:] <>\/]+?<br>){9}[[:alnum:][:punct:] <>\/]+?<\/p>/i, Faker::HTMLIpsum.p(10, {:fancy => true, :include_breaks => true})
36
36
  end
37
-
37
+
38
38
  def test_dl
39
39
  assert_match /^<dl>(<dt>[ \w]+<\/dt><dd>[ \w.]+<\/dd>){3}<\/dl>$/i, Faker::HTMLIpsum.dl(3)
40
40
  end
41
-
41
+
42
42
  def test_ul_short
43
43
  assert_match /^<ul>(<li>[ \w.]+<\/li>){3}<\/ul>$/i, Faker::HTMLIpsum.ul_short(3)
44
44
  end
45
-
45
+
46
46
  def test_ul_long
47
47
  assert_match /^<ul>(<li>[ \w.]+<\/li>){3}<\/ul>$/i, Faker::HTMLIpsum.ul_long(3)
48
48
  end
@@ -50,15 +50,15 @@ class TestHTMLIpsum < Test::Unit::TestCase
50
50
  def test_ol_short
51
51
  assert_match /^<ol>(<li>[ \w.]+<\/li>){3}<\/ol>$/i, Faker::HTMLIpsum.ol_short(3)
52
52
  end
53
-
53
+
54
54
  def test_ol_long
55
55
  assert_match /^<ol>(<li>[ \w.]+<\/li>){3}<\/ol>$/i, Faker::HTMLIpsum.ol_long(3)
56
56
  end
57
-
57
+
58
58
  def test_ul_links
59
59
  assert_match /^<ul>(<li><a href="#\w+" title="\w+">[ \w]+<\/a><\/li>){3}<\/ul>$/i, Faker::HTMLIpsum.ul_links(3)
60
60
  end
61
-
61
+
62
62
  def test_table
63
63
  assert_match /(<td>[ \w]+<\/td>\s*){3}/i, Faker::HTMLIpsum.table(3)
64
64
  end
@@ -68,13 +68,13 @@ class TestHTMLIpsum < Test::Unit::TestCase
68
68
  # that we have a complete string.
69
69
  assert_match /^<h1>.+<\/pre>$/im, Faker::HTMLIpsum.body
70
70
  end
71
-
71
+
72
72
  def test_fancy_string
73
73
  # We can't reliably predict what's going to end up inside, so just ensure
74
74
  # that we have a complete string.
75
75
  assert_match /^[[:alnum:][:punct:] <>\/]+$/im, Faker::HTMLIpsum.fancy_string
76
76
  end
77
-
77
+
78
78
  def test_fancy_string_breaks
79
79
  # We can't reliably predict what's going to end up inside, so just ensure
80
80
  # that we have a complete string.
data/test/test_lorem.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestLorem < Test::Unit::TestCase
4
-
5
4
  def test_paragraph
6
5
  assert_match /[ a-z]+/, Faker::Lorem.paragraph
7
6
  end
@@ -2,7 +2,6 @@
2
2
  require 'helper'
3
3
 
4
4
  class TestLoremCN < Test::Unit::TestCase
5
-
6
5
  def test_paragraph
7
6
  assert Faker::LoremCN.paragraph.length >= 3*4*2
8
7
  end
@@ -14,9 +13,11 @@ class TestLoremCN < Test::Unit::TestCase
14
13
  def test_paragraphs
15
14
  assert Faker::LoremCN.paragraphs.length >= 2
16
15
  end
16
+
17
17
  def test_paragraphs_is_not_a_string_representation_of_an_array
18
18
  assert_not_match /[\[\]]+/, [Faker::LoremCN.paragraphs].flatten.join(' ')
19
19
  end
20
+
20
21
  def test_paragraphs_is_an_array
21
22
  assert Faker::LoremCN.paragraphs.class == Array
22
23
  end
@@ -24,9 +25,11 @@ class TestLoremCN < Test::Unit::TestCase
24
25
  def test_sentences
25
26
  assert Faker::LoremCN.sentences.length >= 2
26
27
  end
28
+
27
29
  def test_sentences_is_an_array
28
30
  assert Faker::LoremCN.sentences.class == Array
29
31
  end
32
+
30
33
  def test_sentences_via_to_s_produces_string_terminated_with_period
31
34
  string = Faker::LoremCN.sentences.to_s
32
35
  assert string.class == String
@@ -3,15 +3,13 @@
3
3
  # => author: xarala
4
4
  # => email: pathe.sene@xarala.sn
5
5
  # => website: http://www.xarala.sn
6
-
7
6
  require 'helper'
8
7
 
9
8
  class TestPhoneNumberSN < Test::Unit::TestCase
10
-
11
9
  def setup
12
10
  @tester = Faker::PhoneNumberSN
13
- end
14
-
11
+ end
12
+
15
13
  def test_mobile_phone_prefix
16
14
  assert Faker::PhoneNumberSN::MobileOperatorsPrefix.include?(@tester.mobile_phone_prefix)
17
15
  end
@@ -19,12 +17,11 @@ class TestPhoneNumberSN < Test::Unit::TestCase
19
17
  def test_homework_phone_prefix
20
18
  assert Faker::PhoneNumberSN::HomeWorkOperatorsPrefix.include?(@tester.homework_phone_prefix)
21
19
  end
22
-
23
-
20
+
24
21
  def test_short_phone_number
25
22
  assert_match /\d{3}-\d{2}-\d{2}/, Faker::PhoneNumberSN.short_phone_number
26
23
  end
27
-
24
+
28
25
  def test_mobile_phone_number
29
26
  assert_match /(70|76|77)-\d{3}-\d{2}-\d{2}/, Faker::PhoneNumberSN.mobile_number
30
27
  end
@@ -32,10 +29,8 @@ class TestPhoneNumberSN < Test::Unit::TestCase
32
29
  def test_phone_number
33
30
  assert_match /(33|70|76|77)-\d{3}-\d{2}-\d{2}/, Faker::PhoneNumberSN.phone_number
34
31
  end
35
-
32
+
36
33
  def test_homework_phone_number
37
34
  assert_match /(33)-(8|9)\d{2}-\d{2}-\d{2}/, Faker::PhoneNumberSN.homework_number
38
35
  end
39
-
40
-
41
36
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 9
7
+ - 10
8
8
  - 1
9
- version: 1.9.1
9
+ version: 1.10.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Emmanuel Oga
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-11-06 00:00:00 -03:00
17
+ date: 2011-11-11 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -35,6 +35,7 @@ files:
35
35
  - ffaker.gemspec
36
36
  - lib/ffaker.rb
37
37
  - lib/ffaker/address.rb
38
+ - lib/ffaker/address_ca.rb
38
39
  - lib/ffaker/address_de.rb
39
40
  - lib/ffaker/company.rb
40
41
  - lib/ffaker/education.rb
@@ -60,6 +61,7 @@ files:
60
61
  - scripts/profiling.rb
61
62
  - test/helper.rb
62
63
  - test/test_address.rb
64
+ - test/test_address_ca.rb
63
65
  - test/test_address_de.rb
64
66
  - test/test_array_utils.rb
65
67
  - test/test_company.rb
@@ -113,6 +115,7 @@ specification_version: 2
113
115
  summary: Faster Faker, generates dummy data.
114
116
  test_files:
115
117
  - test/test_address.rb
118
+ - test/test_address_ca.rb
116
119
  - test/test_address_de.rb
117
120
  - test/test_array_utils.rb
118
121
  - test/test_company.rb