amp-front 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -104,8 +104,9 @@ module Amp
104
104
 
105
105
  # Specifies the block to run, or returns the block.
106
106
  def self.on_call(&block)
107
- @on_call = block if block_given?
108
- @on_call
107
+ if block_given?
108
+ define_method :call_without_args, &block
109
+ end
109
110
  end
110
111
 
111
112
  def self.desc(*args)
@@ -120,17 +121,17 @@ module Amp
120
121
  def self.opt(*args)
121
122
  self.options << args
122
123
  end
123
-
124
+
124
125
  # Runs the command with the provided options and arguments.
125
- def call(options, arguments)
126
- self.options = options
127
- self.arguments = arguments
128
- instance_eval(&self.class.on_call)
126
+ def call(opts, args)
127
+ self.options = opts
128
+ self.arguments = args
129
+ call_without_args
129
130
  end
130
131
 
131
132
  # Collects the options specific to this command and returns them.
132
- def collect_options(arguments)
133
- args = arguments.dup
133
+ def collect_options(input_args)
134
+ args = input_args.dup
134
135
  base_options = self.class.options # Trollop::options uses instance_eval
135
136
  @parser, hash = Trollop::options(args) do
136
137
  base_options.each do |option|
@@ -45,13 +45,6 @@ describe Amp::Command::Base do
45
45
  @klass.new.call(nil, nil)
46
46
  flag.should be_true
47
47
  end
48
-
49
- it 'returns the current handler if no block is given' do
50
- @klass.on_call.should == nil
51
- @klass.on_call { puts 'hello' }
52
- @klass.on_call.should_not == nil
53
- @klass.on_call.should respond_to(:call)
54
- end
55
48
  end
56
49
 
57
50
  describe '#opt' do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Edgar
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-03 00:00:00 -04:00
17
+ date: 2010-11-11 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency