commandeer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .rbx
1
2
  test.rb
2
3
  Gemfile.lock
3
4
  .rvmrc
@@ -0,0 +1,9 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - rbx
6
+ - jruby
7
+ env:
8
+ - ISOLATED=true
9
+ script: "bundle exec rake test"
data/Gemfile CHANGED
@@ -1 +1,2 @@
1
1
  source "http://rubygems.org"
2
+ gemspec
@@ -14,4 +14,6 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "commandeer"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Commandeer::VERSION
17
+ gem.add_development_dependency "rake", "~> 0.9.2.2"
18
+ gem.add_development_dependency "minitest", "~> 2.8.1"
17
19
  end
@@ -1,5 +1,5 @@
1
1
  module Commandeer
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
 
4
4
  @commands = {}
5
5
 
@@ -42,15 +42,17 @@ module Commandeer
42
42
  if (args.size == 0) || (args[0] =~ /^-/)
43
43
  output = ''
44
44
  output << "Usage: #{@script_name} [command options] or [command subcommand options]\n\n"
45
- @commands.each do |command, options|
46
- next if (command==:klass || command==:parser)
47
- output << "\t#{command}\t"
45
+ @commands.keys.sort.each do |c|
46
+ options = @commands[c]
47
+ next if (c==:klass || c==:parser)
48
+ output << "\t#{c}"
48
49
  unless options["subcommands"].nil?
49
- output << "Subcommands:"
50
+ output << "\tSubcommands:"
50
51
  options["subcommands"].each do |sub, opts|
51
- output << " #{sub}"
52
+ output << "\t #{sub}"
52
53
  end
53
54
  end
55
+ output << "\n"
54
56
  end
55
57
  puts output
56
58
  exit
@@ -1,6 +1,7 @@
1
1
  $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
2
2
  $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "test")))
3
- gem 'minitest'
3
+ gem 'minitest' if RUBY_VERSION =~ /1.9/
4
+
4
5
  require 'minitest/pride'
5
6
  require 'minitest/autorun'
6
7
  require 'commandeer'
@@ -0,0 +1,11 @@
1
+ class CommandOne
2
+ include Commandeer
3
+
4
+ command "command_one"
5
+ end
6
+
7
+ class CommandTwo
8
+ include Commandeer
9
+
10
+ command "command_two"
11
+ end
@@ -33,7 +33,7 @@ class TestOverrideAll < MiniTest::Unit::TestCase
33
33
  rescue SystemExit
34
34
  end
35
35
  end
36
- assert_match(out, /^.*Usage.*\n\n\t.*override\tSubcommands: random.*$/)
36
+ assert_match(out, /^.*Usage.*\n\n\t.*override\tSubcommands:\t random.*$/)
37
37
  end
38
38
 
39
39
  def test_output_override
@@ -0,0 +1,26 @@
1
+ require "#{File.expand_path(File.join(File.dirname(__FILE__), "helper.rb"))}"
2
+
3
+ class TestMultipleCommands < MiniTest::Unit::TestCase
4
+ def setup
5
+ require 'helpers/multiple_commands.rb'
6
+ @commands = Commandeer.commands
7
+ end
8
+
9
+ def test_has_all_commands
10
+ ["command_one", "command_two"].each do |c|
11
+ assert_includes(@commands.keys, c)
12
+ end
13
+ end
14
+
15
+ # To ensure top-level commands are new-lined
16
+ def test_format_output
17
+ out, err = capture_io do
18
+ begin
19
+ Commandeer.parse!('')
20
+ rescue SystemExit
21
+ end
22
+ end
23
+
24
+ assert_match(out, /^.*Usage:.*\n\n\tcommand_one*\n\tcommand_two\n.*$/)
25
+ end
26
+ end
@@ -41,7 +41,7 @@ class TestSubOfRealCommand < MiniTest::Unit::TestCase
41
41
  rescue SystemExit
42
42
  end
43
43
  end
44
- assert_match(out, /^.*Usage.*\n\n\t.*parent\tSubcommands: child.*$/)
44
+ assert_match(out, /^.*Usage.*\n\n\tparent\tSubcommands:\t child.*$/)
45
45
  end
46
46
 
47
47
  def test_output_parent
@@ -33,7 +33,7 @@ class TestSubCommand < MiniTest::Unit::TestCase
33
33
  rescue SystemExit
34
34
  end
35
35
  end
36
- assert_match(out, /^.*Usage.*\n\n\t.*fakeparent\tSubcommands: bar.*$/)
36
+ assert_match(out, /^.*Usage.*\n\n\tfakeparent\tSubcommands:\t bar.*$/)
37
37
  end
38
38
 
39
39
  def test_output_fakeparent
metadata CHANGED
@@ -1,29 +1,47 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: commandeer
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
4
5
  prerelease:
5
- version: 0.1.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - John E. Vincent
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-12-05 00:00:00 Z
14
- dependencies: []
15
-
12
+ date: 2011-12-05 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &10334400 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.2.2
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *10334400
25
+ - !ruby/object:Gem::Dependency
26
+ name: minitest
27
+ requirement: &10384460 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.8.1
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *10384460
16
36
  description: Class-based CLI utility
17
- email:
37
+ email:
18
38
  - lusis.org+github.com@gmail.com
19
39
  executables: []
20
-
21
40
  extensions: []
22
-
23
41
  extra_rdoc_files: []
24
-
25
- files:
42
+ files:
26
43
  - .gitignore
44
+ - .travis.yml
27
45
  - Gemfile
28
46
  - LICENSE
29
47
  - README.md
@@ -33,41 +51,39 @@ files:
33
51
  - test/helper.rb
34
52
  - test/helpers/all_override.rb
35
53
  - test/helpers/command.rb
54
+ - test/helpers/multiple_commands.rb
36
55
  - test/helpers/namespaced.rb
37
56
  - test/helpers/sub_of_real_command.rb
38
57
  - test/helpers/subcommand.rb
39
58
  - test/test_all_override.rb
40
59
  - test/test_command.rb
41
60
  - test/test_methods.rb
61
+ - test/test_multiple_commands.rb
42
62
  - test/test_namespaced.rb
43
63
  - test/test_sub_of_real.rb
44
64
  - test/test_subcommand.rb
45
65
  homepage: https://github.com/lusis/commandeer
46
66
  licenses: []
47
-
48
67
  post_install_message:
49
68
  rdoc_options: []
50
-
51
- require_paths:
69
+ require_paths:
52
70
  - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
71
+ required_ruby_version: !ruby/object:Gem::Requirement
54
72
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: "0"
59
- required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
78
  none: false
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: "0"
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
65
83
  requirements: []
66
-
67
84
  rubyforge_project:
68
85
  rubygems_version: 1.8.6
69
86
  signing_key:
70
87
  specification_version: 3
71
88
  summary: Commandeer allows you to make any class a git style command or subcommand
72
89
  test_files: []
73
-