yarrow 0.8.7 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CONTENT.md +228 -0
- data/README.md +8 -8
- data/lib/extensions/mementus.rb +29 -0
- data/lib/yarrow/content/expansion/aggregator.rb +91 -0
- data/lib/yarrow/content/expansion/basename_merge.rb +44 -0
- data/lib/yarrow/content/expansion/directory_map.rb +21 -0
- data/lib/yarrow/content/expansion/directory_merge.rb +31 -0
- data/lib/yarrow/content/expansion/file_list.rb +15 -0
- data/lib/yarrow/content/expansion/filename_map.rb +24 -0
- data/lib/yarrow/content/expansion/strategy.rb +47 -0
- data/lib/yarrow/content/expansion/traversal.rb +67 -0
- data/lib/yarrow/content/expansion/tree.rb +53 -74
- data/lib/yarrow/content/model.rb +3 -4
- data/lib/yarrow/content/policy.rb +78 -22
- data/lib/yarrow/content/source.rb +4 -0
- data/lib/yarrow/format/asciidoc.rb +0 -0
- data/lib/yarrow/format/html.rb +0 -0
- data/lib/yarrow/format/json.rb +0 -0
- data/lib/yarrow/format/markdown.rb +67 -0
- data/lib/yarrow/format/mediawiki.rb +0 -0
- data/lib/yarrow/format/methods/front_matter.rb +115 -0
- data/lib/yarrow/format/methods/metadata.rb +22 -0
- data/lib/yarrow/format/orgmode.rb +0 -0
- data/lib/yarrow/format/text.rb +0 -0
- data/lib/yarrow/format/xml.rb +0 -0
- data/lib/yarrow/format/yaml.rb +19 -0
- data/lib/yarrow/format.rb +71 -0
- data/lib/yarrow/symbols.rb +6 -0
- data/lib/yarrow/version.rb +1 -1
- data/lib/yarrow/web/generator.rb +2 -1
- data/lib/yarrow/web/manifest.rb +23 -9
- data/lib/yarrow.rb +7 -9
- data/yarrow.gemspec +1 -0
- metadata +36 -3
- data/lib/yarrow/tools/content_utils.rb +0 -74
data/lib/yarrow/symbols.rb
CHANGED
@@ -30,5 +30,11 @@ module Yarrow
|
|
30
30
|
def self.to_plural(atom)
|
31
31
|
Strings::Inflection.pluralize(atom.to_s).to_sym
|
32
32
|
end
|
33
|
+
|
34
|
+
# @param [Symbol, String] atom
|
35
|
+
# @return [String]
|
36
|
+
def self.to_text(identifier)
|
37
|
+
identifier.to_s.gsub(/\A[^[:alnum:]]+/, "").gsub(/[\-_]+/, " ").capitalize
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
data/lib/yarrow/version.rb
CHANGED
data/lib/yarrow/web/generator.rb
CHANGED
data/lib/yarrow/web/manifest.rb
CHANGED
@@ -3,6 +3,7 @@ module Yarrow
|
|
3
3
|
class Manifest
|
4
4
|
def self.build(graph)
|
5
5
|
manifest = new
|
6
|
+
manifest.set_graph(graph)
|
6
7
|
|
7
8
|
graph.n(:collection).each do |collection|
|
8
9
|
# TODO: raise error if both content_only and index_only are set
|
@@ -10,12 +11,12 @@ module Yarrow
|
|
10
11
|
|
11
12
|
# If the collection is tagged :index_only then skip adding individual documents
|
12
13
|
unless collection.props[:index_only]
|
13
|
-
collection.out(:
|
14
|
+
collection.out(:entity).each do |entity|
|
14
15
|
#if item[:entity].status.to_sym == :published
|
15
|
-
if
|
16
|
-
index =
|
16
|
+
if entity.props[:resource].name == "index"
|
17
|
+
index = entity
|
17
18
|
else
|
18
|
-
manifest.add_document(
|
19
|
+
manifest.add_document(entity_context(entity))
|
19
20
|
end
|
20
21
|
#end
|
21
22
|
end
|
@@ -34,13 +35,18 @@ module Yarrow
|
|
34
35
|
manifest
|
35
36
|
end
|
36
37
|
|
37
|
-
attr_reader :documents, :assets
|
38
|
+
attr_reader :documents, :assets, :graph
|
38
39
|
|
39
40
|
def initialize
|
40
41
|
@documents = []
|
41
42
|
@assets = []
|
42
43
|
end
|
43
44
|
|
45
|
+
# Used for dot debugging
|
46
|
+
def set_graph(graph)
|
47
|
+
@graph = graph
|
48
|
+
end
|
49
|
+
|
44
50
|
def add_document(document)
|
45
51
|
@documents << document
|
46
52
|
end
|
@@ -50,15 +56,23 @@ module Yarrow
|
|
50
56
|
end
|
51
57
|
|
52
58
|
def self.collection_context(collection)
|
59
|
+
# TODO: debug log
|
60
|
+
# puts "collection_context"
|
61
|
+
# p collection.props[:resource].title
|
62
|
+
# p collection
|
53
63
|
IndexDocument.new(collection, nil, true)
|
54
64
|
end
|
55
65
|
|
56
|
-
def self.collection_index_context(collection,
|
57
|
-
|
66
|
+
def self.collection_index_context(collection, entity)
|
67
|
+
# TODO: debug log
|
68
|
+
# puts "collection_index_context"
|
69
|
+
# p collection.props[:resource].title
|
70
|
+
# p entity.props[:resource].title
|
71
|
+
IndexDocument.new(collection, entity, false)
|
58
72
|
end
|
59
73
|
|
60
|
-
def self.
|
61
|
-
Document.new(
|
74
|
+
def self.entity_context(entity)
|
75
|
+
Document.new(entity, false)
|
62
76
|
end
|
63
77
|
end
|
64
78
|
end
|
data/lib/yarrow.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "pathname"
|
2
2
|
require "yaml"
|
3
3
|
require "kramdown"
|
4
|
+
require "toml"
|
4
5
|
require "mustache"
|
5
6
|
require "parallel"
|
6
7
|
|
@@ -15,14 +16,16 @@ require "yarrow/schema/dictionary"
|
|
15
16
|
require "yarrow/schema/entity"
|
16
17
|
require "yarrow/schema/value"
|
17
18
|
require "yarrow/schema/registry"
|
18
|
-
require "yarrow/
|
19
|
-
require "yarrow/tools/content_utils"
|
19
|
+
require "yarrow/format"
|
20
20
|
require "yarrow/content/graph"
|
21
21
|
require "yarrow/content/policy"
|
22
22
|
require "yarrow/content/model"
|
23
23
|
require "yarrow/content/source"
|
24
|
-
require "yarrow/content/expansion/
|
25
|
-
require "yarrow/content/expansion/
|
24
|
+
require "yarrow/content/expansion/aggregator"
|
25
|
+
require "yarrow/content/expansion/basename_merge"
|
26
|
+
require "yarrow/content/expansion/filename_map"
|
27
|
+
require "yarrow/content/expansion/directory_merge"
|
28
|
+
require "yarrow/content/expansion/traversal"
|
26
29
|
require "yarrow/content/resource"
|
27
30
|
require "yarrow/web/manifest"
|
28
31
|
require "yarrow/web/document"
|
@@ -41,9 +44,4 @@ require "yarrow/process/project_manifest"
|
|
41
44
|
require "yarrow/config"
|
42
45
|
require "yarrow/configuration"
|
43
46
|
require "yarrow/console_runner"
|
44
|
-
|
45
47
|
require "yarrow/generator"
|
46
|
-
|
47
|
-
# Dir[File.dirname(__FILE__) + "/yarrow/generators/*.rb"].each do |generator|
|
48
|
-
# require generator
|
49
|
-
# 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
|
+
spec.add_runtime_dependency 'toml', '~> 0.3.0'
|
27
28
|
# https://github.com/joeldrapper/phlex
|
28
29
|
spec.add_runtime_dependency 'kramdown', '~> 2.4.0'
|
29
30
|
spec.add_development_dependency 'rake', '~> 13.0'
|
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.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickerby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03
|
11
|
+
date: 2023-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0.3'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: toml
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.3.0
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 0.3.0
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: kramdown
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -245,6 +259,7 @@ extra_rdoc_files: []
|
|
245
259
|
files:
|
246
260
|
- ".github/workflows/ruby.yml"
|
247
261
|
- ".gitignore"
|
262
|
+
- CONTENT.md
|
248
263
|
- Gemfile
|
249
264
|
- LICENSE
|
250
265
|
- README.md
|
@@ -260,7 +275,14 @@ files:
|
|
260
275
|
- lib/yarrow/config.rb
|
261
276
|
- lib/yarrow/configuration.rb
|
262
277
|
- lib/yarrow/console_runner.rb
|
278
|
+
- lib/yarrow/content/expansion/aggregator.rb
|
279
|
+
- lib/yarrow/content/expansion/basename_merge.rb
|
280
|
+
- lib/yarrow/content/expansion/directory_map.rb
|
281
|
+
- lib/yarrow/content/expansion/directory_merge.rb
|
282
|
+
- lib/yarrow/content/expansion/file_list.rb
|
283
|
+
- lib/yarrow/content/expansion/filename_map.rb
|
263
284
|
- lib/yarrow/content/expansion/strategy.rb
|
285
|
+
- lib/yarrow/content/expansion/traversal.rb
|
264
286
|
- lib/yarrow/content/expansion/tree.rb
|
265
287
|
- lib/yarrow/content/graph.rb
|
266
288
|
- lib/yarrow/content/model.rb
|
@@ -269,6 +291,18 @@ files:
|
|
269
291
|
- lib/yarrow/content/source.rb
|
270
292
|
- lib/yarrow/content_map.rb
|
271
293
|
- lib/yarrow/defaults.yml
|
294
|
+
- lib/yarrow/format.rb
|
295
|
+
- lib/yarrow/format/asciidoc.rb
|
296
|
+
- lib/yarrow/format/html.rb
|
297
|
+
- lib/yarrow/format/json.rb
|
298
|
+
- lib/yarrow/format/markdown.rb
|
299
|
+
- lib/yarrow/format/mediawiki.rb
|
300
|
+
- lib/yarrow/format/methods/front_matter.rb
|
301
|
+
- lib/yarrow/format/methods/metadata.rb
|
302
|
+
- lib/yarrow/format/orgmode.rb
|
303
|
+
- lib/yarrow/format/text.rb
|
304
|
+
- lib/yarrow/format/xml.rb
|
305
|
+
- lib/yarrow/format/yaml.rb
|
272
306
|
- lib/yarrow/generator.rb
|
273
307
|
- lib/yarrow/help.txt
|
274
308
|
- lib/yarrow/logging.rb
|
@@ -292,7 +326,6 @@ files:
|
|
292
326
|
- lib/yarrow/server/livereload.rb
|
293
327
|
- lib/yarrow/source/graph.rb
|
294
328
|
- lib/yarrow/symbols.rb
|
295
|
-
- lib/yarrow/tools/content_utils.rb
|
296
329
|
- lib/yarrow/tools/front_matter.rb
|
297
330
|
- lib/yarrow/version.rb
|
298
331
|
- lib/yarrow/web/document.rb
|
@@ -1,74 +0,0 @@
|
|
1
|
-
module Yarrow
|
2
|
-
module Tools
|
3
|
-
# Synchronous utility functions for working with filesystem content tasks.
|
4
|
-
module ContentUtils
|
5
|
-
# Pass in a source path and get back a parsed representation of the
|
6
|
-
# content if it is in a known text format. Mostly used as a fallback if
|
7
|
-
# a custom parser or processing chain is not configured for a content
|
8
|
-
# type.
|
9
|
-
#
|
10
|
-
# Supported formats:
|
11
|
-
# - HTML template and document partials
|
12
|
-
# - Markdown documents
|
13
|
-
# - YAML documents
|
14
|
-
# - JSON (untested)
|
15
|
-
#
|
16
|
-
# Works around meta and content source in multiple files or a single
|
17
|
-
# file with front matter.
|
18
|
-
def read_yfm(name)
|
19
|
-
path = if name.is_a?(Pathname)
|
20
|
-
name
|
21
|
-
else
|
22
|
-
Pathname.new(name)
|
23
|
-
end
|
24
|
-
|
25
|
-
text = File.read(path, :encoding => 'utf-8')
|
26
|
-
|
27
|
-
case path.extname
|
28
|
-
when '.htm', '.md', '.txt', '.yfm'
|
29
|
-
extract_yfm(text, symbolize_keys: true)
|
30
|
-
# when '.md'
|
31
|
-
# body, data = read_split_content(path.to_s, symbolize_keys: true)
|
32
|
-
# [Kramdown::Document.new(body).to_html, data]
|
33
|
-
when '.yml'
|
34
|
-
[nil, YAML.load(File.read(path.to_s), symbolize_names: true)]
|
35
|
-
when '.json'
|
36
|
-
[nil, JSON.parse(File.read(path.to_s))]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def extract_yfm(text, options={})
|
41
|
-
pattern = /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
42
|
-
if text =~ pattern
|
43
|
-
content = text.sub(pattern, "")
|
44
|
-
|
45
|
-
begin
|
46
|
-
if options.key?(:symbolize_keys)
|
47
|
-
meta = YAML.load($1, symbolize_names: true)
|
48
|
-
else
|
49
|
-
meta = YAML.load($1)
|
50
|
-
end
|
51
|
-
return [content, meta]
|
52
|
-
rescue Psych::SyntaxError => error
|
53
|
-
if defined? ::Logger
|
54
|
-
# todo: application wide logger
|
55
|
-
#logger = ::Logger.new(STDOUT)
|
56
|
-
#logger.error "#{error.message}"
|
57
|
-
end
|
58
|
-
return [content, nil]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
[text, nil]
|
63
|
-
end
|
64
|
-
|
65
|
-
def write_yfm(name, text, meta)
|
66
|
-
# Symbolized keys are better to deal with when manipulating data in
|
67
|
-
# Ruby but are an interop nightmare when serialized so here we do a
|
68
|
-
# round-trip through JSON encoding to ensure all keys are string
|
69
|
-
# encoded before dumping them to the front matter format.
|
70
|
-
File.write(name, [YAML.dump(meta.to_json), "---", text].join("\n"))
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|