templater 0.4.0 → 0.4.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/lib/templater.rb +1 -1
- data/lib/templater/cli/generator.rb +1 -1
- data/lib/templater/cli/parser.rb +11 -15
- data/spec/options_parser_spec.rb +20 -0
- metadata +4 -3
data/lib/templater.rb
CHANGED
data/lib/templater/cli/parser.rb
CHANGED
@@ -42,11 +42,6 @@ module Templater
|
|
42
42
|
options[:skip] = s
|
43
43
|
end
|
44
44
|
|
45
|
-
# TODO: implement this
|
46
|
-
#opts.on("-a", "--ask", "Ask about each file before generating it.") do |s|
|
47
|
-
# options[:ask] = s
|
48
|
-
#end
|
49
|
-
|
50
45
|
opts.on("-d", "--delete", "Delete files that have previously been generated with this generator.") do |s|
|
51
46
|
options[:delete] = s
|
52
47
|
end
|
@@ -55,15 +50,6 @@ module Templater
|
|
55
50
|
options[:no_color] = true
|
56
51
|
end
|
57
52
|
|
58
|
-
# these could be implemented in the future, but they are not used right now.
|
59
|
-
#opts.on("-q", "--quiet", "Suppress normal output.") do |q|
|
60
|
-
# options[:quit] = q
|
61
|
-
#end
|
62
|
-
#
|
63
|
-
#opts.on("-v", "--verbose", "Run verbosely") do |v|
|
64
|
-
# options[:verbose] = v
|
65
|
-
#end
|
66
|
-
|
67
53
|
opts.on("-h", "--help", "Show this message") do
|
68
54
|
options[:help] = true
|
69
55
|
end
|
@@ -78,10 +64,20 @@ module Templater
|
|
78
64
|
|
79
65
|
options[:opts] = opts
|
80
66
|
|
81
|
-
|
67
|
+
begin
|
68
|
+
opts.parse!(args)
|
69
|
+
rescue OptionParser::InvalidOption => e
|
70
|
+
puts
|
71
|
+
puts error_message(e)
|
72
|
+
puts
|
73
|
+
end
|
74
|
+
|
82
75
|
options
|
83
76
|
end
|
84
77
|
|
78
|
+
def self.error_message(e)
|
79
|
+
"One or more unknown options given: #{e.args.join(', ')}"
|
80
|
+
end
|
85
81
|
end
|
86
82
|
|
87
83
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require "tempfile"
|
3
|
+
|
4
|
+
describe Templater::CLI::Parser do
|
5
|
+
describe "given unknown option" do
|
6
|
+
it "outputs a meaninful error message instead of just blowing up" do
|
7
|
+
lambda do
|
8
|
+
Templater::CLI::Parser.parse(["--this-option-is-unknown", "--second-unknown-option"])
|
9
|
+
end.should_not raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it "lists unknown options" do
|
13
|
+
e = OptionParser::InvalidOption.new("--this-option-is-unknown", "--second-unknown-option")
|
14
|
+
output = Templater::CLI::Parser.error_message(e)
|
15
|
+
|
16
|
+
output.should =~ /--this-option-is-unknown/
|
17
|
+
output.should =~ /--second-unknown-option/
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: templater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
@@ -9,7 +9,7 @@ autorequire: templater
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-16 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- spec/generator/source_root_spec.rb
|
103
103
|
- spec/generator/templates_spec.rb
|
104
104
|
- spec/manifold_spec.rb
|
105
|
+
- spec/options_parser_spec.rb
|
105
106
|
- spec/results
|
106
107
|
- spec/results/erb.rbs
|
107
108
|
- spec/results/file.rbs
|
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
147
|
requirements: []
|
147
148
|
|
148
149
|
rubyforge_project:
|
149
|
-
rubygems_version: 1.
|
150
|
+
rubygems_version: 1.3.1
|
150
151
|
signing_key:
|
151
152
|
specification_version: 2
|
152
153
|
summary: File generation system
|