commandable 0.3.1 → 0.3.2

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.
@@ -0,0 +1 @@
1
+ 1.9.3-p392
data/README.md CHANGED
@@ -21,9 +21,9 @@ You can now "use your words" to let people interact with your apps in a natural
21
21
 
22
22
  ## Latest version
23
23
 
24
- 2012-02-07 - Version: 0.3.1
24
+ 2013-03-04 - Version: 0.3.2
25
25
 
26
- See change history for specific changes.
26
+ Verified works with Ruby 2.0
27
27
 
28
28
  ## Principle of Least Surprise
29
29
 
@@ -31,7 +31,7 @@ I've tried to follow the principle of least surprise so Commandable should just
31
31
 
32
32
  ## Requirements ##
33
33
 
34
- * Ruby 1.9.2 or greater
34
+ * Ruby 1.9.3 or greater (Ruby 2.0 supported)
35
35
  * OS X or any Posix OS (It works, mostly, on Windows but it won't pass the tests because of some Unix commands I use in the tests but no in the code base)
36
36
 
37
37
  ## Installation
@@ -418,6 +418,10 @@ Most of all it should be simple to use so if you have any problems please drop m
418
418
 
419
419
  ## Version History ##
420
420
 
421
+ 2013-04-04 - Version: 0.3.2
422
+
423
+ * Works with Ruby 2.0
424
+
421
425
  2012-02-07 - Version: 0.3.1
422
426
 
423
427
  * Fixed bug where an error was raised if a non-commandable method was before a commandable method (uninitialized class variable @@command_options)
data/Rakefile CHANGED
@@ -4,7 +4,6 @@ Bundler::GemHelper.install_tasks
4
4
  require 'rake'
5
5
  require 'rdoc/task'
6
6
  require 'rspec/core/rake_task'
7
- require 'cucumber/rake/task'
8
7
 
9
8
  desc "Run all examples"
10
9
  RSpec::Core::RakeTask.new(:spec) do |t|
@@ -0,0 +1,27 @@
1
+ $:.unshift File.expand_path((File.dirname(__FILE__) + '/../lib'))
2
+ require 'commandable'
3
+
4
+ Commandable.color_output = true
5
+ Commandable.app_exe = "bug_fix"
6
+ Commandable.app_info =
7
+ """
8
+ Testing - Testing Commandable
9
+ Copyleft (c) 2012 Mike Bethany
10
+ http://mikeb.tk
11
+ """
12
+
13
+ class TestIt
14
+ extend Commandable
15
+
16
+ def non_command_method
17
+ puts "test"
18
+ end
19
+
20
+ command "A directory or file to convert", :default
21
+ def command_method(value="blah")
22
+ puts "value: #{value}"
23
+ end
24
+
25
+ end
26
+
27
+ Commandable.execute
@@ -19,9 +19,9 @@ EOF
19
19
 
20
20
  s.license = 'MIT'
21
21
 
22
- s.add_dependency("term-ansicolor", "~>1.0.7")
22
+ s.add_dependency("term-ansicolor", "~>1.1")
23
23
 
24
- s.add_development_dependency("rspec", "~>2.5")
24
+ s.add_development_dependency("rspec", "~>2.13")
25
25
 
26
26
  s.files = `git ls-files`.split("\n")
27
27
  s.test_files = `git ls-files -- {spec,autotest}/*`.split("\n")
@@ -39,20 +39,15 @@ module Commandable
39
39
 
40
40
  private
41
41
 
42
- # This is where the magic happens!
43
- # It lets you add a method to the list of command line methods
44
- def command(*cmd_parameters)
45
-
42
+ def init_properties
46
43
  @@attribute = nil
47
44
  @@method_file = nil
48
45
  @@method_line = nil
49
- @@command_options = {}
50
-
51
- # Include Commandable in singleton classes so class level methods work
52
- include Commandable unless self.include? Commandable
53
-
54
- # parse command parameters
55
- while (param = cmd_parameters.shift)
46
+ @@command_options = {}
47
+ end
48
+
49
+ def parse_parameters(params)
50
+ while (param = params.shift)
56
51
  case param
57
52
  when Symbol
58
53
  if param == :xor
@@ -67,6 +62,19 @@ module Commandable
67
62
  end
68
63
  end
69
64
  @@command_options[:priority] ||= 0
65
+ end
66
+
67
+ # This is where the magic happens!
68
+ # It lets you add a method to the list of command line methods
69
+ def command(*cmd_parameters)
70
+
71
+ init_properties
72
+
73
+ # Include Commandable in singleton classes so class level methods work
74
+ include Commandable unless self.include? Commandable
75
+
76
+ # parse command parameters
77
+ parse_parameters(cmd_parameters)
70
78
 
71
79
  # only one default allowed
72
80
  raise ConfigurationError, "Only one default method is allowed." if @@default_method and @@command_options[:default]
@@ -88,6 +96,7 @@ module Commandable
88
96
  raise SyntaxError, "A command was specified but no method follows"
89
97
  end
90
98
  }
99
+
91
100
  end
92
101
 
93
102
  # Add a method to the list of available command line methods
@@ -3,7 +3,7 @@ module Commandable
3
3
  module VERSION
4
4
  MAJOR = 0
5
5
  MINOR = 3
6
- TINY = 1
6
+ TINY = 2
7
7
  PRE = nil
8
8
 
9
9
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ # These tests MUST run first to be valid
4
+
5
+ describe Commandable do
6
+
7
+ it 'should not raise an error if a non-command method is before a command method' do
8
+ load 'run_first.rb'
9
+ capture_output{Commandable.execute([])}.to_s.should_not match(/Error:/)
10
+ end
11
+
12
+ it 'should not raise an error if a non-command class method is before a command method' do
13
+ Commandable.reset_all
14
+ load 'run_first_class.rb'
15
+ capture_output{Commandable.execute([])}.to_s.should_not match(/Error:/)
16
+ end
17
+
18
+
19
+ end
@@ -9,7 +9,7 @@ describe Commandable do
9
9
  before(:each) { load 'test_class.rb' }
10
10
 
11
11
  it "should use ARGV by default" do
12
- expect {capture_output{Commandable.execute()}}.should_not raise_error(ArgumentError)
12
+ expect {capture_output{Commandable.execute()}}.to_not raise_error(ArgumentError)
13
13
  end
14
14
 
15
15
  end
@@ -0,0 +1,24 @@
1
+ require "commandable"
2
+
3
+ Commandable.color_output = true
4
+ Commandable.app_exe = "bug_fix"
5
+ Commandable.app_info =
6
+ """
7
+ Testing - Testing Commandable
8
+ Copyleft (c) 2012 Mike Bethany
9
+ http://mikeb.tk
10
+ """
11
+
12
+ class RunFirst
13
+ extend Commandable
14
+
15
+ def non_command_method
16
+ puts "non_command_method"
17
+ end
18
+
19
+ command "default method", :default
20
+ def command_method
21
+ puts "#command_method"
22
+ end
23
+
24
+ end
@@ -0,0 +1,24 @@
1
+ require "commandable"
2
+
3
+ Commandable.color_output = true
4
+ Commandable.app_exe = "bug_fix"
5
+ Commandable.app_info =
6
+ """
7
+ Testing - Testing Commandable
8
+ Copyleft (c) 2012 Mike Bethany
9
+ http://mikeb.tk
10
+ """
11
+
12
+ class RunFirstClass
13
+ extend Commandable
14
+
15
+ def self.non_command_method
16
+ puts "class non_command_method"
17
+ end
18
+
19
+ command "default method", :default
20
+ def command_method
21
+ puts "#command_method"
22
+ end
23
+
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commandable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,30 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-08 00:00:00.000000000 Z
12
+ date: 2013-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: term-ansicolor
16
- requirement: &70273995390760 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.7
21
+ version: '1.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70273995390760
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.1'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &70273995389900 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
31
36
  - !ruby/object:Gem::Version
32
- version: '2.5'
37
+ version: '2.13'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70273995389900
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.13'
36
46
  description: ! 'The easiest way to add command line control to your Ruby app. You
37
47
  can add a single line above an existing method and that method will be available
38
48
  from the command line.
@@ -52,11 +62,12 @@ files:
52
62
  - .gemtest
53
63
  - .gitignore
54
64
  - .rbenv-gemsets
55
- - BUGS.txt
65
+ - .ruby-version
56
66
  - Gemfile
57
67
  - LICENCE
58
68
  - README.md
59
69
  - Rakefile
70
+ - _spike/bug_fix.rb
60
71
  - autotest/discover.rb
61
72
  - bin/commandable
62
73
  - commandable.gemspec
@@ -70,6 +81,7 @@ files:
70
81
  - lib/commandable/execution_controller.rb
71
82
  - lib/commandable/help_text.rb
72
83
  - lib/commandable/version.rb
84
+ - spec/commandable/00_run_first_spec.rb
73
85
  - spec/commandable/app_controller_spec.rb
74
86
  - spec/commandable/attr_accessor_spec.rb
75
87
  - spec/commandable/coloring_spec.rb
@@ -103,6 +115,8 @@ files:
103
115
  - spec/source_code_examples/parameter_free.rb
104
116
  - spec/source_code_examples/required_default.rb
105
117
  - spec/source_code_examples/required_methods.rb
118
+ - spec/source_code_examples/run_first.rb
119
+ - spec/source_code_examples/run_first_class.rb
106
120
  - spec/source_code_examples/super_deep_class.rb
107
121
  - spec/source_code_examples/test_class.rb
108
122
  - spec/source_code_examples/xor_class.rb
@@ -131,12 +145,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
145
  version: '0'
132
146
  requirements: []
133
147
  rubyforge_project:
134
- rubygems_version: 1.8.15
148
+ rubygems_version: 1.8.23
135
149
  signing_key:
136
150
  specification_version: 3
137
151
  summary: The easiest way to add command line control to your Ruby apps.
138
152
  test_files:
139
153
  - autotest/discover.rb
154
+ - spec/commandable/00_run_first_spec.rb
140
155
  - spec/commandable/app_controller_spec.rb
141
156
  - spec/commandable/attr_accessor_spec.rb
142
157
  - spec/commandable/coloring_spec.rb
@@ -170,6 +185,8 @@ test_files:
170
185
  - spec/source_code_examples/parameter_free.rb
171
186
  - spec/source_code_examples/required_default.rb
172
187
  - spec/source_code_examples/required_methods.rb
188
+ - spec/source_code_examples/run_first.rb
189
+ - spec/source_code_examples/run_first_class.rb
173
190
  - spec/source_code_examples/super_deep_class.rb
174
191
  - spec/source_code_examples/test_class.rb
175
192
  - spec/source_code_examples/xor_class.rb
data/BUGS.txt DELETED
@@ -1,2 +0,0 @@
1
- term-ansicolor-hi conflicts with term-ansicolor.
2
-