cri 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS.md CHANGED
@@ -1,13 +1,17 @@
1
1
  Cri News
2
2
  ========
3
3
 
4
+ 2.0.2
5
+ -----
6
+
7
+ * Added command filename to stack traces
8
+
4
9
  2.0.1
5
10
  -----
6
11
 
7
12
  * Sorted ambiguous command names
8
13
  * Restored compatibility with Ruby 1.8.x
9
14
 
10
-
11
15
  2.0.0
12
16
  -----
13
17
 
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.1'
20
+ VERSION = '2.0.2'
21
21
 
22
22
  autoload 'Command', 'cri/command'
23
23
  autoload 'CommandDSL', 'cri/command_dsl'
@@ -88,10 +88,11 @@ module Cri
88
88
  # @param [String, nil] The string containing the command’s definition
89
89
  #
90
90
  # @return [Cri::Command] The newly defined command
91
- def self.define(string=nil, &block)
91
+ def self.define(string=nil, filename=nil, &block)
92
92
  dsl = Cri::CommandDSL.new
93
93
  if string
94
- dsl.instance_eval(string)
94
+ args = filename ? [ string, filename ] : [ string ]
95
+ dsl.instance_eval(*args)
95
96
  elsif [ -1, 0 ].include? block.arity
96
97
  dsl.instance_eval(&block)
97
98
  else
@@ -295,4 +295,12 @@ class Cri::CommandTestCase < Cri::TestCase
295
295
  assert_equal 'baresub', cmd.subcommands.to_a[0].name
296
296
  end
297
297
 
298
+ def test_backtrace_includes_filename
299
+ error = assert_raises RuntimeError do
300
+ Cri::Command.define('raise "boom"', 'mycommand.rb')
301
+ end
302
+
303
+ assert_match /mycommand.rb/, error.backtrace.join("\n")
304
+ end
305
+
298
306
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cri
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
4
  prerelease:
6
- segments:
7
- - 2
8
- - 0
9
- - 1
10
- version: 2.0.1
5
+ version: 2.0.2
11
6
  platform: ruby
12
7
  authors:
13
8
  - Denis Defreyne
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-07-04 00:00:00 +02:00
19
- default_executable:
13
+ date: 2011-07-17 00:00:00 Z
20
14
  dependencies: []
21
15
 
22
16
  description: Cri allows building easy-to-use commandline interfaces with support for subcommands.
@@ -53,7 +47,6 @@ files:
53
47
  - test/test_option_parser.rb
54
48
  - cri.gemspec
55
49
  - .gemtest
56
- has_rdoc: true
57
50
  homepage: http://stoneship.org/software/cri/
58
51
  licenses: []
59
52
 
@@ -68,23 +61,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
61
  requirements:
69
62
  - - ">="
70
63
  - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
64
  version: "0"
75
65
  required_rubygems_version: !ruby/object:Gem::Requirement
76
66
  none: false
77
67
  requirements:
78
68
  - - ">="
79
69
  - !ruby/object:Gem::Version
80
- hash: 3
81
- segments:
82
- - 0
83
70
  version: "0"
84
71
  requirements: []
85
72
 
86
73
  rubyforge_project:
87
- rubygems_version: 1.6.2
74
+ rubygems_version: 1.8.5
88
75
  signing_key:
89
76
  specification_version: 3
90
77
  summary: a library for building easy-to-use commandline tools