random_data 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ desc 'Release the website and new gem version'
2
+ task :deploy => [:check_version, :website, :release] do
3
+ puts "Remember to create SVN tag:"
4
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
5
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
6
+ puts "Suggested comment:"
7
+ puts "Tagging release #{CHANGES}"
8
+ end
9
+
10
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
11
+ task :local_deploy => [:website_generate, :install_gem]
12
+
13
+ task :check_version do
14
+ unless ENV['VERSION']
15
+ puts 'Must pass a VERSION=x.y.z release version'
16
+ exit
17
+ end
18
+ unless ENV['VERSION'] == VERS
19
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
20
+ exit
21
+ end
22
+ end
23
+
24
+ desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
25
+ task :install_gem_no_doc => [:clean, :package] do
26
+ sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
27
+ end
@@ -0,0 +1,7 @@
1
+ task :ruby_env do
2
+ RUBY_APP = if RUBY_PLATFORM =~ /java/
3
+ "jruby"
4
+ else
5
+ "ruby"
6
+ end unless defined? RUBY_APP
7
+ end
@@ -0,0 +1,9 @@
1
+ # stubs for the website generation
2
+ # To install the website framework:
3
+ # script/generate website
4
+
5
+ task :website_generate
6
+
7
+ task :website_upload
8
+
9
+ task :website => :publish_docs
@@ -0,0 +1,4 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'mocha'
4
+ require File.dirname(__FILE__) + '/../lib/random_data'
@@ -0,0 +1,89 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestRandomData < Test::Unit::TestCase
4
+
5
+ def setup
6
+ # to make random numbers deterministic for testing purposes
7
+ srand(100)
8
+ end
9
+
10
+ def test_should_return_random_phone_number
11
+ assert_equal "620-892-9039", Random.phone
12
+ end
13
+
14
+ def test_should_return_random_international_phone
15
+ assert_equal "011-9-34-9039", Random.international_phone
16
+ end
17
+
18
+ def test_should_return_random_email
19
+ assert_equal "jwalker@webmail.com", Random.email
20
+ end
21
+
22
+ def test_should_return_random_date
23
+ Date.expects(:today).returns(Date.civil(2007,9,15))
24
+ assert_equal "2007-09-13", Random.date.to_s
25
+ end
26
+
27
+ def test_should_return_random_date_with_range
28
+ Date.expects(:today).returns(Date.civil(2007,9,15))
29
+ assert_equal "2007-10-29", Random.date(1500).to_s
30
+ end
31
+
32
+ def test_should_return_random_address_line_1
33
+ assert_equal "38408 Virginia Blvd", Random.address_line_1
34
+ end
35
+
36
+ def test_should_return_random_address_line_2
37
+ assert_equal "Lot 792", Random.address_line_2
38
+ end
39
+
40
+ def test_should_return_random_zipcode
41
+ assert_equal 48408, Random.zipcode
42
+ end
43
+
44
+ def test_should_return_random_state
45
+ assert_equal "DE", Random.state
46
+ end
47
+
48
+ def test_should_return_random_state_full
49
+ assert_equal "Delaware", Random.state_full
50
+ end
51
+
52
+ def test_should_return_random_country
53
+ assert_equal "Armenia", Random.country
54
+ end
55
+
56
+ def test_should_return_random_city
57
+ assert_equal "Georgetown", Random.city
58
+ end
59
+
60
+ def test_should_return_random_firstname
61
+ assert_equal "Joseph", Random.firstname
62
+ end
63
+
64
+ def test_should_return_random_initial
65
+ assert_equal "J", Random.initial
66
+ end
67
+
68
+ def test_should_return_random_lastname
69
+ assert_equal "Moore", Random.lastname
70
+ end
71
+
72
+ def test_should_return_random_alphanumeric
73
+ assert_equal "8O3dNFmAUqYr2YEY", Random.alphanumeric
74
+ end
75
+
76
+ def test_should_return_random_alphanumeric_with_range
77
+ assert_equal "8O3dNFm", Random.alphanumeric(7)
78
+ end
79
+
80
+ def test_should_return_random_paragraphs
81
+ assert_equal 2, Random.paragraphs(2).scan(/\n\n/).size
82
+ end
83
+
84
+ def test_should_return_random_paragraphs_with_limit
85
+ num_paragraphs = 5
86
+ assert_equal num_paragraphs, Random.paragraphs(num_paragraphs).scan(/\n\n/).size
87
+ end
88
+
89
+ end
@@ -0,0 +1,228 @@
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
+ random_data
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>random_data</h1>
34
+ <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/random_data"; return false'>
35
+ <p>Get Version</p>
36
+ <a href="http://rubyforge.org/projects/random_data" class="numbers">1.0.0</a>
37
+ </div>
38
+ <h2>What</h2>
39
+
40
+
41
+ <p>This plugin defines a Random singleton class that has a bunch of class methods to quickly generate random test for testing and developmental use.</p>
42
+
43
+
44
+ <h3>Contact Methods</h3>
45
+
46
+
47
+ <p>Random.phone, Random.international_phone, Random.email</p>
48
+
49
+
50
+ <h3>Time/Date Methods</h3>
51
+
52
+
53
+ <p>Random.date</p>
54
+
55
+
56
+ <h3>Location Methods</h3>
57
+
58
+
59
+ <p>Random.address_line_1, Random.address_line_2, Random.zipcode, Random.state, Random.country, Random.city,</p>
60
+
61
+
62
+ <h3>Name Methods</h3>
63
+
64
+
65
+ <p>Random.firstname, Random.initial, Random.lastname,</p>
66
+
67
+
68
+ <h3>Text Methods</h3>
69
+
70
+
71
+ <p>Random.alphanumeric, Random.paragraphs</p>
72
+
73
+
74
+ <p>Note that some methods take parameters to bound or limit the amount of data returned. See RDocs for details.</p>
75
+
76
+
77
+ <h2>Installing</h2>
78
+
79
+
80
+ <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">random_data</span></pre></p>
81
+
82
+
83
+ <p><pre class='syntax'><span class="ident">require</span> <span class="punct">'</span><span class="string">random_data</span><span class="punct">'</span></pre></p>
84
+
85
+
86
+ <h2>Demonstration of usage</h2>
87
+
88
+
89
+ <p><pre class='syntax'>
90
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">alphanumeric</span>
91
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">cfbutm3vYfhZXil0</span><span class="punct">&quot;</span>
92
+ </pre></p>
93
+
94
+
95
+ <p><pre class='syntax'>
96
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">alphanumeric</span><span class="punct">(</span><span class="number">5</span><span class="punct">)</span>
97
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">XYVyn</span><span class="punct">&quot;</span>
98
+ </pre></p>
99
+
100
+
101
+ <p><pre class='syntax'>
102
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">paragraphs</span>
103
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Ulysses, fighting evil and tyranny with all his power and with all of his might. Ulysses, fighting evil and tyranny with all his power and with all of his
104
+ might. <span class="escape">\n\n</span>He's got style, a groovy style, and a car that just won't stop. <span class="escape">\n\n</span></span><span class="punct">&quot;</span>
105
+ </pre></p>
106
+
107
+
108
+ <p><pre class='syntax'>
109
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">paragraphs</span><span class="punct">(</span><span class="number">3</span><span class="punct">)</span>
110
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum. Down the road that's where I'll always be. He's got style, a groovy style, and a car that just won't stop. I've gotten burned over Cheryl Tiegs and blown up for Raquel Welch, but when I end up in the hay it's only hay hey hey. Hey there where ya goin, not exactly knowin'. <span class="escape">\n\n</span>Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. I might jump an open drawbridge or Tarzan from a vine, beause I'm the unknown stuntman that makes Eastwood look so fine. He just keeps on movin' and ladies keep improvin'. Rolling down to Dallas - who is providin my palace?. Every stop I make I make a new friend; Can't stay for long just turn around and I'm gone again. <span class="escape">\n\n</span>Always fighting all the evil forces bringing peace and justice to all. <span class="escape">\n\n</span></span><span class="punct">&quot;</span>
111
+ </pre></p>
112
+
113
+
114
+ <p><pre class='syntax'>
115
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">firstname</span>
116
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Thomas</span><span class="punct">&quot;</span>
117
+ </pre></p>
118
+
119
+
120
+ <p><pre class='syntax'>
121
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">initial</span>
122
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">E</span><span class="punct">&quot;</span>
123
+ </pre></p>
124
+
125
+
126
+ <p><pre class='syntax'>
127
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">lastname</span>
128
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Robinson</span><span class="punct">&quot;</span>
129
+ </pre></p>
130
+
131
+
132
+ <p><pre class='syntax'>
133
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">date</span>
134
+ <span class="punct">=&gt;</span> <span class="constant">Sun</span><span class="punct">,</span> <span class="number">09</span> <span class="constant">Sep</span> <span class="number">2007</span>
135
+ </pre></p>
136
+
137
+
138
+ <p><pre class='syntax'>
139
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">date</span><span class="punct">(</span><span class="number">1000</span><span class="punct">)</span>
140
+ <span class="punct">=&gt;</span> <span class="constant">Sun</span><span class="punct">,</span> <span class="number">26</span> <span class="constant">Nov</span> <span class="number">2006</span>
141
+ </pre></p>
142
+
143
+
144
+ <p><pre class='syntax'>
145
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">email</span>
146
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">zrodriguez@example.com</span><span class="punct">&quot;</span>
147
+ </pre></p>
148
+
149
+
150
+ <p><pre class='syntax'>
151
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">phone</span>
152
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">564-103-8353</span><span class="punct">&quot;</span>
153
+ </pre></p>
154
+
155
+
156
+ <p><pre class='syntax'>
157
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">international_phone</span>
158
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">011-24-37-9704</span><span class="punct">&quot;</span>
159
+ </pre></p>
160
+
161
+
162
+ <p><pre class='syntax'>
163
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">address_line_1</span>
164
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">38367 Adams Rd</span><span class="punct">&quot;</span>
165
+ </pre></p>
166
+
167
+
168
+ <p><pre class='syntax'>
169
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">address_line_2</span>
170
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Lot 247</span><span class="punct">&quot;</span>
171
+ </pre></p>
172
+
173
+
174
+ <p><pre class='syntax'>
175
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">zipcode</span>
176
+ <span class="punct">=&gt;</span> <span class="number">22904</span>
177
+ <span class="punct">(</span><span class="ident">note</span> <span class="ident">that</span> <span class="ident">the</span> <span class="ident">zipcodes</span> <span class="ident">are</span> <span class="ident">totally</span> <span class="ident">random</span> <span class="keyword">and</span> <span class="ident">may</span> <span class="keyword">not</span> <span class="ident">be</span> <span class="ident">real</span> <span class="ident">zipcodes</span><span class="punct">)</span>
178
+ </pre></p>
179
+
180
+
181
+ <p><pre class='syntax'>
182
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">state</span>
183
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">MD</span><span class="punct">&quot;</span>
184
+ </pre></p>
185
+
186
+
187
+ <p><pre class='syntax'>
188
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">state_full</span>
189
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">New Mexico</span><span class="punct">&quot;</span>
190
+ </pre></p>
191
+
192
+
193
+ <p><pre class='syntax'>
194
+ <span class="punct">&gt;&gt;</span> <span class="constant">Random</span><span class="punct">.</span><span class="ident">country</span>
195
+ <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">Philippines</span><span class="punct">&quot;</span>
196
+ </pre></p>
197
+
198
+
199
+ <h2>How to submit patches</h2>
200
+
201
+
202
+ <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 e-mail the patch to me
203
+ at <a href="mailto:mike@subelsky.com">mike@subelsky.com</a>.</p>
204
+
205
+
206
+ <p>The trunk repository is <code>svn://rubyforge.org/var/svn/random_data/trunk</code> for anonymous access.</p>
207
+
208
+
209
+ <h2>License</h2>
210
+
211
+
212
+ <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
213
+
214
+
215
+ <h2>Contact</h2>
216
+
217
+
218
+ <p>Comments are welcome. Send an email to <a href="mailto:mike@subelsky.com">mike@subelsky.com</a></p>
219
+ <p class="coda">
220
+ <a href="http://www.subelsky.com/">Mike Subelsky</a>, 20th September 2007<br>
221
+ Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
222
+ </p>
223
+ </div>
224
+
225
+ <!-- insert site tracking codes here, like Google Urchin -->
226
+
227
+ </body>
228
+ </html>
data/website/index.txt ADDED
@@ -0,0 +1,143 @@
1
+ h1. random_data
2
+
3
+ h2. What
4
+
5
+ This plugin defines a Random singleton class that has a bunch of class methods to quickly generate random test for testing and developmental use.
6
+
7
+ h3. Contact Methods
8
+
9
+ Random.phone, Random.international_phone, Random.email
10
+
11
+ h3. Time/Date Methods
12
+
13
+ Random.date
14
+
15
+ h3. Location Methods
16
+
17
+ Random.address_line_1, Random.address_line_2, Random.zipcode, Random.state, Random.country, Random.city,
18
+
19
+ h3. Name Methods
20
+
21
+ Random.firstname, Random.initial, Random.lastname,
22
+
23
+ h3. Text Methods
24
+
25
+ Random.alphanumeric, Random.paragraphs
26
+
27
+ Note that some methods take parameters to bound or limit the amount of data returned. See RDocs for details.
28
+
29
+ h2. Installing
30
+
31
+ <pre syntax="ruby">sudo gem install random_data</pre>
32
+
33
+ <pre syntax="ruby">require 'random_data'</pre>
34
+
35
+ h2. Demonstration of usage
36
+
37
+ <pre syntax="ruby">
38
+ >> Random.alphanumeric
39
+ => "cfbutm3vYfhZXil0"
40
+ </pre>
41
+
42
+ <pre syntax="ruby">
43
+ >> Random.alphanumeric(5)
44
+ => "XYVyn"
45
+ </pre>
46
+
47
+ <pre class='wide' syntax="ruby">
48
+ >> Random.paragraphs
49
+ => "Ulysses, fighting evil and tyranny with all his power and with all of his might. Ulysses, fighting evil and tyranny with all his power and with all of his
50
+ might. \n\nHe's got style, a groovy style, and a car that just won't stop. \n\n"
51
+ </pre>
52
+
53
+ <pre.wide syntax="ruby">
54
+ >> Random.paragraphs(3)
55
+ => "Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum. Down the road that's where I'll always be. He's got style, a groovy style, and a car that just won't stop. I've gotten burned over Cheryl Tiegs and blown up for Raquel Welch, but when I end up in the hay it's only hay hey hey. Hey there where ya goin, not exactly knowin'. \n\nLorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. I might jump an open drawbridge or Tarzan from a vine, beause I'm the unknown stuntman that makes Eastwood look so fine. He just keeps on movin' and ladies keep improvin'. Rolling down to Dallas - who is providin my palace?. Every stop I make I make a new friend; Can't stay for long just turn around and I'm gone again. \n\nAlways fighting all the evil forces bringing peace and justice to all. \n\n"
56
+ </pre>
57
+
58
+ <pre syntax="ruby">
59
+ >> Random.firstname
60
+ => "Thomas"
61
+ </pre>
62
+
63
+ <pre syntax="ruby">
64
+ >> Random.initial
65
+ => "E"
66
+ </pre>
67
+
68
+ <pre syntax="ruby">
69
+ >> Random.lastname
70
+ => "Robinson"
71
+ </pre>
72
+
73
+ <pre syntax="ruby">
74
+ >> Random.date
75
+ => Sun, 09 Sep 2007
76
+ </pre>
77
+
78
+ <pre syntax="ruby">
79
+ >> Random.date(1000)
80
+ => Sun, 26 Nov 2006
81
+ </pre>
82
+
83
+ <pre syntax="ruby">
84
+ >> Random.email
85
+ => "zrodriguez@example.com"
86
+ </pre>
87
+
88
+ <pre syntax="ruby">
89
+ >> Random.phone
90
+ => "564-103-8353"
91
+ </pre>
92
+
93
+ <pre syntax="ruby">
94
+ >> Random.international_phone
95
+ => "011-24-37-9704"
96
+ </pre>
97
+
98
+ <pre syntax="ruby">
99
+ >> Random.address_line_1
100
+ => "38367 Adams Rd"
101
+ </pre>
102
+
103
+ <pre syntax="ruby">
104
+ >> Random.address_line_2
105
+ => "Lot 247"
106
+ </pre>
107
+
108
+ <pre syntax="ruby">
109
+ >> Random.zipcode
110
+ => 22904
111
+ (note that the zipcodes are totally random and may not be real zipcodes)
112
+ </pre>
113
+
114
+ <pre syntax="ruby">
115
+ >> Random.state
116
+ => "MD"
117
+ </pre>
118
+
119
+ <pre syntax="ruby">
120
+ >> Random.state_full
121
+ => "New Mexico"
122
+ </pre>
123
+
124
+ <pre syntax="ruby">
125
+ >> Random.country
126
+ => "Philippines"
127
+ </pre>
128
+
129
+ h2. How to submit patches
130
+
131
+ Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and e-mail the patch to me
132
+ at "mike@subelsky.com":mailto:mike@subelsky.com.
133
+
134
+ The trunk repository is <code>svn://rubyforge.org/var/svn/random_data/trunk</code> for anonymous access.
135
+
136
+ h2. License
137
+
138
+ This code is free to use under the terms of the MIT license.
139
+
140
+ h2. Contact
141
+
142
+ Comments are welcome. Send an email to "mike@subelsky.com":mailto:mike@subelsky.com
143
+