dreck 0.0.1 → 0.0.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 +4 -4
- data/README.md +8 -1
- data/lib/dreck.rb +1 -1
- data/lib/dreck/parser.rb +2 -4
- data/lib/dreck/result.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e092368a712551dfe8ffcc0b0cb01ef2cff5f20
|
4
|
+
data.tar.gz: 87aec6c08190dbf3a297ef3fe478aedbd5358ada
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f0c34b531a9d8fd59e602a738fa27741d0db8934c8f881575180fd9b8ce4ea0fc1c4629205f136dab9987a7c30f99edb0ab96948e7b5ca2246bc7083b67b650
|
7
|
+
data.tar.gz: cd634371172bfd2d512392c2eb0f46e3bdab3129ffe903b0bc8fa3393efd544d86b8768de407616abe89aa045dbd2f271aff42d6c7aef83c86eb5f8a2d37d478
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
dreck
|
2
2
|
=====
|
3
3
|
|
4
|
+
[](https://badge.fury.io/rb/dreck)
|
5
|
+
|
4
6
|
A stupid parser for trailing arguments.
|
5
7
|
|
6
8
|
### Motivation
|
@@ -55,7 +57,12 @@ result = Dreck.parse opts.args do
|
|
55
57
|
list :int, :nums
|
56
58
|
end
|
57
59
|
|
58
|
-
result[:
|
60
|
+
result[:uuid] # => "01aa84ab-5b2c-4861-adc9-fcc6990a5ca5"
|
59
61
|
result[:inputs] # => ["/tmp/foo", "/tmp/bar"]
|
60
62
|
result[:nums] # => [1, 2, 3, 4, 5]
|
61
63
|
```
|
64
|
+
|
65
|
+
### TODO
|
66
|
+
|
67
|
+
* Guarding against multiple unbound lists/unbound list before scalar types
|
68
|
+
* Custom types?
|
data/lib/dreck.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative "dreck/result"
|
|
5
5
|
# The primary namespace for {Dreck}.
|
6
6
|
module Dreck
|
7
7
|
# {Dreck}'s current version.
|
8
|
-
VERSION = "0.0.
|
8
|
+
VERSION = "0.0.2"
|
9
9
|
|
10
10
|
# Parse the given arguments and produce a result.
|
11
11
|
# @param args [Array<String>] the arguments to parse
|
data/lib/dreck/parser.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "parser"
|
4
|
-
|
5
3
|
module Dreck
|
6
4
|
# Type and other constraint testing methods for {Dreck}.
|
7
5
|
class Parser
|
@@ -58,12 +56,12 @@ module Dreck
|
|
58
56
|
# @return [String] the coerced string
|
59
57
|
# @note This does nothing.
|
60
58
|
def parse_string(str)
|
61
|
-
str
|
59
|
+
str.to_s
|
62
60
|
end
|
63
61
|
|
64
62
|
# @param type [Symbol] the type of each member of the list
|
65
63
|
# @param list [Array<String>] the value of each member
|
66
|
-
# @return [Object] the coerced results
|
64
|
+
# @return [Array<Object>] the coerced results
|
67
65
|
def parse_list(type, list)
|
68
66
|
list.map { |arg| send "parse_#{type}", arg }
|
69
67
|
end
|
data/lib/dreck/result.rb
CHANGED
@@ -71,8 +71,8 @@ module Dreck
|
|
71
71
|
count = count_expected
|
72
72
|
|
73
73
|
return if count.nil?
|
74
|
-
raise
|
75
|
-
raise
|
74
|
+
raise AbsorptionError, "too few arguments" if count > @args.size && strict?
|
75
|
+
raise AbsorptionError, "too many arguments" if count < @args.size && strict?
|
76
76
|
end
|
77
77
|
|
78
78
|
# Count the number of arguments expected to be supplied.
|