optix 1.0.3 → 1.1.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/README.md CHANGED
@@ -8,7 +8,7 @@ Optix is an unobtrusive, composable command line parser based on Trollop.
8
8
  * Lightweight, unobtrusive syntax.
9
9
  No subclassing or introduction of dependencies.
10
10
 
11
- * Supports subcommands such as `git remote show origin` with arbitrary nesting.
11
+ * Nested subcommands such as `git remote show origin` may be composed at runtime in arbitrary order.
12
12
 
13
13
  * Subcommands inherit from their parent. Common options (such as '--debug' or '--loglevel')
14
14
  need to be declared only once to make them available to an entire branch.
@@ -18,6 +18,8 @@ Optix is an unobtrusive, composable command line parser based on Trollop.
18
18
 
19
19
  * Automatic validation and help-screens.
20
20
 
21
+ * Should work on all major Ruby versions (tested on 1.9.3, 1.9.2 and 1.8.7).
22
+
21
23
  * Strong test-suite.
22
24
 
23
25
  ## Installation
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ RSpec::Core::RakeTask.new("test:spec") do |t|
9
9
  t.pattern = 'spec/*_spec.rb'
10
10
  t.rcov = false
11
11
  #t.rspec_opts = '-b -c -f progress --tag ~benchmark'
12
- t.rspec_opts = '-b -c -f documentation --tag ~benchmark'
12
+ t.rspec_opts = '--fail-fast -b -c -f documentation --tag ~benchmark'
13
13
  end
14
14
 
15
15
  RSpec::Core::RakeTask.new("test:benchmark") do |t|
data/lib/optix.rb CHANGED
@@ -59,24 +59,21 @@ class Optix
59
59
  o[:params] = @@config[:text_param_subcommand]
60
60
  end
61
61
 
62
- text = o[:header].gsub('%0', $0)
63
- .gsub('%command', cmdpath.join(' '))
64
- .gsub('%params', o[:params])
65
- .gsub(/ +/, ' ')
62
+ text = o[:header].gsub('%0', $0).gsub('%command', cmdpath.join(' ')).gsub('%params', o[:params]).gsub(/ +/, ' ')
66
63
 
67
64
  calls = []
68
- calls << [:banner, [text], nil]
65
+ calls << [:nowrap, [text], nil]
69
66
 
70
67
  calls << [:banner, [' '], nil]
71
68
  unless o[:text].nil?
72
- calls << [:banner, o[:text], nil]
69
+ calls << [:banner, [o[:text]], nil]
73
70
  calls << [:banner, [' '], nil]
74
71
  end
75
72
 
76
73
  # sort opts and move non-opt calls to the end
77
74
  non_opt = parent_calls.select {|x| x[0] != :opt }
78
- parent_calls.select! {|x| x[0] == :opt }
79
- parent_calls.sort! {|a,b| ; a[1][0] <=> b[1][0] }
75
+ parent_calls = parent_calls.select {|x| x[0] == :opt }
76
+ parent_calls.sort! {|a,b| ; a[1][0].to_s <=> b[1][0].to_s }
80
77
  parent_calls += non_opt
81
78
  parent_calls.unshift([:banner, [@@config[:text_header_options]], nil])
82
79
  calls += parent_calls
data/lib/optix/trollop.rb CHANGED
@@ -246,6 +246,9 @@ class Parser
246
246
  def banner s; @order << [:text, s] end
247
247
  alias :text :banner
248
248
 
249
+ ## Adds text to the help display without wrapping.
250
+ def nowrap s; @order << [:nowrap, s] end
251
+
249
252
  ## Marks two (or more!) options as requiring each other. Only handles
250
253
  ## undirected (i.e., mutual) dependencies. Directed dependencies are
251
254
  ## better modeled with Trollop::die.
@@ -480,6 +483,11 @@ class Parser
480
483
  next
481
484
  end
482
485
 
486
+ if what == :nowrap
487
+ stream.puts opt
488
+ next
489
+ end
490
+
483
491
  spec = @specs[opt]
484
492
  #next if @no_help_help and opt == :help
485
493
  stream.printf " %#{leftcol_width}s: ", left[opt]
data/lib/optix/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Optix
2
- VERSION = "1.0.3"
1
+ class Optix
2
+ VERSION = "1.1.0"
3
3
  end
data/optix.gemspec CHANGED
@@ -17,5 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.version = Optix::VERSION
18
18
 
19
19
  gem.add_dependency "chronic"
20
+
21
+ gem.add_development_dependency "rake"
22
+ gem.add_development_dependency "rspec"
20
23
  gem.add_development_dependency "simplecov"
21
24
  end
data/spec/spec_helper.rb CHANGED
@@ -1,22 +1,6 @@
1
1
  require 'simplecov'
2
2
  SimpleCov.start
3
3
 
4
- RSpec::Matchers.define :have_stdout do |regex|
5
- define_method :has_stdout? do |actual|
6
- regex = /^#{Regexp.escape(regex)}$/ if regex.is_a?(String)
7
-
8
- $stdout = StringIO.new
9
- actual.call
10
- $stdout.rewind
11
- captured = $stdout.read
12
-
13
- $stdout = STDOUT
14
- captured =~ regex
15
- end
16
- match { |actual| has_stdout?(actual) }
17
- end
18
-
19
-
20
4
  def capture_streams(stdin_str = '')
21
5
  begin
22
6
  require 'stringio'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-09 00:00:00.000000000Z
12
+ date: 2012-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chronic
16
- requirement: &16186640 !ruby/object:Gem::Requirement
16
+ requirement: &4581720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,32 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16186640
24
+ version_requirements: *4581720
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &4580900 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *4580900
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &4579220 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *4579220
25
47
  - !ruby/object:Gem::Dependency
26
48
  name: simplecov
27
- requirement: &16182560 !ruby/object:Gem::Requirement
49
+ requirement: &4594820 !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ! '>='
@@ -32,7 +54,7 @@ dependencies:
32
54
  version: '0'
33
55
  type: :development
34
56
  prerelease: false
35
- version_requirements: *16182560
57
+ version_requirements: *4594820
36
58
  description: Optix is an unobtrusive, composable command line parser.
37
59
  email:
38
60
  - moe@busyloop.net
@@ -65,12 +87,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
87
  - - ! '>='
66
88
  - !ruby/object:Gem::Version
67
89
  version: '0'
90
+ segments:
91
+ - 0
92
+ hash: 1556456279788703897
68
93
  required_rubygems_version: !ruby/object:Gem::Requirement
69
94
  none: false
70
95
  requirements:
71
96
  - - ! '>='
72
97
  - !ruby/object:Gem::Version
73
98
  version: '0'
99
+ segments:
100
+ - 0
101
+ hash: 1556456279788703897
74
102
  requirements: []
75
103
  rubyforge_project:
76
104
  rubygems_version: 1.8.10
@@ -80,4 +108,3 @@ summary: Optix is an unobtrusive, composable command line parser.
80
108
  test_files:
81
109
  - spec/optix_spec.rb
82
110
  - spec/spec_helper.rb
83
- has_rdoc: false