dreck 0.0.7 → 0.1.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 +4 -4
- data/lib/dreck.rb +1 -1
- data/lib/dreck/exceptions.rb +13 -6
- data/lib/dreck/result.rb +2 -2
- 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: 79881a5433a29683e6c61380f0a52a29ce443c13
|
4
|
+
data.tar.gz: 04e7ae02e53f85e3b86384e9ef055b0e3262776a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a97e85038cc19205c7cc69c7534d9a8e189a72122b4983877f6aa758bf92ea88ad214869eef5d7c51fb54b6be1ad120a2f3f2744c29b7b937b0e950c461790b
|
7
|
+
data.tar.gz: a467df281d0b7e1c7b3c33a0a67482394915a40d623a47148d04b7e6cdba0773df00f4a7a7e53427b5dacd27299ebb1b1557001c96813d0313018dadb7113506
|
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.1.0"
|
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/exceptions.rb
CHANGED
@@ -10,12 +10,19 @@ module Dreck
|
|
10
10
|
class AbsorptionError < DreckError
|
11
11
|
# @param actual [Integer] the actual number of arguments given
|
12
12
|
# @param expected [Integer] the expected number of arguments
|
13
|
-
|
14
|
-
|
15
|
-
nmany
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
def initialize(actual, expected)
|
14
|
+
nmany = actual < expected ? "too few" : "too many"
|
15
|
+
super "#{nmany} arguments given (#{actual}, expected #{expected})"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Raised during argument absorption if a greedy list was expected but all arguments
|
20
|
+
# have already been absorbed.
|
21
|
+
class GreedyAbsorptionError < DreckError
|
22
|
+
# @param actual [Integer] the actual number of arguments given
|
23
|
+
# @param expected [Integer] the expected number of arguments
|
24
|
+
def initialize(actual, expected)
|
25
|
+
super "too few arguments given (>#{actual}, expected >#{expected})"
|
19
26
|
end
|
20
27
|
end
|
21
28
|
|
data/lib/dreck/result.rb
CHANGED
@@ -70,10 +70,10 @@ module Dreck
|
|
70
70
|
def check_absorption!
|
71
71
|
count, greedy = count_expected
|
72
72
|
|
73
|
-
return if greedy && @args.size >= count
|
74
73
|
return unless strict?
|
75
74
|
|
76
|
-
raise
|
75
|
+
raise GreedyAbsorptionError.new(count, @args.size) if count >= @args.size && greedy
|
76
|
+
raise AbsorptionError.new(count, @args.size) if count != @args.size && !greedy
|
77
77
|
end
|
78
78
|
|
79
79
|
# Count the number of arguments expected to be supplied.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dreck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Woodruff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Typechecks and coerces non-option arguments.
|
14
14
|
email: william@tuffbizz.com
|