yarrow 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb8358e221f56cb48075609b4ae35e07ef7ea1bef577d6a1f929a8eb26ca4242
4
- data.tar.gz: 8730eec22402eb73b1555a7421fd6ea5f22edb049d8dc7083c0b4de1ea777681
3
+ metadata.gz: 89667b38c1ebf2da983a381e20be9d8e0904bdb69137bb86a1bce6ee9507fbf1
4
+ data.tar.gz: 364c196cefad90398b10c387edb925b055490163be854b814f3522a6333234ef
5
5
  SHA512:
6
- metadata.gz: 1571c747f38efd25382c758b9974c1e5b644f541aa93f76f9f8d3082c35db13b30cf39da52487e67ad2611feb73fc24ad39acdf7de57393aaa8e16cebe8dc0ea
7
- data.tar.gz: aad027b60c53a918b9b96f800e144b8b981f3e083a211524ce329549b8242cbd9100da756b7130adcfac990b7944d557378de963b62042cf2effba12acade81e
6
+ metadata.gz: 113ce8dc745ec3e83121d5229beeed755671a7902e1330373ef7b129d7138048d090bbdb1abedd2458f0faca3f86f4433c30a855cc6a53119ba59576699f7002
7
+ data.tar.gz: 6b24b087284b3be6f2d55a8aa3afc25d0e3cc38dbbb2bd80bd9005487b9b95b3bf65d218a47c65b6ac9f4fd54e830a01984292bc1f0c4c8d1455b7af3a5b5049
@@ -10,7 +10,7 @@ jobs:
10
10
  fail-fast: false
11
11
  matrix:
12
12
  os: [ubuntu-latest, macos-latest]
13
- ruby: [2.7, '3.0', 3.1, head]
13
+ ruby: [2.7, 3.1, 3.2]
14
14
  runs-on: ${{ matrix.os }}
15
15
  steps:
16
16
  - uses: actions/checkout@v2
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
 
@@ -5,6 +5,7 @@ module Yarrow
5
5
  def expand(policy)
6
6
  #p graph.n(:root).out(:directory).to_a.count
7
7
  #policy.match()
8
+ p policy
8
9
 
9
10
  #p graph.n(:root).out(:directory).first.props[:name]
10
11
  type = policy.container
@@ -2,6 +2,8 @@ module Yarrow
2
2
  module Content
3
3
  class Model
4
4
  def initialize(content_config)
5
+ p content_config
6
+
5
7
  @policies = {}
6
8
  content_config.source_map.each_entry do |policy_label, policy_spec|
7
9
  @policies[policy_label] = Policy.from_spec(
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Yarrow
3
3
  APP_NAME = "Yarrow"
4
- VERSION = "0.8.6"
4
+ VERSION = "0.8.7"
5
5
  end
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.6
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: 2022-12-06 00:00:00.000000000 Z
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable