yarrow 0.8.6 → 0.8.7
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/.github/workflows/ruby.yml +1 -1
- data/lib/yarrow/config.rb +10 -0
- data/lib/yarrow/content/expansion/tree.rb +1 -0
- data/lib/yarrow/content/model.rb +2 -0
- data/lib/yarrow/schema/types.rb +41 -0
- data/lib/yarrow/version.rb +1 -1
- data/yarrow.gemspec +1 -0
- 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: 89667b38c1ebf2da983a381e20be9d8e0904bdb69137bb86a1bce6ee9507fbf1
|
4
|
+
data.tar.gz: 364c196cefad90398b10c387edb925b055490163be854b814f3522a6333234ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 113ce8dc745ec3e83121d5229beeed755671a7902e1330373ef7b129d7138048d090bbdb1abedd2458f0faca3f86f4433c30a855cc6a53119ba59576699f7002
|
7
|
+
data.tar.gz: 6b24b087284b3be6f2d55a8aa3afc25d0e3cc38dbbb2bd80bd9005487b9b95b3bf65d218a47c65b6ac9f4fd54e830a01984292bc1f0c4c8d1455b7af3a5b5049
|
data/.github/workflows/ruby.yml
CHANGED
data/lib/yarrow/config.rb
CHANGED
@@ -43,9 +43,19 @@ module Yarrow
|
|
43
43
|
# Yarrow::Schema.define do
|
44
44
|
# type :config_source_map, Yarrow::Schema::Types::Instance.of(Hash).accept(Symbol)
|
45
45
|
# end
|
46
|
+
# class PolicySpec < Yarrow::Schema::Entity[:__config_policy_spec]
|
47
|
+
# attribute :module, :string
|
48
|
+
# attribute :source_map, :__config_source_map
|
49
|
+
# end
|
50
|
+
|
51
|
+
# Yarrow::Schema::Definitions.register(
|
52
|
+
# :__config_source_map,
|
53
|
+
# Yarrow::Schema::Types::Map.of(Symbol)
|
54
|
+
# )
|
46
55
|
|
47
56
|
class Content < Yarrow::Schema::Entity[:__config_content]
|
48
57
|
attribute :module, :string
|
58
|
+
#attribute :source_map, :__config_source_map
|
49
59
|
attribute :source_map, :hash
|
50
60
|
end
|
51
61
|
|
data/lib/yarrow/content/model.rb
CHANGED
data/lib/yarrow/schema/types.rb
CHANGED
@@ -17,6 +17,10 @@ module Yarrow
|
|
17
17
|
def self.respond_to_all(t, m)
|
18
18
|
new("#{t} does not implement #{m}")
|
19
19
|
end
|
20
|
+
|
21
|
+
def self.union_member(t, s)
|
22
|
+
new("#{t} is not a member of union")
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
class TypeClass
|
@@ -31,6 +35,10 @@ module Yarrow
|
|
31
35
|
@accepts = {}
|
32
36
|
end
|
33
37
|
|
38
|
+
def |(rhs_opt)
|
39
|
+
Union.new(self, rhs_opt)
|
40
|
+
end
|
41
|
+
|
34
42
|
def accept(type, constructor=:new, options=nil)
|
35
43
|
accepts[type] = if options.nil?
|
36
44
|
[constructor]
|
@@ -201,6 +209,39 @@ module Yarrow
|
|
201
209
|
[keys, values].transpose.to_h
|
202
210
|
end
|
203
211
|
end
|
212
|
+
|
213
|
+
class Union < TypeClass
|
214
|
+
def self.of(*unit_opts)
|
215
|
+
instances = unit_opts.map { |unit| Instance.of(unit) }
|
216
|
+
new(*instances)
|
217
|
+
end
|
218
|
+
|
219
|
+
def initialize(*type_opts)
|
220
|
+
@options = type_opts
|
221
|
+
super()
|
222
|
+
end
|
223
|
+
|
224
|
+
def |(rhs_opt)
|
225
|
+
@options << rhs_opt
|
226
|
+
end
|
227
|
+
|
228
|
+
def check(input)
|
229
|
+
failed_checks = []
|
230
|
+
@options.each do |opt|
|
231
|
+
begin
|
232
|
+
opt.check(input)
|
233
|
+
rescue CastError => err
|
234
|
+
failed_checks << err
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
if failed_checks.size == @options.size
|
239
|
+
raise CastError.union_member(input.class, @options.map { |opt| opt.class })
|
240
|
+
end
|
241
|
+
|
242
|
+
input
|
243
|
+
end
|
244
|
+
end
|
204
245
|
end
|
205
246
|
end
|
206
247
|
end
|
data/lib/yarrow/version.rb
CHANGED
data/yarrow.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_runtime_dependency 'parallel', '~> 1.22.1'
|
25
25
|
spec.add_runtime_dependency 'strings-inflection', '~> 0.1'
|
26
26
|
spec.add_runtime_dependency 'strings-case', '~> 0.3'
|
27
|
+
# https://github.com/joeldrapper/phlex
|
27
28
|
spec.add_runtime_dependency 'kramdown', '~> 2.4.0'
|
28
29
|
spec.add_development_dependency 'rake', '~> 13.0'
|
29
30
|
spec.add_development_dependency 'rspec', '~> 3.11'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yarrow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickerby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|