kdl 1.0.0.rc1 → 1.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ module KDL
2
+ module Types
3
+ class UUID < Value
4
+ RGX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
5
+
6
+ def self.call(value, type = 'uuid')
7
+ return nil unless value.is_a? ::KDL::Value::String
8
+
9
+ uuid = value.value.downcase
10
+ raise ArgumentError, "`#{value.value}' is not a valid uuid" unless uuid =~ RGX
11
+
12
+ new(uuid, type: type)
13
+ end
14
+ end
15
+ MAPPING['uuid'] = UUID
16
+ end
17
+ end
data/lib/kdl/types.rb ADDED
@@ -0,0 +1,22 @@
1
+ module KDL
2
+ module Types
3
+ MAPPING = {}
4
+ end
5
+ end
6
+
7
+ require 'kdl/types/date_time'
8
+ require 'kdl/types/duration'
9
+ require 'kdl/types/currency'
10
+ require 'kdl/types/country'
11
+ require 'kdl/types/ip'
12
+ require 'kdl/types/url'
13
+ require 'kdl/types/uuid'
14
+ require 'kdl/types/regex'
15
+ require 'kdl/types/base64'
16
+ require 'kdl/types/decimal'
17
+ require 'kdl/types/hostname'
18
+ require 'kdl/types/email'
19
+ require 'kdl/types/irl'
20
+ require 'kdl/types/url_template'
21
+
22
+ KDL::Types::MAPPING.freeze
data/lib/kdl/value.rb CHANGED
@@ -8,8 +8,19 @@ module KDL
8
8
  @type = type
9
9
  end
10
10
 
11
- def as_type(type)
12
- self.class.new(value, format: format, type: type)
11
+ def as_type(type, parser = nil)
12
+ if parser.nil?
13
+ self.class.new(value, format: format, type: type)
14
+ else
15
+ result = parser.call(self, type)
16
+ return self.as_type(type) if result.nil?
17
+
18
+ unless result.is_a?(::KDL::Value)
19
+ raise ArgumentError, "expected parser to return an instance of ::KDL::Value, got `#{result.class}'"
20
+ end
21
+
22
+ result
23
+ end
13
24
  end
14
25
 
15
26
  def to_s
data/lib/kdl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module KDL
2
- VERSION = "1.0.0.rc1"
2
+ VERSION = "1.0.0.rc2"
3
3
  end
data/lib/kdl.rb CHANGED
@@ -4,10 +4,11 @@ require "kdl/document"
4
4
  require "kdl/value"
5
5
  require "kdl/node"
6
6
  require "kdl/string_dumper"
7
+ require "kdl/types"
7
8
  require "kdl/kdl.tab"
8
9
 
9
10
  module KDL
10
- def self.parse_document(input)
11
- Parser.new.parse(input)
11
+ def self.parse_document(input, options = {})
12
+ Parser.new.parse(input, options)
12
13
  end
13
14
  end
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.0.rc1
4
+ version: 1.0.0.rc2
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-09-28 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: racc
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simpleidn
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.1
27
41
  description: Ruby implementation of the KDL Document Language Spec
28
42
  email:
29
43
  - danini@hey.com
@@ -51,6 +65,28 @@ files:
51
65
  - lib/kdl/node.rb
52
66
  - lib/kdl/string_dumper.rb
53
67
  - lib/kdl/tokenizer.rb
68
+ - lib/kdl/types.rb
69
+ - lib/kdl/types/base64.rb
70
+ - lib/kdl/types/country.rb
71
+ - lib/kdl/types/country/iso3166_countries.rb
72
+ - lib/kdl/types/country/iso3166_subdivisions.rb
73
+ - lib/kdl/types/currency.rb
74
+ - lib/kdl/types/currency/iso4217_currencies.rb
75
+ - lib/kdl/types/date_time.rb
76
+ - lib/kdl/types/decimal.rb
77
+ - lib/kdl/types/duration.rb
78
+ - lib/kdl/types/duration/iso8601_parser.rb
79
+ - lib/kdl/types/email.rb
80
+ - lib/kdl/types/email/parser.rb
81
+ - lib/kdl/types/hostname.rb
82
+ - lib/kdl/types/hostname/validator.rb
83
+ - lib/kdl/types/ip.rb
84
+ - lib/kdl/types/irl.rb
85
+ - lib/kdl/types/irl/parser.rb
86
+ - lib/kdl/types/regex.rb
87
+ - lib/kdl/types/url.rb
88
+ - lib/kdl/types/url_template.rb
89
+ - lib/kdl/types/uuid.rb
54
90
  - lib/kdl/value.rb
55
91
  - lib/kdl/version.rb
56
92
  homepage: https://kdl.dev
@@ -68,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
104
  requirements:
69
105
  - - ">="
70
106
  - !ruby/object:Gem::Version
71
- version: 2.3.0
107
+ version: 2.4.0
72
108
  required_rubygems_version: !ruby/object:Gem::Requirement
73
109
  requirements:
74
110
  - - ">"