templater 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/templater.rb CHANGED
@@ -43,6 +43,6 @@ module Templater
43
43
  class MalformattedArgumentError < ArgumentError #:nodoc:
44
44
  end
45
45
 
46
- VERSION = '0.4.0'
46
+ VERSION = '0.4.1'
47
47
 
48
48
  end
@@ -45,7 +45,7 @@ module Templater
45
45
  options[option.name] = s
46
46
  end
47
47
  else
48
- opts.on("--#{name} OPTION", option.options[:desc]) do |s|
48
+ opts.on("--#{name}=value", option.options[:desc]) do |s|
49
49
  options[option.name] = s.gsub('-', '_').to_sym
50
50
  end
51
51
  end
@@ -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
- opts.parse!(args)
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.0
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-11 00:00:00 +02:00
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.2.0
150
+ rubygems_version: 1.3.1
150
151
  signing_key:
151
152
  specification_version: 2
152
153
  summary: File generation system