cri 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS.md CHANGED
@@ -1,8 +1,15 @@
1
1
  Cri News
2
2
  ========
3
3
 
4
- 2.0
5
- ---
4
+ 2.0.1
5
+ -----
6
+
7
+ * Sorted ambiguous command names
8
+ * Restored compatibility with Ruby 1.8.x
9
+
10
+
11
+ 2.0.0
12
+ -----
6
13
 
7
14
  * Added DSL
8
15
  * Added support for nested commands
data/lib/cri.rb CHANGED
@@ -17,7 +17,7 @@ module Cri
17
17
  end
18
18
 
19
19
  # The current Cri version.
20
- VERSION = '2.0.0'
20
+ VERSION = '2.0.1'
21
21
 
22
22
  autoload 'Command', 'cri/command'
23
23
  autoload 'CommandDSL', 'cri/command_dsl'
data/lib/cri/command.rb CHANGED
@@ -92,7 +92,7 @@ module Cri
92
92
  dsl = Cri::CommandDSL.new
93
93
  if string
94
94
  dsl.instance_eval(string)
95
- elsif block.arity == 0
95
+ elsif [ -1, 0 ].include? block.arity
96
96
  dsl.instance_eval(&block)
97
97
  else
98
98
  block.call(dsl)
@@ -133,7 +133,7 @@ module Cri
133
133
  # @return [Cri::Command] The command itself
134
134
  def modify(&block)
135
135
  dsl = Cri::CommandDSL.new(self)
136
- if block.arity == 0
136
+ if [ -1, 0 ].include? block.arity
137
137
  dsl.instance_eval(&block)
138
138
  else
139
139
  block.call(dsl)
@@ -170,7 +170,7 @@ module Cri
170
170
  # Execute DSL
171
171
  dsl = Cri::CommandDSL.new
172
172
  dsl.name name unless name.nil?
173
- if block.arity == 0
173
+ if [ -1, 0 ].include? block.arity
174
174
  dsl.instance_eval(&block)
175
175
  else
176
176
  block.call(dsl)
@@ -218,7 +218,7 @@ module Cri
218
218
  exit 1
219
219
  elsif commands.size > 1
220
220
  $stderr.puts "#{self.name}: '#{name}' is ambiguous:"
221
- $stderr.puts " #{commands.map { |c| c.name }.join(' ') }"
221
+ $stderr.puts " #{commands.map { |c| c.name }.sort.join(' ') }"
222
222
  exit 1
223
223
  else
224
224
  commands[0]
data/test/test_command.rb CHANGED
@@ -24,7 +24,7 @@ class Cri::CommandTestCase < Cri::TestCase
24
24
 
25
25
  opts_strings = []
26
26
  opts.each_pair { |k,v| opts_strings << "#{k}=#{v}" }
27
- $stdout.puts opts_strings.join(',')
27
+ $stdout.puts opts_strings.sort.join(',')
28
28
  end
29
29
  end
30
30
  end
@@ -115,7 +115,7 @@ class Cri::CommandTestCase < Cri::TestCase
115
115
  simple_cmd.run(%w(-c -b x))
116
116
  end
117
117
 
118
- assert_equal [ 'Awesome moo!', '', 'ccc=true,bbb=x' ], lines(out)
118
+ assert_equal [ 'Awesome moo!', '', 'bbb=x,ccc=true' ], lines(out)
119
119
  assert_equal [], lines(err)
120
120
  end
121
121
 
@@ -189,7 +189,7 @@ class Cri::CommandTestCase < Cri::TestCase
189
189
  end
190
190
 
191
191
  assert_equal [ ], lines(out)
192
- assert_equal [ "super: 's' is ambiguous:", " sub sink" ], lines(err)
192
+ assert_equal [ "super: 's' is ambiguous:", " sink sub" ], lines(err)
193
193
  end
194
194
 
195
195
  def test_invoke_nested_with_alias
@@ -211,7 +211,7 @@ class Cri::CommandTestCase < Cri::TestCase
211
211
  end
212
212
 
213
213
  def test_help_nested
214
- help = nested_cmd.subcommands.to_a[0].help
214
+ help = nested_cmd.subcommands.find { |cmd| cmd.name == 'sub' }.help
215
215
 
216
216
  assert_match /^usage: super sub \[options\]/, help
217
217
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cri
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 13
4
5
  prerelease:
5
- version: 2.0.0
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 1
10
+ version: 2.0.1
6
11
  platform: ruby
7
12
  authors:
8
13
  - Denis Defreyne
@@ -10,7 +15,8 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-07-03 00:00:00 Z
18
+ date: 2011-07-04 00:00:00 +02:00
19
+ default_executable:
14
20
  dependencies: []
15
21
 
16
22
  description: Cri allows building easy-to-use commandline interfaces with support for subcommands.
@@ -47,6 +53,7 @@ files:
47
53
  - test/test_option_parser.rb
48
54
  - cri.gemspec
49
55
  - .gemtest
56
+ has_rdoc: true
50
57
  homepage: http://stoneship.org/software/cri/
51
58
  licenses: []
52
59
 
@@ -61,17 +68,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
68
  requirements:
62
69
  - - ">="
63
70
  - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
64
74
  version: "0"
65
75
  required_rubygems_version: !ruby/object:Gem::Requirement
66
76
  none: false
67
77
  requirements:
68
78
  - - ">="
69
79
  - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
70
83
  version: "0"
71
84
  requirements: []
72
85
 
73
86
  rubyforge_project:
74
- rubygems_version: 1.8.5
87
+ rubygems_version: 1.6.2
75
88
  signing_key:
76
89
  specification_version: 3
77
90
  summary: a library for building easy-to-use commandline tools