samovar 1.6.0 → 1.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06e76d86b275ed684abaabcadd799765248b67d8
4
- data.tar.gz: 5dbb428a9e5523779b394d3c14cb8661ca14271c
3
+ metadata.gz: 6014f824c6dfa4a7d93f58d12a580eed8d47e6a9
4
+ data.tar.gz: 292f00004c02a16ad603b7ccbabf69ea79fe26bf
5
5
  SHA512:
6
- metadata.gz: e412c9871a224a1ad5049fd9d13a94dc1cf6f3f1a6b5c4bb2a92f085ce3a7b629f9a2ab142fe428b1e6a766c2252ef93eaf059b3d92e9bd48582fa9aca6c5abd
7
- data.tar.gz: ba4f76b3c6b9457647cf8132e02d94df20add0d19e6c7c610ca2277291544db21e767735b4a9850a4756fd765e341c8ecefa3ecc4d0016b063e008a8d1a9f3d9
6
+ metadata.gz: 92b356e5330830a7b82e0cc85fb574688167d3748ae5ede4ccaab970110a690821f1da4d49bc913e79f493c83baa2d721599dc3b1bb3c9f1cfc29c0a9e79beb9
7
+ data.tar.gz: 267c1a904ac4ec70ec74465a00443ef9be80bf9ac0321035388bcf74e33a5fdbef1c3b330208300bd440f259cd10da8f5d7ce7d7073faa2caec41b96e74f2b65
data/lib/samovar/many.rb CHANGED
@@ -20,10 +20,11 @@
20
20
 
21
21
  module Samovar
22
22
  class Many
23
- def initialize(key, description, stop: /^-/)
23
+ def initialize(key, description, stop: /^-/, default: nil)
24
24
  @key = key
25
25
  @description = description
26
26
  @stop = stop
27
+ @default = default
27
28
  end
28
29
 
29
30
  attr :key
@@ -33,10 +34,16 @@ module Samovar
33
34
  end
34
35
 
35
36
  def to_a
36
- [to_s, @description]
37
+ usage = [to_s, @description]
38
+
39
+ if @default
40
+ usage << "Default: #{@default.inspect}"
41
+ end
42
+
43
+ return usage
37
44
  end
38
45
 
39
- def parse(input, default)
46
+ def parse(input, default = @default)
40
47
  if @stop and stop_index = input.index{|item| @stop === item}
41
48
  input.shift(stop_index)
42
49
  else
data/lib/samovar/one.rb CHANGED
@@ -20,10 +20,11 @@
20
20
 
21
21
  module Samovar
22
22
  class One
23
- def initialize(key, description, pattern: //)
23
+ def initialize(key, description, pattern: //, default: nil)
24
24
  @key = key
25
25
  @description = description
26
26
  @pattern = pattern
27
+ @default = default
27
28
  end
28
29
 
29
30
  attr :key
@@ -33,10 +34,16 @@ module Samovar
33
34
  end
34
35
 
35
36
  def to_a
36
- [to_s, @description]
37
+ usage = [to_s, @description]
38
+
39
+ if @default
40
+ usage << "Default: #{@default.inspect}"
41
+ end
42
+
43
+ return usage
37
44
  end
38
45
 
39
- def parse(input, default)
46
+ def parse(input, default = @default)
40
47
  if input.first =~ @pattern
41
48
  input.shift
42
49
  end || default
data/lib/samovar/split.rb CHANGED
@@ -20,10 +20,11 @@
20
20
 
21
21
  module Samovar
22
22
  class Split
23
- def initialize(key, description, marker: '--')
23
+ def initialize(key, description, marker: '--', default: nil)
24
24
  @key = key
25
25
  @description = description
26
26
  @marker = marker
27
+ @default = default
27
28
  end
28
29
 
29
30
  attr :key
@@ -33,10 +34,16 @@ module Samovar
33
34
  end
34
35
 
35
36
  def to_a
36
- [to_s, @description]
37
+ usage = [to_s, @description]
38
+
39
+ if @default
40
+ usage << "Default: #{@default.inspect}"
41
+ end
42
+
43
+ return usage
37
44
  end
38
45
 
39
- def parse(input, default = nil)
46
+ def parse(input, default = @default)
40
47
  if offset = input.index(@marker)
41
48
  input.pop(input.size - offset).tap(&:shift)
42
49
  end || default
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Samovar
22
- VERSION = "1.6.0"
22
+ VERSION = "1.7.0"
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samovar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-06 00:00:00.000000000 Z
11
+ date: 2017-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mapping