yarrow 0.8.5 → 0.8.6

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: 33fcaf7b1d66e43c0bd0a83967d0cc8b4891b96ec652bbfd28e5e91e7991b7e2
4
- data.tar.gz: ccf4513eee11929864f76386e22adf39224a1898f5b207a3cefb11a30a5ed6e7
3
+ metadata.gz: cb8358e221f56cb48075609b4ae35e07ef7ea1bef577d6a1f929a8eb26ca4242
4
+ data.tar.gz: 8730eec22402eb73b1555a7421fd6ea5f22edb049d8dc7083c0b4de1ea777681
5
5
  SHA512:
6
- metadata.gz: 20272c169c2dd1280c06b80277a981217ae08c77c80892b4c8d07bac0564099ea0cbc248d54ac3160522e7e38c7dbe129aa703e6cb9e9cb848619f2009e15273
7
- data.tar.gz: 143a1bbb91909f1e8921b9b587f611293b2f20de9f50d66b18a7346c00e6ebc2078d98ac0e9abcb88cad258e2f3a2d902f1f2eda811d27abd0348ece8f7cf87e
6
+ metadata.gz: 1571c747f38efd25382c758b9974c1e5b644f541aa93f76f9f8d3082c35db13b30cf39da52487e67ad2611feb73fc24ad39acdf7de57393aaa8e16cebe8dc0ea
7
+ data.tar.gz: aad027b60c53a918b9b96f800e144b8b981f3e083a211524ce329549b8242cbd9100da756b7130adcfac990b7944d557378de963b62042cf2effba12acade81e
@@ -6,6 +6,22 @@ module Mementus
6
6
  # Monkeypatch extension to ensure each pipeline step supports enumerable
7
7
  # methods. Mostly used for #map. API needs to be fixed in the gem itself.
8
8
  include Enumerable
9
+
10
+ def to
11
+ Step.new(map { |edge| edge.to }, Pipe.new(graph), graph)
12
+ end
13
+
14
+ def props
15
+ Step.new(map { |node| node.props }, Pipe.new(graph), graph)
16
+ end
17
+
18
+ # def props
19
+ # node_props = source.inject([]) do |result, node|
20
+ # result.concat(node.props)
21
+ # end
22
+
23
+ # Step.new(node_props, Pipe.new(graph), graph)
24
+ # end
9
25
  end
10
26
  end
11
27
  module Structure
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Yarrow
3
3
  APP_NAME = "Yarrow"
4
- VERSION = "0.8.5"
4
+ VERSION = "0.8.6"
5
5
  end
@@ -1,20 +1,15 @@
1
- module Yarrow
1
+ module Yarrow
2
2
  module Web
3
- class Document
4
- # This class is somewhat verbose for simplicity and long-term maintainability
5
- # (having a clear and easy to follow construction, rather than doing anything
6
- # too clever which has burned this lib in the past).
7
- def initialize(item, parent, is_index)
8
- @item = item
9
- @resource = item.props[:resource]
10
- @parent = parent
11
- @is_index = is_index
12
- end
13
-
3
+ class BaseDocument
14
4
  def resource
15
5
  @resource
16
6
  end
17
7
 
8
+ def type
9
+ @type
10
+ end
11
+
12
+ # TODO: confirm this can be deleted
18
13
  def index
19
14
  _index = @item.out_e(:index)
20
15
  unless _index.first.nil?
@@ -24,16 +19,19 @@ module Yarrow
24
19
  end
25
20
  end
26
21
 
22
+ # TODO: confirm this can be deleted
27
23
  def index_body
28
24
  @item.props[:index_body]
29
25
  end
30
26
 
31
27
  # TODO: manage behaviour with and without current item
32
28
  # TODO: link to manifest
29
+ #
30
+ # TODO: replace @item and @collection with @node internally and in class interface
33
31
  def breadcrumbs
34
32
  path = []
35
33
 
36
- current_parent = @item.in(:collection)
34
+ current_parent = @node.in(:collection)
37
35
 
38
36
  while !current_parent.first.nil?
39
37
  path << current_parent.first.props[:resource]
@@ -51,10 +49,6 @@ module Yarrow
51
49
  @resource.title
52
50
  end
53
51
 
54
- def type
55
- @item.props[:type]
56
- end
57
-
58
52
  def body
59
53
  return @resource.body.to_html if @resource.respond_to?(:body)
60
54
  ""
@@ -78,5 +72,54 @@ module Yarrow
78
72
  end
79
73
  end
80
74
  end
75
+
76
+ class IndexDocument < BaseDocument
77
+ # Represents the index document of a collection. This contains
78
+ # a reference to the individual items in the collection as well as
79
+ # any document content itself.
80
+ def initialize(collection, item=nil, is_index=false)
81
+ @collection = collection
82
+ @item = item
83
+ # The parent node of the collection is the first incoming node link
84
+ @parent = collection.in(:collection).first
85
+ @is_index = is_index
86
+
87
+ template_map = collection.out_e(:child).to.all.inject([]) do |result, node|
88
+ result << Document.new(node, false)
89
+ end
90
+
91
+ instance_variable_set("@children", template_map)
92
+ define_singleton_method(:children){ template_map }
93
+
94
+ if @item.nil?
95
+ @resource = collection.props[:resource]
96
+ @type = collection.props[:type]
97
+ @node = collection
98
+ else
99
+ @resource = item.props[:resource]
100
+ @type = item.props[:type]
101
+ @node = item
102
+ end
103
+
104
+ instance_variable_set("@#{@type}", @resource)
105
+ define_singleton_method(@type){ @resource }
106
+ end
107
+ end
108
+
109
+ class Document < BaseDocument
110
+ # This class is somewhat verbose for simplicity and long-term maintainability
111
+ # (having a clear and easy to follow construction, rather than doing anything
112
+ # too clever which has burned this lib in the past).
113
+ def initialize(item, is_index)
114
+ @item = item
115
+ @type = item.props[:type]
116
+ @parent = item.in(:collection).first
117
+ @node = item
118
+ @is_index = is_index
119
+ @resource = item.props[:resource]
120
+ instance_variable_set("@#{item.props[:type]}", @resource)
121
+ define_singleton_method(item.props[:type]){ @resource }
122
+ end
123
+ end
81
124
  end
82
125
  end
@@ -50,15 +50,15 @@ module Yarrow
50
50
  end
51
51
 
52
52
  def self.collection_context(collection)
53
- Document.new(collection, collection.in(:collection).first, true)
53
+ IndexDocument.new(collection, nil, true)
54
54
  end
55
55
 
56
56
  def self.collection_index_context(collection, item)
57
- Document.new(item, collection.in(:collection).first, false)
57
+ IndexDocument.new(collection, item, false)
58
58
  end
59
59
 
60
60
  def self.item_context(item)
61
- Document.new(item, item.in(:collection).first, false)
61
+ Document.new(item, false)
62
62
  end
63
63
  end
64
64
  end
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.5
4
+ version: 0.8.6
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-05 00:00:00.000000000 Z
11
+ date: 2022-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable