thunder 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift File.expand_path("../../lib", __FILE__)
4
-
5
3
  require 'thunder'
6
4
  require 'pp'
7
5
 
@@ -155,9 +155,9 @@ module Thunder
155
155
  # @api private
156
156
  # Registers a method as a thunder task
157
157
  def method_added(method)
158
- add_command(method.to_sym)
159
- thunder[:commands][method][:params] = instance_method(method).parameters
160
- thunder[:commands][method][:arity] = instance_method(method).arity
158
+ add_command(method.to_sym) do |command|
159
+ command[:params] = instance_method(method).parameters
160
+ end
161
161
  end
162
162
 
163
163
  # Set the options processor.
@@ -225,12 +225,13 @@ module Thunder
225
225
  # @param command [Symbol,String] the command that transfers processing to the provided handler
226
226
  # @param handler [Thunder] the handler that processes the request
227
227
  def subcommand(command, handler)
228
- add_command(command.to_sym)
229
- thunder[:commands][command.to_sym][:subcommand] = handler
228
+ add_command(command.to_sym) do |subcommand|
229
+ subcommand[:subcommand] = handler
230
+ end
230
231
  end
231
232
 
232
233
  private
233
- def add_command(command)
234
+ def add_command(command, &block)
234
235
  attributes = [:usage, :description, :options, :long_description]
235
236
  return unless attributes.reduce(nil) { |a, key| a || thunder[key] }
236
237
  thunder[:commands][command] = {
@@ -239,6 +240,13 @@ module Thunder
239
240
  attributes.each do |key|
240
241
  thunder[:commands][command][key] = thunder.delete(key)
241
242
  end
243
+ if block
244
+ if block.arity == 0
245
+ block.call
246
+ else
247
+ block.call thunder[:commands][command]
248
+ end
249
+ end
242
250
  end
243
251
  end
244
252
  end
@@ -1,4 +1,4 @@
1
1
  module Thunder
2
2
  # Version string for gemspec
3
- VERSION = "0.6.0"
3
+ VERSION = "0.6.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thunder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,27 +9,27 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-02 00:00:00.000000000 Z
12
+ date: 2013-01-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Thunder does command line interfaces. Nothing more, nothing less.
15
15
  email: steven.karas@gmail.com
16
16
  executables:
17
- - thunder-spec
18
17
  - thunder-completion
18
+ - thunder-spec
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - lib/thunder/help/default.rb
23
- - lib/thunder/version.rb
24
23
  - lib/thunder/options/optparse.rb
25
24
  - lib/thunder/options/trollop.rb
25
+ - lib/thunder/version.rb
26
26
  - lib/thunder.rb
27
27
  - spec/spec_thunder.rb
28
- - Rakefile
29
28
  - DESIGN.md
29
+ - Rakefile
30
30
  - README.md
31
- - bin/thunder-spec
32
31
  - bin/thunder-completion
32
+ - bin/thunder-spec
33
33
  homepage: http://stevenkaras.github.com/thunder
34
34
  licenses: []
35
35
  post_install_message: