has_keyword_argument 0.0.1 → 0.1.1
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/has_keyword_argument.rb +14 -26
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f62bfeac10d810ec8e454f8e2c2206a70bd92beb
|
4
|
+
data.tar.gz: 4bba437a0b8d0e571facdd9e7d61498c1f753d1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c48e17f2887f6956d4d7a0ea54037b300baa92026d3029df612d25c6c16e6fbd70e306b9647a5d19aecf78ce0b4e9887eed5f9e062c026ef13ada4ba6bcecc2
|
7
|
+
data.tar.gz: 8224d484a0bd5d8ef8f21cb30883dfcd4a1bd03a003aec9f5062ac25f3b40fe60d3fe5496bca178d95a3fef6859e321af630f0656313de0864eb1f61654bf960
|
data/lib/has_keyword_argument.rb
CHANGED
@@ -1,33 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
class Symbol
|
2
|
+
def has_keyword_argument? *keyword
|
3
|
+
keyword.uniq!
|
4
|
+
keyword.each_with_index do |keywd, i|
|
5
|
+
unless keywd.is_a? Symbol
|
6
|
+
raise ArgumentError, "Expected all `keyword´ to be Symbol, argument #{i} is #{keywd.class}"
|
7
|
+
end
|
8
|
+
end
|
5
9
|
|
6
|
-
|
7
|
-
raise ArgumentError, '`keyword` must be String or Array'
|
8
|
-
end
|
10
|
+
keyreq_params = []
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
params = method(self).parameters
|
13
|
+
params.each do |param|
|
14
|
+
if param.first == :keyreq
|
15
|
+
keyreq_params << param.last
|
14
16
|
end
|
15
17
|
end
|
16
|
-
end
|
17
|
-
|
18
|
-
output = keyword
|
19
|
-
begin
|
20
|
-
method.call
|
21
|
-
rescue ArgumentError => e
|
22
|
-
output = e.message.split(':').first == 'missing keyword' ? e.message.split(':').last : e.message
|
23
18
|
|
24
|
-
|
25
|
-
# output = flunk("missing keyword: #{keyword.join(': ')}")
|
26
|
-
#else
|
27
|
-
# output = flunk("missing keyword: #{keyword}")
|
28
|
-
#end
|
19
|
+
keyreq_params.must_equal keyreq_params & keyword
|
29
20
|
end
|
30
|
-
|
31
|
-
return output
|
32
21
|
end
|
33
|
-
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_keyword_argument
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Eriksson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: README.md
|
14
14
|
email: joel.eriksson@protonmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
@@ -40,5 +40,5 @@ rubyforge_project:
|
|
40
40
|
rubygems_version: 2.5.1
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
|
-
summary: A gem for use with
|
43
|
+
summary: A gem for use with Minitest to check if certain keyword arguments are used
|
44
44
|
test_files: []
|