faker 0.1.0 → 0.3.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.
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestFakerInternet < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @tester = Faker::Internet
7
+ end
8
+
9
+ def test_email
10
+ assert @tester.email.match(/.+@.+\.\w+/)
11
+ end
12
+
13
+ def test_free_email
14
+ assert @tester.free_email.match(/.+@(gmail|hotmail|yahoo)\.com/)
15
+ end
16
+
17
+ def test_user_name
18
+ assert @tester.user_name.match(/[a-z]+((_|\.)[a-z]+)?/)
19
+ end
20
+
21
+ def test_user_name_with_arg
22
+ assert @tester.user_name('bo peep').match(/(bo(_|\.)peep|peep(_|\.)bo)/)
23
+ end
24
+
25
+ def test_domain_name
26
+ assert @tester.domain_name.match(/\w+\.\w+/)
27
+ end
28
+
29
+ def test_domain_word
30
+ assert @tester.domain_word.match(/^\w+$/)
31
+ end
32
+
33
+ def test_domain_suffix
34
+ assert @tester.domain_suffix.match(/^\w+(\.\w+)?/)
35
+ end
36
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestFakerName < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @tester = Faker::Name
7
+ end
8
+
9
+ def test_name
10
+ assert @tester.name.match(/(\w+\.? ?){2,3}/)
11
+ end
12
+
13
+ def test_prefix
14
+ assert @tester.prefix.match(/[A-Z][a-z]+\.?/)
15
+ end
16
+
17
+ def test_suffix
18
+ assert @tester.suffix.match(/[A-Z][a-z]*\.?/)
19
+ end
20
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- platform: ""
4
+ version: 0.3.1
5
+ platform: ruby
6
6
  authors:
7
7
  - Benjamin Curtis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2007-11-22 00:00:00 -08:00
12
+ date: 2008-04-03 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -24,7 +24,6 @@ extra_rdoc_files:
24
24
  - License.txt
25
25
  - Manifest.txt
26
26
  - README.txt
27
- - website/index.txt
28
27
  files:
29
28
  - History.txt
30
29
  - License.txt
@@ -33,11 +32,14 @@ files:
33
32
  - Rakefile
34
33
  - config/hoe.rb
35
34
  - config/requirements.rb
36
- - lib/facets/random.rb
35
+ - faker.tmproj
36
+ - lib/extensions/array.rb
37
+ - lib/extensions/object.rb
37
38
  - lib/faker.rb
38
39
  - lib/faker/address.rb
39
40
  - lib/faker/company.rb
40
41
  - lib/faker/internet.rb
42
+ - lib/faker/lorem.rb
41
43
  - lib/faker/name.rb
42
44
  - lib/faker/phone_number.rb
43
45
  - lib/faker/version.rb
@@ -49,12 +51,9 @@ files:
49
51
  - tasks/environment.rake
50
52
  - tasks/website.rake
51
53
  - test/test_faker.rb
54
+ - test/test_faker_internet.rb
55
+ - test/test_faker_name.rb
52
56
  - test/test_helper.rb
53
- - website/index.html
54
- - website/index.txt
55
- - website/javascripts/rounded_corners_lite.inc.js
56
- - website/stylesheets/screen.css
57
- - website/template.rhtml
58
57
  has_rdoc: true
59
58
  homepage: http://faker.rubyforge.org
60
59
  post_install_message:
@@ -78,10 +77,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
77
  requirements: []
79
78
 
80
79
  rubyforge_project: faker
81
- rubygems_version: 0.9.5
80
+ rubygems_version: 1.1.0
82
81
  signing_key:
83
82
  specification_version: 2
84
83
  summary: A port of Perl's Data::Faker - Generates fake names, phone numbers, etc.
85
84
  test_files:
86
85
  - test/test_faker.rb
86
+ - test/test_faker_internet.rb
87
+ - test/test_faker_name.rb
87
88
  - test/test_helper.rb
data/lib/facets/random.rb DELETED
@@ -1,224 +0,0 @@
1
- # TITLE:
2
- #
3
- # Random
4
- #
5
- # DESCRIPTION:
6
- #
7
- # Randomization methods.
8
- #
9
- # COPYRIGHT:
10
- #
11
- # Copyright (c) 2005 Ilmari Heikkinen, Christian Neukirchen, Thomas Sawyer
12
- #
13
- # LICENSE:
14
- #
15
- # Ruby License
16
- #
17
- # This module is free software. You may use, modify, and/or redistribute this
18
- # software under the same terms as Ruby.
19
- #
20
- # This program is distributed in the hope that it will be useful, but WITHOUT
21
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22
- # FOR A PARTICULAR PURPOSE.
23
- #
24
- # AUTHORS:
25
- #
26
- # - Ilmari Heikkinen <mailto:kig@misfiring.net>
27
- # - Christian Neukirchen <mailto:chneukirchen@gmail.com>
28
- # - Thomas Sawyer
29
-
30
- # Modifications to Kernal, Hash, and String have been removed for Faker
31
-
32
-
33
- class Array
34
-
35
- # Return a random element of the array.
36
- #
37
- # [1, 2, 3, 4].at_rand #=> 2
38
- # [1, 2, 3, 4].at_rand #=> 4
39
- #
40
- def at_rand
41
- self.at( rand( size ) )
42
- end
43
-
44
- # Same as #at_rand, but acts in place removing a
45
- # random element from the array.
46
- #
47
- # a = [1,2,3,4]
48
- # a.at_rand! #=> 2
49
- # a #=> [1,3,4]
50
- #
51
- def at_rand!
52
- return delete_at( Kernel.rand( size ) )
53
- end
54
-
55
- # Similar to #at_rand, but will return an array of randomly
56
- # picked exclusive elements if given a number.
57
- def pick(n=nil)
58
- if n
59
- a = self.dup
60
- a.pick!(n)
61
- else
62
- at( Kernel.rand( size ) )
63
- end
64
- end
65
-
66
- # Similar to #at_rand!, but given a number will return
67
- # an array of exclusive elements.
68
- def pick!(n=nil)
69
- if n
70
- if n > self.size
71
- r = self.dup
72
- self.replace([])
73
- r
74
- else
75
- r = []
76
- n.times { r << delete_at( Kernel.rand( size ) ) }
77
- r
78
- end
79
- else
80
- delete_at( Kernel.rand( size ) )
81
- end
82
- end
83
-
84
- # Random index.
85
- #
86
- def rand_index
87
- rand( size )
88
- end
89
-
90
- # Returns a random subset of an Array. If a _number_
91
- # of elements is specified then returns that number of
92
- # elements, otherwise returns a random number of elements
93
- # upto the size of the Array.
94
- #
95
- # By defualt the returned values are exclusive of
96
- # each other, but if _exclusive_ is set to <tt>false</tt>,
97
- # the same values can be choosen more than once.
98
- #
99
- # When _exclusive_ is <tt>true</tt> (the default) and the
100
- # _number_ given is greater than the size of the array,
101
- # then all values are returned.
102
- #
103
- # [1, 2, 3, 4].rand_subset(1) #=> [2]
104
- # [1, 2, 3, 4].rand_subset(4) #=> [2, 1, 3, 4]
105
- # [1, 2, 3, 4].rand_subset #=> [1, 3, 4]
106
- # [1, 2, 3, 4].rand_subset #=> [2, 3]
107
- #
108
- def rand_subset( number=nil, exclusive=true )
109
- number = rand( size ) unless number
110
- number = number.to_int
111
- #return self.dup if (number >= size and exlusive)
112
- return sort_by{rand}.slice(0,number) if exclusive
113
- ri =[]; number.times { |n| ri << rand( size ) }
114
- return values_at(*ri)
115
- end
116
-
117
- # Randomize the order of an array.
118
- #
119
- # [1,2,3,4].shuffle #=> [2,4,1,3]
120
- #
121
- def shuffle
122
- dup.shuffle!
123
- #sort_by{Kernel.rand}
124
- end
125
-
126
- # CREDIT Niel Spring
127
-
128
- # As with #shuffle but modifies the array in place.
129
- # The algorithm used here is known as a Fisher-Yates shuffle.
130
- #
131
- # a = [1,2,3,4]
132
- # a.shuffle!
133
- # a #=> [2,4,1,3]
134
- #
135
- def shuffle!
136
- s = size
137
- each_index do |j|
138
- i = Kernel.rand(s-j)
139
- #self[j], self[j+i] = self[j+i], self[j]
140
- tmp = self[j]
141
- self[j] = self[j+i]
142
- self[j+i] = tmp
143
- end
144
- self
145
- end
146
-
147
- end
148
-
149
-
150
-
151
-
152
-
153
- # _____ _
154
- # |_ _|__ ___| |_
155
- # | |/ _ \/ __| __|
156
- # | | __/\__ \ |_
157
- # |_|\___||___/\__|
158
- #
159
- =begin test
160
-
161
- require 'test/unit'
162
-
163
- class TestArrayRandom < Test::Unit::TestCase
164
-
165
- def test_at_rand
166
- a = [1,2,3,4,5]
167
- 20.times{ assert_nothing_raised{ a.at_rand } }
168
- 20.times{ assert( a.include?( a.at_rand ) ) }
169
- end
170
-
171
- def test_at_rand!
172
- a = ['a','b','c']
173
- assert_equal( 1, a.at_rand!.length )
174
- assert_equal( 2, a.length )
175
- end
176
-
177
- def test_pick
178
- a = ['a','b','c']
179
- assert_equal( 3, a.pick(3).length )
180
- assert_equal( 3, a.length )
181
- a = ['a','b','c']
182
- assert_equal( 3, a.pick(4).length )
183
- assert_equal( 3, a.length )
184
- end
185
-
186
- def test_pick!
187
- a = ['a','b','c']
188
- assert_equal( 3, a.pick!(3).length )
189
- assert_equal( 0, a.length )
190
- a = ['a','b','c']
191
- assert_equal( 3, a.pick!(4).length )
192
- assert_equal( 0, a.length )
193
- end
194
-
195
- def test_rand_index
196
- 10.times {
197
- i = [1,2,3].rand_index
198
- assert( (0..2).include?(i) )
199
- }
200
- end
201
-
202
- def test_rand_subset
203
- 10.times {
204
- a = [1,2,3,4].rand_subset
205
- assert( a.size <= 4 )
206
- }
207
- end
208
-
209
- def test_shuffle
210
- a = [1,2,3,4,5]
211
- b = a.shuffle
212
- assert_equal( a, b.sort )
213
- end
214
-
215
- def test_shuffle!
216
- a = [1,2,3,4,5]
217
- b = a.dup
218
- b.shuffle!
219
- assert_equal( a, b.sort )
220
- end
221
-
222
- end
223
-
224
- =end
data/website/index.html DELETED
@@ -1,90 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
6
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
- <title>
8
- faker
9
- </title>
10
- <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
11
- <style>
12
-
13
- </style>
14
- <script type="text/javascript">
15
- window.onload = function() {
16
- settings = {
17
- tl: { radius: 10 },
18
- tr: { radius: 10 },
19
- bl: { radius: 10 },
20
- br: { radius: 10 },
21
- antiAlias: true,
22
- autoPad: true,
23
- validTags: ["div"]
24
- }
25
- var versionBox = new curvyCorners(settings, document.getElementById("version"));
26
- versionBox.applyCornersToAll();
27
- }
28
- </script>
29
- </head>
30
- <body>
31
- <div id="main">
32
-
33
- <h1>faker</h1>
34
- <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/faker"; return false'>
35
- <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/faker" class="numbers">0.1.0</a>
37
- </div>
38
- <h2>What</h2>
39
-
40
-
41
- <p>Faker, a port of Data::Faker from Perl, is used to easily generate fake data: names, addresses, phone numbers, etc. The port was motivated by a need for a bunch of fake data to make good-looking screenshots for <a href="http://catchthebest.com">Catch the Best</a>. :)</p>
42
-
43
-
44
- <h2>Installing</h2>
45
-
46
-
47
- <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">faker</span></pre></p>
48
-
49
-
50
- <h2>Usage</h2>
51
-
52
-
53
- <p>Faker::Name.name #=&gt; &#8220;Bob Hope&#8221;</p>
54
-
55
-
56
- <h2>Forum</h2>
57
-
58
-
59
- <p><a href="http://groups.google.com/group/ruby-faker">http://groups.google.com/group/ruby-faker</a></p>
60
-
61
-
62
- <h2>How to submit patches</h2>
63
-
64
-
65
- <p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
66
-
67
-
68
- <p>The trunk repository is <code>svn://rubyforge.org/var/svn/faker/trunk</code> for anonymous access.</p>
69
-
70
-
71
- <h2>License</h2>
72
-
73
-
74
- <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
75
-
76
-
77
- <h2>Contact</h2>
78
-
79
-
80
- <p>Comments are welcome. Send an email to Benjamin Curtis via the <a href="http://groups.google.com/group/ruby-faker">forum</a></p>
81
- <p class="coda">
82
- <a href="http://www.bencurtis.com/">Benjamin Curtis</a>, 22nd November 2007<br>
83
- Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
84
- </p>
85
- </div>
86
-
87
- <!-- insert site tracking codes here, like Google Urchin -->
88
-
89
- </body>
90
- </html>
data/website/index.txt DELETED
@@ -1,33 +0,0 @@
1
- h1. faker
2
-
3
- h2. What
4
-
5
- Faker, a port of Data::Faker from Perl, is used to easily generate fake data: names, addresses, phone numbers, etc. The port was motivated by a need for a bunch of fake data to make good-looking screenshots for "Catch the Best":http://catchthebest.com. :)
6
-
7
- h2. Installing
8
-
9
- <pre syntax="ruby">sudo gem install faker</pre>
10
-
11
- h2. Usage
12
-
13
- Faker::Name.name #=> "Bob Hope"
14
-
15
- h2. Forum
16
-
17
- "http://groups.google.com/group/ruby-faker":http://groups.google.com/group/ruby-faker
18
-
19
-
20
- h2. How to submit patches
21
-
22
- Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
23
-
24
- The trunk repository is <code>svn://rubyforge.org/var/svn/faker/trunk</code> for anonymous access.
25
-
26
- h2. License
27
-
28
- This code is free to use under the terms of the MIT license.
29
-
30
- h2. Contact
31
-
32
- Comments are welcome. Send an email to Benjamin Curtis via the "forum":http://groups.google.com/group/ruby-faker
33
-