commander 4.1.2 → 4.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,8 @@ rvm:
4
4
  - 1.8.7
5
5
  - 1.9.2
6
6
  - 1.9.3
7
+ - 2.0.0
7
8
  - jruby-18mode
8
- # rspec 2.8.0 failing in jruby 1.9 mode
9
- # - jruby-19mode
9
+ - jruby-19mode
10
10
  - rbx-18mode
11
+ - rbx-19mode
@@ -1,3 +1,9 @@
1
+ === 4.1.3 / 2012-12-15
2
+
3
+ * Remove use of eval in Array.parse
4
+ * Make generated template executable and set better defaults (@suan)
5
+ * Fixed valid_command_names_from to match exact commands only (@fgalassi)
6
+
1
7
  === 4.1.2 / 2012-02-17
2
8
 
3
9
  * Improvement to `ask_editor` to be more portable across *nix variants. (thanks to Federico Galassi)
@@ -336,4 +342,4 @@
336
342
 
337
343
  === 1.0.0 / 2008-10-31
338
344
 
339
- * Initial release
345
+ * Initial release
@@ -1,3 +1,5 @@
1
+ {<img src="https://secure.travis-ci.org/ggilder/commander.png?branch=master" alt="Build Status" />}[http://travis-ci.org/ggilder/commander]
2
+
1
3
  = Commander
2
4
 
3
5
  The complete solution for Ruby command-line executables.
@@ -25,9 +25,8 @@ command :init do |c|
25
25
 
26
26
  require 'rubygems'
27
27
  require 'commander/import'
28
- require '#{name}'
29
28
 
30
- program :version, #{name.capitalize}::VERSION
29
+ program :version, '0.0.1'
31
30
  program :description, '#{description}'
32
31
 
33
32
  ...
@@ -47,6 +46,7 @@ command :init do |c|
47
46
  ...
48
47
  end
49
48
  end
49
+ File.chmod 0755, file
50
50
  say "Initialized template in #{file}"
51
51
  rescue Exception => e
52
52
  abort e
@@ -1,6 +1,6 @@
1
1
 
2
- class Array
3
-
2
+ class Array
3
+
4
4
  ##
5
5
  # Split _string_ into an array. Used in
6
6
  # conjunction with Highline's #ask, or #ask_for_array
@@ -10,16 +10,17 @@ class Array
10
10
  # the arguments foo bar\ baz will become ['foo', 'bar baz']
11
11
  #
12
12
  # === Example
13
- #
13
+ #
14
14
  # # ask invokes Array#parse
15
15
  # list = ask 'Favorite cookies:', Array
16
16
  #
17
17
  # # or use ask_for_CLASS
18
18
  # list = ask_for_array 'Favorite cookies: '
19
19
  #
20
-
20
+
21
21
  def self.parse string
22
- eval "%w(#{string})"
22
+ # Using reverse + lookahead to work around Ruby 1.8's lack of lookbehind
23
+ string.reverse.split(/\s(?!\\)/).reverse.map { |s| s.reverse.gsub('\\ ', ' ') }
23
24
  end
24
-
25
+
25
26
  end
@@ -223,7 +223,7 @@ module Commander
223
223
 
224
224
  def valid_command_names_from *args
225
225
  arg_string = args.delete_if { |value| value =~ /^-/ }.join ' '
226
- commands.keys.find_all { |name| name if /^#{name}/.match arg_string }
226
+ commands.keys.find_all { |name| name if /^#{name}\b/.match arg_string }
227
227
  end
228
228
 
229
229
  ##
@@ -1,3 +1,3 @@
1
1
  module Commander
2
- VERSION = '4.1.2'
3
- end
2
+ VERSION = '4.1.3'
3
+ end
@@ -1,15 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Array do
4
-
4
+
5
5
  describe "#parse" do
6
6
  it "should seperate a list of words into an array" do
7
7
  Array.parse('just a test').should eq(['just', 'a', 'test'])
8
8
  end
9
-
9
+
10
10
  it "should preserve escaped whitespace" do
11
11
  Array.parse('just a\ test').should eq(['just', 'a test'])
12
12
  end
13
+
14
+ it "should match %w behavior with multiple backslashes" do
15
+ str = 'just a\\ test'
16
+ Array.parse(str).should eq(eval("%w(#{str})"))
17
+ end
13
18
  end
14
19
 
15
20
  end
@@ -361,6 +361,11 @@ describe Commander do
361
361
  it "should return empty array when no possible command names exist" do
362
362
  command_runner.valid_command_names_from('fake', 'command', 'name').should eq([])
363
363
  end
364
+
365
+ it "should match exact commands only" do
366
+ command('foo') {}
367
+ command_runner.valid_command_names_from('foobar').should eq([])
368
+ end
364
369
  end
365
370
 
366
371
  describe "#command_name_from_args" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.2
4
+ version: 4.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-02-17 00:00:00.000000000Z
13
+ date: 2012-12-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: highline
17
- requirement: &70103334850040 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,15 @@ dependencies:
22
22
  version: 1.6.11
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70103334850040
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 1.6.11
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: rspec
28
- requirement: &70103334849540 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ~>
@@ -33,10 +38,15 @@ dependencies:
33
38
  version: '2'
34
39
  type: :development
35
40
  prerelease: false
36
- version_requirements: *70103334849540
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '2'
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: rake
39
- requirement: &70103334849160 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ! '>='
@@ -44,10 +54,15 @@ dependencies:
44
54
  version: '0'
45
55
  type: :development
46
56
  prerelease: false
47
- version_requirements: *70103334849160
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
48
63
  - !ruby/object:Gem::Dependency
49
64
  name: simplecov
50
- requirement: &70103334848700 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
51
66
  none: false
52
67
  requirements:
53
68
  - - ! '>='
@@ -55,7 +70,12 @@ dependencies:
55
70
  version: '0'
56
71
  type: :development
57
72
  prerelease: false
58
- version_requirements: *70103334848700
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
59
79
  description: The complete solution for Ruby command-line executables. Commander bridges
60
80
  the gap between other terminal related libraries you know and love (OptionParser,
61
81
  HighLine), while providing many new features, and an elegant API.
@@ -123,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
143
  version: '0'
124
144
  requirements: []
125
145
  rubyforge_project: commander
126
- rubygems_version: 1.8.16
146
+ rubygems_version: 1.8.22
127
147
  signing_key:
128
148
  specification_version: 3
129
149
  summary: The complete solution for Ruby command-line executables