methadone 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -91,6 +91,12 @@ Methadone gives you a simple,lightweight DSL to help. It's important to note th
91
91
  arg :name
92
92
  arg :password, :optional
93
93
 
94
+ # If you want to avoid automatic exception catching/logging do:
95
+ #
96
+ # leak_exceptions true
97
+ #
98
+ # Note that Methadone::Error exceptions are always caught and logged
99
+
94
100
  go!
95
101
 
96
102
  +go!+ runs the block you gave to +main+, passing it the unparsed +ARGV+ as parameters to the block. It will
@@ -87,6 +87,16 @@ module Methadone
87
87
  @option_parser = OptionParserProxy.new(OptionParser.new,@options)
88
88
  end
89
89
 
90
+ # Configure the auto-handling of StandardError exceptions caught
91
+ # from calling go!.
92
+ #
93
+ # leak - if true, go! will *not* catch StandardError exceptions, but instead
94
+ # allow them to bubble up. If false, they will be caught and handled as normal.
95
+ # This does *not* affect Methadone::Error exceptions; those will NOT leak through.
96
+ def leak_exceptions(leak)
97
+ @leak_exceptions = leak
98
+ end
99
+
90
100
 
91
101
  # Start your command-line app, exiting appropriately when
92
102
  # complete.
@@ -196,6 +206,7 @@ module Methadone
196
206
  error ex.message unless no_message? ex
197
207
  ex.exit_code
198
208
  rescue => ex
209
+ raise ex if @leak_exceptions
199
210
  error ex.message unless no_message? ex
200
211
  70 # Linux sysexit code for internal software error
201
212
  end
@@ -1,3 +1,3 @@
1
1
  module Methadone
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
data/test/test_main.rb CHANGED
@@ -93,8 +93,6 @@ class TestMain < BaseTest
93
93
  end
94
94
  end
95
95
 
96
- def run_go!; proc { go! }; end
97
-
98
96
  test_that "go exits with the numeric value that main evaluated to" do
99
97
  [0,1,2,3].each do |exit_status|
100
98
  Given main_that_exits exit_status
@@ -120,6 +118,35 @@ class TestMain < BaseTest
120
118
  }
121
119
  end
122
120
 
121
+ test_that "An exception that's not a StandardError causes the excepteion to break through and raise" do
122
+ Given {
123
+ main do
124
+ raise Exception,"oh noes"
125
+ end
126
+ }
127
+ Then {
128
+ ex = assert_raises Exception do
129
+ When run_go!
130
+ end
131
+ assert_equal "oh noes",ex.message
132
+ }
133
+ end
134
+
135
+ test_that "Non-methadone exceptions leak through if we configure it that way" do
136
+ Given {
137
+ main do
138
+ raise StandardError,"oh noes"
139
+ end
140
+ leak_exceptions true
141
+ }
142
+ Then {
143
+ ex = assert_raises StandardError do
144
+ When run_go!
145
+ end
146
+ assert_equal "oh noes",ex.message
147
+ }
148
+ end
149
+
123
150
  test_that "go exits with the exit status included in the special-purpose excepiton" do
124
151
  Given {
125
152
  main do
@@ -368,6 +395,8 @@ class TestMain < BaseTest
368
395
  rescue SystemExit
369
396
  end
370
397
 
398
+ def run_go!; proc { go! }; end
399
+
371
400
  def assert_logged_at_error(expected_message)
372
401
  @logged.should include expected_message
373
402
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: methadone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-04 00:00:00.000000000Z
12
+ date: 2011-11-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &70155090787300 !ruby/object:Gem::Requirement
16
+ requirement: &70257700838920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70155090787300
24
+ version_requirements: *70257700838920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec-expectations
27
- requirement: &70155090786800 !ruby/object:Gem::Requirement
27
+ requirement: &70257700838400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.6'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70155090786800
35
+ version_requirements: *70257700838400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70155090786380 !ruby/object:Gem::Requirement
38
+ requirement: &70257700837880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70155090786380
46
+ version_requirements: *70257700837880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &70155090785840 !ruby/object:Gem::Requirement
49
+ requirement: &70257700837200 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '3.9'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70155090785840
57
+ version_requirements: *70257700837200
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: cucumber
60
- requirement: &70155090785340 !ruby/object:Gem::Requirement
60
+ requirement: &70257700836640 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.1.1
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70155090785340
68
+ version_requirements: *70257700836640
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: aruba
71
- requirement: &70155090784960 !ruby/object:Gem::Requirement
71
+ requirement: &70257700836160 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70155090784960
79
+ version_requirements: *70257700836160
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov
82
- requirement: &70155090784420 !ruby/object:Gem::Requirement
82
+ requirement: &70257700835560 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0.5'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70155090784420
90
+ version_requirements: *70257700835560
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: test_unit-given
93
- requirement: &70155090783920 !ruby/object:Gem::Requirement
93
+ requirement: &70257700834960 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: 0.1.1
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70155090783920
101
+ version_requirements: *70257700834960
102
102
  description: Methadone provides a lot of small but useful features for developing
103
103
  a command-line app, including an opinionated bootstrapping process, some helpful
104
104
  cucumber steps, and some classes to bridge logging and output into a simple, unified,