modlr 0.0.5.1 → 0.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.
- data/README.textile +1 -1
- data/bin/modlr +70 -0
- data/lib/modlr.rb +6 -5
- data/lib/modlr/email.rb +1 -1
- data/lib/modlr/version.rb +1 -1
- metadata +4 -3
data/README.textile
CHANGED
data/bin/modlr
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: #{File.basename($0)} [path]"
|
8
|
+
|
9
|
+
begin
|
10
|
+
opts.parse!(ARGV)
|
11
|
+
rescue OptionParser::ParseError => e
|
12
|
+
warn e.message
|
13
|
+
puts opts
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
if ARGV.empty?
|
19
|
+
abort "Please specify the directory to set up Modlr, e.g. `#{File.basename($0)} .'"
|
20
|
+
elsif !File.exists?(ARGV.first)
|
21
|
+
abort "`#{ARGV.first}' does not exist."
|
22
|
+
elsif !File.directory?(ARGV.first)
|
23
|
+
abort "`#{ARGV.first}' is not a directory."
|
24
|
+
elsif ARGV.length > 1
|
25
|
+
abort "Too many arguments; please specify only the directory to set up Modlr."
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
configcontent = <<-FILE
|
30
|
+
# Use this file to easily set up which models you want to use Modlr with.
|
31
|
+
#
|
32
|
+
# For documentation, check out http://nicholasradford.com/modlr.html
|
33
|
+
#
|
34
|
+
# eg. modlr User, {:number => 32, :client_name => :name, :client_email => :email}
|
35
|
+
FILE
|
36
|
+
configfile = 'config/modlr.rb'
|
37
|
+
|
38
|
+
initcontent = <<-FILE
|
39
|
+
require "modlr"
|
40
|
+
Modlr.read_config_file
|
41
|
+
FILE
|
42
|
+
initfile = 'config/initializers/modlr.rb'
|
43
|
+
|
44
|
+
base = ARGV.shift
|
45
|
+
|
46
|
+
configfile = File.join(base, configfile)
|
47
|
+
if File.exists?(configfile)
|
48
|
+
warn "[skip] `#{configfile}' already exists"
|
49
|
+
elsif File.exists?(configfile.downcase)
|
50
|
+
warn "[skip] `#{configfile.downcase}' exists, which could conflict with `#{configfile}'"
|
51
|
+
elsif !File.exists?(File.dirname(configfile))
|
52
|
+
warn "[skip] directory `#{File.dirname(configfile)}' does not exist"
|
53
|
+
else
|
54
|
+
puts "[add] writing `#{configfile}'"
|
55
|
+
File.open(configfile, "w") { |f| f.write(configcontent) }
|
56
|
+
end
|
57
|
+
|
58
|
+
initfile = File.join(base, initfile)
|
59
|
+
if File.exists?(initfile)
|
60
|
+
warn "[skip] `#{initfile}' already exists"
|
61
|
+
elsif File.exists?(initfile.downcase)
|
62
|
+
warn "[skip] `#{initfile.downcase}' exists, which could conflict with `#{initfile}'"
|
63
|
+
elsif !File.exists?(File.dirname(initfile))
|
64
|
+
warn "[skip] directory `#{File.dirname(initfile)}' does not exist"
|
65
|
+
else
|
66
|
+
puts "[add] writing `#{initfile}'"
|
67
|
+
File.open(initfile, "w") { |f| f.write(initcontent) }
|
68
|
+
end
|
69
|
+
|
70
|
+
puts "[done] Modlr set up successfully!"
|
data/lib/modlr.rb
CHANGED
@@ -17,9 +17,10 @@ module Modlr
|
|
17
17
|
# will create 100 user records with names and ages which make sense.
|
18
18
|
#
|
19
19
|
#
|
20
|
-
##
|
21
|
-
def
|
22
|
-
|
20
|
+
##
|
21
|
+
def self.read_config_file
|
22
|
+
data = File.read("config/modlr.rb")
|
23
|
+
eval(data)
|
23
24
|
end
|
24
25
|
|
25
26
|
def self.modlr(model, args = nil)
|
@@ -49,9 +50,9 @@ module Modlr
|
|
49
50
|
when :child
|
50
51
|
Age.child
|
51
52
|
when :phone
|
52
|
-
Phone.
|
53
|
+
Phone.random
|
53
54
|
when :address
|
54
|
-
Address.
|
55
|
+
Address.random
|
55
56
|
when :email
|
56
57
|
Email.us
|
57
58
|
end
|
data/lib/modlr/email.rb
CHANGED
data/lib/modlr/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: modlr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: "0.1"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nick Radford
|
@@ -17,8 +17,8 @@ dependencies: []
|
|
17
17
|
description: Generate some sensical test data for your models.
|
18
18
|
email:
|
19
19
|
- nick@nicholasradford.com
|
20
|
-
executables:
|
21
|
-
|
20
|
+
executables:
|
21
|
+
- modlr
|
22
22
|
extensions: []
|
23
23
|
|
24
24
|
extra_rdoc_files: []
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- Gemfile
|
29
29
|
- README.textile
|
30
30
|
- Rakefile
|
31
|
+
- bin/modlr
|
31
32
|
- lib/modlr.rb
|
32
33
|
- lib/modlr/address.rb
|
33
34
|
- lib/modlr/ages.rb
|