rspec-kickstarter 0.2.3 → 0.2.4
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/bin/rspec-kickstarter +29 -8
- data/lib/rspec_kickstarter/version.rb +1 -1
- metadata +1 -1
data/bin/rspec-kickstarter
CHANGED
@@ -4,8 +4,9 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
require 'optparse'
|
7
|
+
require 'rspec_kickstarter/version'
|
7
8
|
require 'rspec_kickstarter/generator'
|
8
|
-
|
9
|
+
print_version = false
|
9
10
|
force_write = false
|
10
11
|
dry_run = false
|
11
12
|
rails_mode = false
|
@@ -22,13 +23,23 @@ opt.on('-r', 'Run in Rails mode') { |_| rails_mode = true }
|
|
22
23
|
opt.on('--rails', '') { |_| rails_mode = true }
|
23
24
|
opt.on('-o VAL', 'Output directory (default: ./spec)') { |dir| spec_dir = dir }
|
24
25
|
opt.on('--output-dir VAL', '') { |dir| spec_dir = dir }
|
25
|
-
opt.on('
|
26
|
-
opt.on('--
|
26
|
+
opt.on('-D VAL', 'Delta tempalte path (e.g. ./rails_controller_delta.erb)') { |path| delta_path = path }
|
27
|
+
opt.on('--delta-template VAL', '') { |path| delta_path = path }
|
28
|
+
opt.on('-F VAL', 'Full template path (e.g. ./rails_controller_full.erb)') { |path| full_path = path }
|
29
|
+
opt.on('--full-template VAL', '') { |path| full_path = path }
|
30
|
+
opt.on('-v', 'Print version') { |_| print_version = true }
|
31
|
+
opt.on('--version', '') { |_| print_version = true }
|
27
32
|
|
28
33
|
args = opt.parse(ARGV)
|
34
|
+
|
35
|
+
if print_version
|
36
|
+
puts "rspec-kickstarter #{RSpecKickstarter::VERSION}"
|
37
|
+
exit 0
|
38
|
+
end
|
39
|
+
|
29
40
|
dir_or_file = args.first
|
30
41
|
if dir_or_file.nil?
|
31
|
-
puts "Usage: rspec-kickstarter [dir/*.rb]"
|
42
|
+
puts "Usage: rspec-kickstarter [dir/*.rb] -options"
|
32
43
|
exit 1
|
33
44
|
end
|
34
45
|
unless dir_or_file.match(/.rb$/)
|
@@ -36,12 +47,22 @@ unless dir_or_file.match(/.rb$/)
|
|
36
47
|
end
|
37
48
|
|
38
49
|
delta_template = nil
|
39
|
-
if ! delta_path.nil?
|
40
|
-
|
50
|
+
if ! delta_path.nil?
|
51
|
+
if File.exist?(delta_path)
|
52
|
+
delta_template = File.read(delta_path)
|
53
|
+
else
|
54
|
+
puts "'#{delta_path}' is not found."
|
55
|
+
exit 1
|
56
|
+
end
|
41
57
|
end
|
42
58
|
full_template = nil
|
43
|
-
if ! full_path.nil?
|
44
|
-
|
59
|
+
if ! full_path.nil?
|
60
|
+
if File.exist?(full_path)
|
61
|
+
full_template = File.read(full_path)
|
62
|
+
else
|
63
|
+
puts "'#{full_path}' is not found."
|
64
|
+
exit 1
|
65
|
+
end
|
45
66
|
end
|
46
67
|
|
47
68
|
generator = RSpecKickstarter::Generator.new(spec_dir, delta_template, full_template)
|