specstar-support-random 0.0.8 → 0.0.9
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/lib/specstar/support/random.rb +30 -22
- metadata +2 -2
@@ -1,7 +1,37 @@
|
|
1
|
+
def random_domain
|
2
|
+
tld = ["com", "org", "net", "biz", "info", "co", "co.in"].sample
|
3
|
+
domain = (0..rand(3)).map { random_text(:max_length => 12).downcase }.join(".")
|
4
|
+
|
5
|
+
"#{domain}.#{tld}"
|
6
|
+
end
|
7
|
+
|
1
8
|
def random_email
|
2
9
|
"#{random_text}@#{random_text}.com".downcase
|
3
10
|
end
|
4
11
|
|
12
|
+
def random_exception
|
13
|
+
begin
|
14
|
+
raise random_text
|
15
|
+
rescue => e
|
16
|
+
e
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def random_hash(options={})
|
21
|
+
hash = {}
|
22
|
+
elements = options[:length] || 1 + rand(options[:max_length] || 10)
|
23
|
+
elements.times { hash[random_text.to_sym] = random_text }
|
24
|
+
hash
|
25
|
+
end
|
26
|
+
|
27
|
+
def random_query
|
28
|
+
params = {}
|
29
|
+
|
30
|
+
(0..rand(10)).each { params[random_text :max_length => 8] = random_text }
|
31
|
+
|
32
|
+
params.to_param
|
33
|
+
end
|
34
|
+
|
5
35
|
def random_text(options={})
|
6
36
|
length = if options[:length]
|
7
37
|
options[:length]
|
@@ -20,21 +50,6 @@ def random_time
|
|
20
50
|
Time.at rand Time.now.to_i
|
21
51
|
end
|
22
52
|
|
23
|
-
def random_domain
|
24
|
-
tld = ["com", "org", "net", "biz", "info", "co", "co.in"].sample
|
25
|
-
domain = (0..rand(3)).map { random_text(:max_length => 12).downcase }.join(".")
|
26
|
-
|
27
|
-
"#{domain}.#{tld}"
|
28
|
-
end
|
29
|
-
|
30
|
-
def random_query
|
31
|
-
params = {}
|
32
|
-
|
33
|
-
(0..rand(10)).each { params[random_text :max_length => 8] = random_text }
|
34
|
-
|
35
|
-
params.to_param
|
36
|
-
end
|
37
|
-
|
38
53
|
def random_url(options={})
|
39
54
|
domain = options.include?(:domain) ? options[:domain] : random_domain
|
40
55
|
scheme = options.include?(:scheme) ? options[:scheme] : ['http', 'https'].sample
|
@@ -48,10 +63,3 @@ def random_url(options={})
|
|
48
63
|
uri.to_s
|
49
64
|
end
|
50
65
|
|
51
|
-
def random_exception
|
52
|
-
begin
|
53
|
-
raise random_text
|
54
|
-
rescue => e
|
55
|
-
e
|
56
|
-
end
|
57
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specstar-support-random
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
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-
|
12
|
+
date: 2013-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: sujoyg@gmail.com
|