modlr 0.0.4.5.1 → 0.0.5

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.
@@ -1,6 +1,13 @@
1
1
 
2
2
  module Modlr
3
3
  require File.join(File.expand_path(File.dirname(__FILE__)), "modlr", "names")
4
+ require File.join(File.expand_path(File.dirname(__FILE__)), "modlr", "address")
5
+ require File.join(File.expand_path(File.dirname(__FILE__)), "modlr", "ages")
6
+ require File.join(File.expand_path(File.dirname(__FILE__)), "modlr", "email")
7
+ require File.join(File.expand_path(File.dirname(__FILE__)), "modlr", "phone")
8
+
9
+
10
+
4
11
 
5
12
  ##
6
13
  # modlr :class, number_of_records, {:field => :type, :field => type}
@@ -15,13 +22,44 @@ module Modlr
15
22
 
16
23
  end
17
24
 
18
- def self.modlr(model, number, &args)
19
- model.new.is_a?(ActiveRecord::Base)
20
- count = model.count
21
- if count >= number
22
- "No new records created: #{model} currently has #{count} records."
25
+ def self.modlr(model, args = nil)
26
+ args ||= {}
27
+ model.new.is_a?(ActiveRecord::Base)
28
+ count = model.count
29
+ args[:number].nil? ? num = 10 : num = args[:number]
30
+ if count >= num
31
+ "No new records created: #{model} currently has #{count} records."
32
+ else
33
+ unless args.nil?
34
+ params = {}
35
+ args.each do |key, value|
36
+ unless key == :number
37
+ params[key] = value
38
+ end
39
+ end
40
+ #return params
41
+ num.times do
42
+ m = model.new
43
+ params.each do |key, value|
44
+ m[key] = case value
45
+ when :name
46
+ Name.rand_name
47
+ when :adult
48
+ Age.adult
49
+ when :child
50
+ Age.child
51
+ when :phone
52
+ Phone.rand
53
+ when :address
54
+ Address.rand
55
+ when :email
56
+ Email.us
57
+ end
58
+ end
59
+ m.save
60
+ end
23
61
  end
24
-
62
+ end
25
63
  end
26
64
 
27
65
 
@@ -0,0 +1,9 @@
1
+ module Modlr
2
+ module Address
3
+ def self.random
4
+ rand(1000).to_s + " " + Name.rand_last_name + " " + STREETS[rand(STREETS.count)]
5
+ end
6
+
7
+ STREETS = ["DR", "RD", "AVE", "PWKY", "PL", "ST", "WAY"]
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Modlr
2
+ module Age
3
+ def self.child
4
+ rand(17)
5
+ end
6
+ def self.adult
7
+ rand(50) + 17
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Modlr
2
+ module Email
3
+ def self.us
4
+ "mandrig@gmail.com"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module Modlr
2
+ module Phone
3
+ def self.random
4
+ s =""
5
+ 10.times do
6
+ s += rand(9).to_s
7
+ end
8
+ s
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Modlr
2
- VERSION = "0.0.4.5.1"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: modlr
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.4.5.1
5
+ version: 0.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nick Radford
@@ -29,7 +29,11 @@ files:
29
29
  - README.textile
30
30
  - Rakefile
31
31
  - lib/modlr.rb
32
+ - lib/modlr/address.rb
33
+ - lib/modlr/ages.rb
34
+ - lib/modlr/email.rb
32
35
  - lib/modlr/names.rb
36
+ - lib/modlr/phone.rb
33
37
  - lib/modlr/version.rb
34
38
  - modlr.gemspec
35
39
  has_rdoc: true