specstar-support-random 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. data/lib/specstar/support/random.rb +22 -2
  2. metadata +2 -2
@@ -20,14 +20,34 @@ def random_time
20
20
  Time.at rand Time.now.to_i
21
21
  end
22
22
 
23
- def random_url
23
+ def random_domain
24
24
  tld = ["com", "org", "net", "biz", "info", "co", "co.in"].sample
25
- domain = (0..rand(3)).map { random_text.downcase }.join(".")
25
+ domain = (0..rand(3)).map { random_text(:max_length => 12).downcase }.join(".")
26
26
  scheme = ["http", "https"].sample
27
27
 
28
28
  "#{scheme}://#{domain}.#{tld}"
29
29
  end
30
30
 
31
+ def random_query
32
+ params = {}
33
+
34
+ (0..rand(10)).each { params[random_text :max_length => 8] = random_text }
35
+
36
+ params.to_param
37
+ end
38
+
39
+ def random_url(options={})
40
+ uri = if options.include? :domain
41
+ URI("#{['http', 'https'].sample}://#{options.delete(:domain)}")
42
+ else
43
+ URI(random_domain)
44
+ end
45
+ uri.path = "/#{random_text.downcase}"
46
+ uri.query = random_query
47
+
48
+ uri.to_s
49
+ end
50
+
31
51
  def random_exception
32
52
  begin
33
53
  raise random_string
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.1
4
+ version: 0.0.2
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: 2012-10-29 00:00:00.000000000 Z
12
+ date: 2012-10-31 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: sujoyg@gmail.com