boson 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.1.0
2
+ * Add Runner.execute
3
+ * Allow Runner to define commands with Kernel method names
4
+ * Fix Runner.load_options
5
+
1
6
  == 1.0.1
2
7
  * Fix RunnerLibrary not parsing options correctly
3
8
 
@@ -76,7 +76,7 @@ module Boson
76
76
  end
77
77
 
78
78
  def load_options
79
- {:verbose=>@options[:verbose]}
79
+ {}
80
80
  end
81
81
  end
82
82
  end
data/lib/boson/runner.rb CHANGED
@@ -19,16 +19,19 @@ module Boson
19
19
  super
20
20
  init
21
21
  command, options, args = parse_args(args)
22
+ execute command, args, options
23
+ end
22
24
 
25
+ def self.execute(command, args, options)
23
26
  if options[:help] || command.nil?
24
27
  display_default_usage
25
28
  else
26
- execute_command(command, args)
29
+ execute_command(command, args, options)
27
30
  end
28
31
  end
29
32
 
30
- def self.execute_command(cmd, args)
31
- Command.find(cmd) ? super : no_command_error(cmd)
33
+ def self.execute_command(cmd, args, options)
34
+ Command.find(cmd) ? super(cmd, args) : no_command_error(cmd)
32
35
  end
33
36
 
34
37
  def self.display_help(cmd)
@@ -53,6 +56,10 @@ module Boson
53
56
  end
54
57
 
55
58
  private
59
+ def self.load_options
60
+ {force: true}
61
+ end
62
+
56
63
  def self.add_command_help
57
64
  # Overrides Scientist' default help
58
65
  Scientist.extend(Module.new do
data/lib/boson/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Boson
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
data/test/runner_test.rb CHANGED
@@ -1,6 +1,14 @@
1
1
  require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class MyRunner < Boson::Runner
4
+ GLOBAL_OPTIONS[:version] = {
5
+ type: :boolean, :desc => 'Print version'
6
+ }
7
+
8
+ def self.execute(command, args, options)
9
+ options[:version] ? puts("Version 1000.0") : super
10
+ end
11
+
4
12
  desc "This is a small"
5
13
  def small(*args)
6
14
  p args
@@ -34,6 +42,10 @@ class MyRunner < Boson::Runner
34
42
  raise ArgumentError
35
43
  end
36
44
 
45
+ def test
46
+ puts "TEST"
47
+ end
48
+
37
49
  private
38
50
  def no_run
39
51
  end
@@ -60,6 +72,7 @@ Available commands:
60
72
  quiet
61
73
  small This is a small
62
74
  splot This is splot
75
+ test
63
76
 
64
77
  For help on a command: my_command COMMAND -h
65
78
  STR
@@ -142,6 +155,14 @@ STR
142
155
  Boson.in_shell = nil
143
156
  end
144
157
 
158
+ it "executes custom global option" do
159
+ my_command('-v').chomp.should == 'Version 1000.0'
160
+ end
161
+
162
+ it "allows Kernel-method command names" do
163
+ my_command('test').chomp.should == 'TEST'
164
+ end
165
+
145
166
  it "prints error message for internal public method" do
146
167
  MyRunner.expects(:abort).with %[Could not find command "to_s"]
147
168
  my_command('to_s').should == ''
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boson
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mocha
16
- requirement: &70306896691040 !ruby/object:Gem::Requirement
16
+ requirement: &70231553336480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.10.4
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70306896691040
24
+ version_requirements: *70231553336480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bacon
27
- requirement: &70306896690580 !ruby/object:Gem::Requirement
27
+ requirement: &70231553335640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.1.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70306896690580
35
+ version_requirements: *70231553335640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mocha-on-bacon
38
- requirement: &70306896690180 !ruby/object:Gem::Requirement
38
+ requirement: &70231553334560 !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: *70306896690180
46
+ version_requirements: *70231553334560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bacon-bits
49
- requirement: &70306896689720 !ruby/object:Gem::Requirement
49
+ requirement: &70231553333940 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70306896689720
57
+ version_requirements: *70231553333940
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bahia
60
- requirement: &70306896689200 !ruby/object:Gem::Requirement
60
+ requirement: &70231553333440 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 0.4.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70306896689200
68
+ version_requirements: *70231553333440
69
69
  description: Boson is a modular command/task framework. Thanks to its rich set of
70
70
  plugins, it differentiates itself from rake and thor by being usable from irb and
71
71
  the commandline, having optional automated views generated by hirb and allowing