kdl 1.0.1 → 1.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/lib/kdl/types/base64.rb +6 -0
- data/lib/kdl/types/email.rb +4 -0
- data/lib/kdl/types/hostname.rb +4 -0
- data/lib/kdl/types/url_template.rb +2 -2
- data/lib/kdl/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7fd58e017395f4ce4c67e04d8c4324c27bfe816926a41ebf0a813231cbe3eaf
|
4
|
+
data.tar.gz: 5ad57dac159e4fabe083f209cf0d0bb07735ed533859da539b0c0796b2d3dc70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c84ac4702188843e47041424d50e35ed19dcacbc8c9ce334a4036e6a8f2201f6d3dc420c9fbd6a5262fd42e1e387090c4ffe1575b4a7d92081a5776844e5492
|
7
|
+
data.tar.gz: 4b02a0867a5ae9cc0e698df0308d91f9fa8b41a96e14ad5efd8b51e95659e3e20196a2d1c197e9dc6e0f96710f632e0d9295342e18e069b6313eac49a5841c72
|
data/lib/kdl/types/base64.rb
CHANGED
@@ -3,9 +3,15 @@ require 'base64'
|
|
3
3
|
module KDL
|
4
4
|
module Types
|
5
5
|
class Base64 < Value
|
6
|
+
RGX = /^[A-Za-z0-9+\/=]+$/.freeze
|
7
|
+
|
6
8
|
def self.call(value, type = 'base64')
|
7
9
|
return nil unless value.is_a? ::KDL::Value::String
|
8
10
|
|
11
|
+
unless RGX.match?(value.value)
|
12
|
+
raise ArgumentError, "invalid base64: #{value.value}"
|
13
|
+
end
|
14
|
+
|
9
15
|
data = ::Base64.decode64(value.value)
|
10
16
|
new(data, type: type)
|
11
17
|
end
|
data/lib/kdl/types/email.rb
CHANGED
@@ -12,6 +12,8 @@ module KDL
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.call(value, type = 'email')
|
15
|
+
return nil unless value.is_a? ::KDL::Value::String
|
16
|
+
|
15
17
|
local, domain = Parser.new(value.value).parse
|
16
18
|
|
17
19
|
new(value.value, type: type, local: local, domain: domain)
|
@@ -29,6 +31,8 @@ module KDL
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def self.call(value, type = 'email')
|
34
|
+
return nil unless value.is_a? ::KDL::Value::String
|
35
|
+
|
32
36
|
local, domain, unicode_domain = Email::Parser.new(value.value, idn: true).parse
|
33
37
|
|
34
38
|
new("#{local}@#{domain}", type: type, local: local, domain: domain, unicode_domain: unicode_domain)
|
data/lib/kdl/types/hostname.rb
CHANGED
@@ -4,6 +4,8 @@ module KDL
|
|
4
4
|
module Types
|
5
5
|
class Hostname < Value
|
6
6
|
def self.call(value, type = 'hostname')
|
7
|
+
return nil unless value.is_a? ::KDL::Value::String
|
8
|
+
|
7
9
|
validator = Validator.new(value.value)
|
8
10
|
raise ArgumentError, "invalid hostname #{value}" unless validator.valid?
|
9
11
|
|
@@ -21,6 +23,8 @@ module KDL
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def self.call(value, type = 'idn-hostname')
|
26
|
+
return nil unless value.is_a? ::KDL::Value::String
|
27
|
+
|
24
28
|
validator = Validator.new(value.value)
|
25
29
|
raise ArgumentError, "invalid hostname #{value}" unless validator.valid?
|
26
30
|
|
@@ -53,7 +53,7 @@ module KDL
|
|
53
53
|
when '+' then ReservedExpansion
|
54
54
|
when '#' then FragmentExpansion
|
55
55
|
when '.' then LabelExpansion
|
56
|
-
when '/' then
|
56
|
+
when '/' then PathExpansion
|
57
57
|
when ';' then ParameterExpansion
|
58
58
|
when '?' then QueryExpansion
|
59
59
|
when '&' then QueryContinuation
|
@@ -275,7 +275,7 @@ module KDL
|
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
278
|
-
class
|
278
|
+
class PathExpansion < StringExpansion
|
279
279
|
def prefix
|
280
280
|
'/'
|
281
281
|
end
|
data/lib/kdl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kdl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danielle Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: racc
|