yarrow 0.5.0 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +23 -0
  3. data/.gitignore +2 -1
  4. data/README.md +13 -19
  5. data/Rakefile +15 -1
  6. data/lib/yarrow.rb +17 -6
  7. data/lib/yarrow/config.rb +59 -0
  8. data/lib/yarrow/configuration.rb +35 -63
  9. data/lib/yarrow/content/collection_expander.rb +218 -0
  10. data/lib/yarrow/content/content_type.rb +42 -0
  11. data/lib/yarrow/content/graph.rb +13 -21
  12. data/lib/yarrow/content/source.rb +11 -0
  13. data/lib/yarrow/extensions.rb +1 -0
  14. data/lib/yarrow/extensions/mementus.rb +24 -0
  15. data/lib/yarrow/output/context.rb +0 -4
  16. data/lib/yarrow/output/generator.rb +2 -2
  17. data/lib/yarrow/output/web/indexed_file.rb +39 -0
  18. data/lib/yarrow/process/expand_content.rb +12 -0
  19. data/lib/yarrow/process/extract_source.rb +12 -0
  20. data/lib/yarrow/process/project_manifest.rb +20 -0
  21. data/lib/yarrow/process/step_processor.rb +43 -0
  22. data/lib/yarrow/process/workflow.rb +36 -0
  23. data/lib/yarrow/schema.rb +132 -0
  24. data/lib/yarrow/schema/validations/array.rb +0 -0
  25. data/lib/yarrow/schema/validations/object.rb +0 -0
  26. data/lib/yarrow/schema/validations/string.rb +0 -0
  27. data/lib/yarrow/server.rb +8 -5
  28. data/lib/yarrow/source/graph.rb +6 -0
  29. data/lib/yarrow/symbols.rb +19 -0
  30. data/lib/yarrow/tools/content_utils.rb +74 -0
  31. data/lib/yarrow/tools/front_matter.rb +4 -2
  32. data/lib/yarrow/version.rb +3 -2
  33. data/lib/yarrow/web/html_document.rb +9 -0
  34. data/lib/yarrow/web/manifest.rb +9 -0
  35. data/lib/yarrow/web/static_asset.rb +9 -0
  36. data/lib/yarrow/web/template.rb +9 -0
  37. data/yarrow.gemspec +6 -7
  38. metadata +52 -48
  39. data/.travis.yml +0 -16
  40. data/lib/yarrow/html.rb +0 -1
  41. data/lib/yarrow/html/asset_tags.rb +0 -59
  42. data/lib/yarrow/html/content_tags.rb +0 -7
  43. data/lib/yarrow/tools/output_file.rb +0 -40
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- language: ruby
2
-
3
- cache: bundler
4
-
5
- rvm:
6
- - 2.3
7
- - 2.4
8
- - 2.5
9
- - ruby-head
10
- - jruby
11
- - rbx-3
12
-
13
- script: bundle exec rspec
14
-
15
- before_install:
16
- - gem install bundler
data/lib/yarrow/html.rb DELETED
@@ -1 +0,0 @@
1
- require_relative 'html/asset_tags'
@@ -1,59 +0,0 @@
1
- module Yarrow
2
- module HTML
3
- module AssetTags
4
- include Yarrow::Configurable
5
-
6
- # TODO: make sprockets manifest optional/pluggable
7
- def manifest
8
- Yarrow::Assets::Manifest.new(config)
9
- end
10
-
11
- ##
12
- # Computes the base URL path to assets in the public web directory.
13
- def base_url_path
14
- if config.assets.nil? || config.output_dir.nil?
15
- raise Yarrow::ConfigurationError
16
- end
17
-
18
- # TODO: prepend configurable CDN URL for host path
19
- # TODO: dev/production mode switch
20
-
21
- config.assets.output_dir.gsub(config.output_dir, '')
22
- end
23
-
24
- def script_tags
25
- manifest.js_logical_paths.map { |path| script_tag(asset: path) }.join("\n")
26
- end
27
-
28
- def script_tag(options)
29
- src_path = if asset_in_manifest?(options)
30
- digest_path(options[:asset])
31
- else
32
- options[:src]
33
- end
34
-
35
- "<script src=\"#{src_path}\"></script>"
36
- end
37
-
38
- def link_tag(options)
39
- href_path = if asset_in_manifest?(options)
40
- digest_path(options[:asset])
41
- else
42
- options[:href]
43
- end
44
-
45
- "<link href=\"#{href_path}\" rel=\"stylesheet\" type=\"text/css\">"
46
- end
47
-
48
- private
49
-
50
- def asset_in_manifest?(options)
51
- options.has_key?(:asset) and manifest.exists?(options[:asset])
52
- end
53
-
54
- def digest_path(path)
55
- "#{base_url_path}/#{manifest.digest_path(path)}"
56
- end
57
- end
58
- end
59
- end
@@ -1,7 +0,0 @@
1
- module Yarrow
2
- module HTML
3
- module ContentTags
4
-
5
- end
6
- end
7
- end
@@ -1,40 +0,0 @@
1
- module Yarrow
2
- module Tools
3
- # TODO: consider renaming this to OutputDocument.
4
- class OutputFile
5
- include Yarrow::Configurable
6
-
7
- WRITE_MODE = 'w+:UTF-8'.freeze
8
-
9
- # @return [String] Basename reflecting the server convention (usually: index.html)
10
- def index_name
11
- @index_name ||= config.index_name || 'index.html'
12
- end
13
-
14
- # @return [String] Docroot of the output target
15
- def docroot
16
- @docroot ||= config.output_dir || 'public'
17
- end
18
-
19
- # Write an output file to the specified path under the docroot.
20
- #
21
- # @param path [String]
22
- # @param content [String]
23
- def write(path, content)
24
- # If the target path is a directory,
25
- # generate a default index filename.
26
- if path[path.length-1] == '/'
27
- path = "#{path}#{index_name}"
28
- end
29
-
30
- target_path = Pathname.new("#{docroot}#{path}")
31
-
32
- FileUtils.mkdir_p(target_path.dirname)
33
-
34
- File.open(target_path.to_s, WRITE_MODE) do |file|
35
- file.puts(content)
36
- end
37
- end
38
- end
39
- end
40
- end