samovar 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/samovar/many.rb +10 -3
- data/lib/samovar/one.rb +10 -3
- data/lib/samovar/split.rb +10 -3
- data/lib/samovar/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6014f824c6dfa4a7d93f58d12a580eed8d47e6a9
|
4
|
+
data.tar.gz: 292f00004c02a16ad603b7ccbabf69ea79fe26bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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
|
data/lib/samovar/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mapping
|