slop 4.8.1 → 4.8.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ec00c622e6cf0e93fdcebfa0964225fd2a2be127fcf21191a47bb96a64afb2b
4
- data.tar.gz: 129ca3a92e02e2ac696c4a1dbc805a6316e59f8802d7c06fe3b071ef4467e6e4
3
+ metadata.gz: b79c8ecabc4f59e446e17b38a61381a4711e1da44918d5bfa3c459e3330fa7c5
4
+ data.tar.gz: 6a5c4c2b6a0624a0f533ea86bc7855774a23d134d581f178d2d6fa476b01da59
5
5
  SHA512:
6
- metadata.gz: b6280d06c83bafc75d2b2169d0c08ac1470031777aad641a162dda1657dbaa8940dad56ae20431fe7dc34eba52ab6a6f42a8dbb0207ad0f568cc21d5ed84884d
7
- data.tar.gz: ce64d1d1d442cbb4a09c130e14a7f4d9837d53cf6ed2b4b4c3db1264650ebaba50cf500418737bbf265940dc2f430c14b30641394aca1b5626680fec4d4f4411
6
+ metadata.gz: 15ac86c2fe54c3c5dffb8d186e50341febfa6ed858eedae5347a416fc9261159262d68873645c7bb11d1cc2155473f6deb3a8740da2c4fcc1a78f0f477cccfc8
7
+ data.tar.gz: d1a078ebc9c8ddd2b970e9cc39dcf72fc20b3e67a50abed4bf51a7d22bafe8ae7170c03930bf8d3073f487d167f6f27fe1475b5e5735b4bf2090efa446a0eff5
@@ -1,6 +1,13 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ v4.8.2 (2020-07-10)
5
+ -------------------
6
+
7
+ Bug fixes:
8
+ * Fix bug where separator position was messed up if using `help: false`
9
+ [#253](https://github.com/leejarvis/slop/issues/253)
10
+
4
11
  v4.8.1 (2020-03-31)
5
12
  -------------------
6
13
 
data/README.md CHANGED
@@ -3,9 +3,6 @@ Slop
3
3
 
4
4
  Slop is a simple option parser with an easy to remember syntax and friendly API.
5
5
 
6
- Version 4 of Slop is aimed at Ruby 2.0 or later. Please use
7
- [Version 3](https://github.com/leejarvis/slop/tree/v3) for Ruby 1.9 support.
8
-
9
6
  [![Build Status](https://travis-ci.org/leejarvis/slop.svg?branch=master)](http://travis-ci.org/leejarvis/slop)
10
7
 
11
8
  Installation
@@ -275,87 +272,4 @@ end
275
272
  Commands
276
273
  --------
277
274
 
278
- As of version 4, Slop does not have built in support for git-style subcommands.
279
- You can use version 3 of Slop (see `v3` branch).
280
-
281
- Upgrading from version 3
282
- ------------------------
283
-
284
- Slop v4 is not backwards compatible. The code has been completely rewritten.
285
- If you're already using version 3 you *have* to update your code to use version 4.
286
- Here's an overview of the large changes:
287
-
288
- #### No more `instance_eval`
289
-
290
- Before:
291
-
292
- ```ruby
293
- Slop.parse do
294
- on 'v', 'version' do
295
- puts VERSION
296
- end
297
- end
298
- ```
299
-
300
- After:
301
-
302
- ```ruby
303
- Slop.parse do |o|
304
- o.on '-v', '--version' do
305
- puts VERSION
306
- end
307
- end
308
- ```
309
-
310
- #### No more `as` for option types
311
-
312
- Instead, the type is declared in the method call. Before:
313
-
314
- ```ruby
315
- on 'port=', as: Integer
316
- ```
317
-
318
- After:
319
-
320
- ```ruby
321
- o.int '--port' # or integer
322
- ```
323
-
324
- See the custom types section of the document.
325
-
326
- #### No more trailing `=`
327
-
328
- Instead, the "does this option expect an argument?" question is answered by
329
- the option type (i.e `on` and `bool` options do not expect arguments, all
330
- others do). They handle type conversion, too.
331
-
332
- #### Hyphens are required
333
-
334
- This was a hard decision to make, but you must provide prefixed hyphens when
335
- declaring your flags. This improves the implementation nicer and makes things
336
- much less ambiguous, which leads to less error prone code. It also means you
337
- can easily support single hyphen prefix for a long flag, i.e `-hostname` which
338
- you could not do before. It also means you can provide infinite flag aliases:
339
- `o.string '-f', '-x', '--foo', '--bar', 'this is insane'`
340
-
341
- #### Strict is now on by default
342
-
343
- v3 had a `strict` option. v4 has no such option. To suppress errors you can
344
- instead provide the `suppress_errors: true` option to Slop.
345
-
346
- #### No more parse!
347
-
348
- Where v3 has both `Slop.parse` and `Slop.parse!`, v4 only has `parse`. The
349
- former was used to decide whether Slop should or should not mutate the
350
- original args (usually ARGV). This is almost never what you want, and it
351
- can lead to confusion. Instead, `Slop::Result` provides an `arguments`
352
- methods:
353
-
354
- ```ruby
355
- opts = Slop.parse do |o|
356
- o.string '--hostname', '...'
357
- end
358
-
359
- # ARGV is "hello --hostname foo bar"
360
- p opts.arguments #=> ["hello", "bar"]
361
- ```
275
+ Slop not longer has built in support for git-style subcommands.
@@ -6,7 +6,7 @@ require 'slop/types'
6
6
  require 'slop/error'
7
7
 
8
8
  module Slop
9
- VERSION = '4.8.1'
9
+ VERSION = '4.8.2'
10
10
 
11
11
  # Parse an array of options (defaults to ARGV). Accepts an
12
12
  # optional hash of configuration options and block.
@@ -102,13 +102,13 @@ module Slop
102
102
  str = config[:banner] ? "#{banner}\n" : ""
103
103
  len = longest_flag_length
104
104
 
105
- options.select(&:help?).each_with_index.sort_by{ |o,i| [o.tail, i] }.each do |opt, i|
105
+ options.select.each_with_index.sort_by{ |o,i| [o.tail, i] }.each do |opt, i|
106
106
  # use the index to fetch an associated separator
107
107
  if sep = separators[i]
108
108
  str << "#{sep}\n"
109
109
  end
110
110
 
111
- str << "#{prefix}#{opt.to_s(offset: len)}\n"
111
+ str << "#{prefix}#{opt.to_s(offset: len)}\n" if opt.help?
112
112
  end
113
113
 
114
114
  if sep = separators[options.size]
@@ -70,6 +70,17 @@ describe Slop::Options do
70
70
 
71
71
  assert_equal [""], @options.separators
72
72
  end
73
+
74
+ it "correctly handles options with `help: false`" do
75
+ @options.boolean "--opt1"
76
+ @options.boolean "--opt2", help: false
77
+ @options.separator "other options"
78
+ @options.boolean "--opt3", help: false
79
+ @options.boolean "--opt4"
80
+
81
+ _usage, help = @options.to_s.squeeze(" ").split("\n", 2)
82
+ assert_equal "--opt1 \nother options\n --opt4", help.strip
83
+ end
73
84
  end
74
85
 
75
86
  describe "#method_missing" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slop
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.1
4
+ version: 4.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Jarvis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-31 00:00:00.000000000 Z
11
+ date: 2020-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -71,7 +71,7 @@ homepage: http://github.com/leejarvis/slop
71
71
  licenses:
72
72
  - MIT
73
73
  metadata: {}
74
- post_install_message:
74
+ post_install_message:
75
75
  rdoc_options: []
76
76
  require_paths:
77
77
  - lib
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubygems_version: 3.0.3
90
- signing_key:
90
+ signing_key:
91
91
  specification_version: 4
92
92
  summary: Simple Lightweight Option Parsing
93
93
  test_files: