slop 3.4.1 → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ 3.4.2 (2013-01-14)
2
+ ------------------
3
+
4
+ * Expose the Hash commands as public API.
5
+ * Deprecated `Slop.optspec`.
6
+ * Ensure help output prints to stdout, not stderr.
7
+
1
8
  3.4.1 (2013-01-13)
2
9
  ------------------
3
10
 
@@ -4,7 +4,7 @@ require 'slop/commands'
4
4
  class Slop
5
5
  include Enumerable
6
6
 
7
- VERSION = '3.4.1'
7
+ VERSION = '3.4.2'
8
8
 
9
9
  # The main Error class, all Exception classes inherit from this class.
10
10
  class Error < StandardError; end
@@ -91,6 +91,7 @@ class Slop
91
91
  #
92
92
  # Returns a new instance of Slop.
93
93
  def optspec(string, config = {})
94
+ warn "[DEPRECATED] `Slop.optspec` is deprecated and will be removed in version 4"
94
95
  config[:banner], optspec = string.split(/^--+$/, 2) if string[/^--+$/]
95
96
  lines = optspec.split("\n").reject(&:empty?)
96
97
  opts = Slop.new(config)
@@ -117,6 +118,9 @@ class Slop
117
118
  # The Array of Slop::Option objects tied to this Slop instance.
118
119
  attr_reader :options
119
120
 
121
+ # The Hash of sub-commands for this Slop instance.
122
+ attr_reader :commands
123
+
120
124
  # Create a new instance of Slop and optionally build options via a block.
121
125
  #
122
126
  # config - A Hash of configuration options.
@@ -139,7 +143,7 @@ class Slop
139
143
 
140
144
  if config[:help]
141
145
  on('-h', '--help', 'Display this help message.', :tail => true) do
142
- $stderr.puts help
146
+ puts help
143
147
  end
144
148
  end
145
149
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'slop'
3
- s.version = '3.4.1'
3
+ s.version = '3.4.2'
4
4
  s.summary = 'Option gathering made easy'
5
5
  s.description = 'A simple DSL for gathering options and parsing the command line'
6
6
  s.author = 'Lee Jarvis'
@@ -16,11 +16,11 @@ class SlopTest < TestCase
16
16
  ARGV.replace old_argv
17
17
  end
18
18
 
19
- def temp_stderr
20
- $stderr = StringIO.new
21
- yield $stderr.string
19
+ def temp_stdout
20
+ $stdout = StringIO.new
21
+ yield $stdout.string
22
22
  ensure
23
- $stderr = STDERR
23
+ $stdout = STDOUT
24
24
  end
25
25
 
26
26
  test "includes Enumerable" do
@@ -330,13 +330,13 @@ class SlopTest < TestCase
330
330
  end
331
331
 
332
332
  test "printing help with :help => true" do
333
- temp_stderr do |string|
333
+ temp_stdout do |string|
334
334
  opts = Slop.new(:help => true, :banner => false)
335
335
  opts.parse %w( --help )
336
336
  assert_equal " -h, --help Display this help message.\n", string
337
337
  end
338
338
 
339
- temp_stderr do |string|
339
+ temp_stdout do |string|
340
340
  opts = Slop.new(:help => true)
341
341
  opts.parse %w( --help )
342
342
  assert_equal "Usage: rake_test_loader [options]\n -h, --help Display this help message.\n", string
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slop
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-13 00:00:00.000000000 Z
12
+ date: 2013-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake