yarrow 0.8.2 → 0.8.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ea37c60e3c8bfe51e6ceb9425f0d0c81b93757a681c7987f7852c3335644824
4
- data.tar.gz: 19cd090d3b3348f633f5d303d8b826fd2b8c054b790136355a41d9b4f0f098c4
3
+ metadata.gz: b4319be245b1b70240d28422cf095d64bb61bdacf1b95c545cd055ed7c9e645b
4
+ data.tar.gz: 1c0fc21f3536a09dd5c11a1c359ce11ab128ea9c527f002a6e6a777090848173
5
5
  SHA512:
6
- metadata.gz: ebd0dd29f6d8800b20560c2e24fd2988caecf19e9ae5f3e44a3d0b427afc9201971be1b086705e72c874683d30625821b270e6ad944c5c28ca9b6cd9ecd65ea2
7
- data.tar.gz: 92d36891c8a270ff663a299b2a217ffe3bb6985200e70d84c4c9d29ee87bb00fb7b2e824e0d932d585b5f8b4a22d578748ee58ad3ae022aa8f1b8ab04117ac6f
6
+ metadata.gz: 0c3d3176870c6bc82695a825bfa7dc46908311200a35722142620e2fdfd5ce60ea795ef03b88ee35c206379e9f382bab41e0cd38f96d5cc261ba0578d7fe51ed
7
+ data.tar.gz: 3d8b4f4acb48ef94dc75b65ebda43c5a0d0e588679688b090a6ebaba6c5bccc7f7610793d60663a2e7c5cdd6fcdc213be989f064ac8d9092f6dfd191a0b38b90
data/lib/yarrow/config.rb CHANGED
@@ -62,7 +62,7 @@ module Yarrow
62
62
  attribute :meta, :any
63
63
  attribute :server, :any
64
64
  attribute :content, :__config_content
65
- #attribute :output, :__config_output
65
+ attribute :output, :__config_output
66
66
  end
67
67
  #
68
68
  # `content_dir` and `output_dir` are placeholders and should be overriden
@@ -59,6 +59,12 @@ module Yarrow
59
59
  })
60
60
  end
61
61
 
62
+ output_obj = if config.key?(:output)
63
+ Yarrow::Config::Output.new(config[:output])
64
+ else
65
+ Yarrow::Config::Output.new({ generator: "web", template_dir: "templates" })
66
+ end
67
+
62
68
  # TODO: messy hack to get rid of Hashie::Mash, this should either be
63
69
  # automated as part of the schema types or a default value should be
64
70
  # generated here (eg: `"#{Dir.pwd}/docs"`)
@@ -70,7 +76,8 @@ module Yarrow
70
76
  source_dir: Pathname.new(File.expand_path(source_dir_or_string)),
71
77
  meta: meta_obj,
72
78
  server: server_obj,
73
- content: content_obj
79
+ content: content_obj,
80
+ output: output_obj
74
81
  )
75
82
  end
76
83
  end
@@ -3,19 +3,19 @@ module Yarrow
3
3
  module Expansion
4
4
  class Strategy
5
5
  include Yarrow::Tools::FrontMatter
6
-
6
+
7
7
  attr_reader :graph
8
-
8
+
9
9
  def initialize(graph)
10
10
  @graph = graph
11
11
  end
12
-
12
+
13
13
  # Extract collection level configuration/metadata from the root node for
14
14
  # this content type.
15
15
  def extract_metadata(node, type)
16
16
  # TODO: support _index or _slug convention as well
17
17
  meta_file = node.out(slug: type.to_s).first
18
-
18
+
19
19
  if meta_file
20
20
  # Process metadata and add it to the collection node
21
21
  # TODO: pass in content converter object
@@ -25,15 +25,15 @@ module Yarrow
25
25
  # Otherwise, assume default collection behaviour
26
26
  data = {}
27
27
  end
28
-
28
+
29
29
  # Generate a default title if not provided in metadata
30
30
  unless data.key?(:title)
31
31
  data[:title] = type.to_s.capitalize
32
32
  end
33
-
33
+
34
34
  data
35
35
  end
36
-
36
+
37
37
  # Workaround for handling meta and content source in multiple files or a single
38
38
  # file with front matter.
39
39
  def process_content(path)
@@ -46,6 +46,7 @@ module Yarrow
46
46
  when '.yml'
47
47
  [nil, YAML.load(File.read(path.to_s), symbolize_names: true)]
48
48
  end
49
+ # TODO: Raise error if unsupported extname reaches here
49
50
  end
50
51
  end
51
52
  end
@@ -63,6 +63,9 @@ module Yarrow
63
63
  item_node.props[:body] = body if body
64
64
  item_node.props[:title] = meta[:title] if meta
65
65
  # TODO: better handling of metadata on node props
66
+
67
+ # TODO: new schema edits go here
68
+ #puts policy.entity_const
66
69
  end
67
70
 
68
71
  # We may not have an expanded node for the parent collection if this is a
@@ -4,7 +4,11 @@ module Yarrow
4
4
  def initialize(content_config)
5
5
  @policies = {}
6
6
  content_config.source_map.each_entry do |policy_label, policy_spec|
7
- @policies[policy_label] = Policy.from_spec(policy_label, policy_spec)
7
+ @policies[policy_label] = Policy.from_spec(
8
+ policy_label,
9
+ policy_spec,
10
+ content_config.module
11
+ )
8
12
  end
9
13
  end
10
14
 
@@ -9,6 +9,8 @@ module Yarrow
9
9
 
10
10
  DEFAULT_MATCH_PATH = "."
11
11
 
12
+ MODULE_SEPARATOR = "::"
13
+
12
14
  # Construct a content policy from the given source specification.
13
15
  def self.from_spec(policy_label, policy_props, module_prefix="")
14
16
  # TODO: validate length, structure etc
@@ -27,7 +29,7 @@ module Yarrow
27
29
  if policy_props.key?(:entity)
28
30
  Yarrow::Symbols.to_plural(policy_props[:entity])
29
31
  else
30
- Yarrow::Symbols.to_plural(label)
32
+ Yarrow::Symbols.to_plural(policy_label)
31
33
  end
32
34
  end
33
35
 
@@ -38,7 +40,7 @@ module Yarrow
38
40
  if policy_props.key?(:container)
39
41
  Yarrow::Symbols.to_singular(policy_props[:container])
40
42
  else
41
- Yarrow::Symbols.to_singular(label)
43
+ Yarrow::Symbols.to_singular(policy_label)
42
44
  end
43
45
  end
44
46
 
@@ -64,7 +66,7 @@ module Yarrow
64
66
  end
65
67
  end
66
68
 
67
- attr_reader :container, :entity, :expansion, :extensions, :match_path, :module
69
+ attr_reader :container, :entity, :expansion, :extensions, :match_path, :module_prefix
68
70
 
69
71
  def initialize(container, entity, expansion, extensions, match_path, module_prefix)
70
72
  @container = container
@@ -72,35 +74,15 @@ module Yarrow
72
74
  @expansion = expansion
73
75
  @extensions = extensions
74
76
  @match_path = match_path
75
- @module_prefix = module_prefix
77
+ @module_prefix = module_prefix.split(MODULE_SEPARATOR)
76
78
  end
77
79
 
78
80
  def container_const
79
- @container_const ||= Yarrow::Symbols.to_module_const([module_prefix, container])
81
+ @container_const ||= Yarrow::Symbols.to_module_const([*module_prefix, container])
80
82
  end
81
83
 
82
84
  def entity_const
83
- @entity_const ||= Yarrow::Symbols.to_module_const([module_prefix, entity])
84
- end
85
-
86
- def _container
87
- return @properties.container if @properties.container
88
- Yarrow::Symbols.to_plural(@properties.entity)
89
- end
90
-
91
- def _entity
92
- return @properties.entity if @properties.entity
93
- Yarrow::Symbols.to_singular(@properties.container)
94
- end
95
-
96
- def _extensions
97
- return @properties.extensions if @properties.extensions
98
- DEFAULT_EXTENSIONS
99
- end
100
-
101
- def _match_path
102
- return @properties.match_path if @properties.match_path
103
- DEFAULT_MATCH_PATH
85
+ @entity_const ||= Yarrow::Symbols.to_module_const([*module_prefix, entity])
104
86
  end
105
87
  end
106
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Yarrow
3
3
  APP_NAME = "Yarrow"
4
- VERSION = "0.8.2"
4
+ VERSION = "0.8.3"
5
5
  end
@@ -18,7 +18,7 @@ module Yarrow
18
18
  end
19
19
 
20
20
  def write_document(document)
21
- template = Template.for_document(document)
21
+ template = Template.for_document(document, config)
22
22
  write_output_file(document.url, template.render(document))
23
23
  end
24
24
 
@@ -39,6 +39,8 @@ module Yarrow
39
39
  File.open(path.to_s, 'w+:UTF-8') do |file|
40
40
  file.puts(content)
41
41
  end
42
+
43
+ puts "[write] #{path} → #{url}"
42
44
  end
43
45
 
44
46
  def generate_sitemap(manifest)
@@ -1,14 +1,15 @@
1
1
  module Yarrow
2
2
  module Web
3
3
  class Template
4
- def self.for_document(document)
4
+ def self.for_document(document, config)
5
5
  layout_name = if document.respond_to?(:layout)
6
6
  document.layout || document.type
7
7
  else
8
8
  document.type
9
9
  end
10
10
 
11
- @template_dir = "./spec/fixtures/templates/doctest"
11
+ @template_dir = config.output.template_dir
12
+ #@template_dir = "./spec/fixtures/templates/doctest"
12
13
  @template_ext = ".html"
13
14
 
14
15
  template_file = "#{layout_name}#{@template_ext}"
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.2
4
+ version: 0.8.3
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-11-04 00:00:00.000000000 Z
11
+ date: 2022-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable