asciisourcerer 0.4.0 → 0.5.0
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 +4 -4
- data/BILL_OF_MATERIALS.adoc +17 -0
- data/README.adoc +87 -7
- data/lib/sourcerer/_docs/partials/liquid-filters-by-kind.adoc +3227 -0
- data/lib/sourcerer/_docs/partials/liquid-filters-by-source.adoc +3155 -0
- data/lib/sourcerer/asciidoc.rb +10 -3
- data/lib/sourcerer/builder.rb +1 -1
- data/lib/sourcerer/jekyll/liquid/filters.rb +295 -0
- data/lib/sourcerer/jekyll.rb +7 -2
- data/lib/sourcerer/mark_down_grade.rb +181 -28
- data/lib/sourcerer/rendering.rb +9 -3
- data/lib/sourcerer/source_skim/config.rb +8 -2
- data/lib/sourcerer/source_skim/ruby_skimmer.rb +83 -0
- data/lib/sourcerer/source_skim/skimmer.rb +94 -1
- data/lib/sourcerer/source_skim.rb +11 -2
- data/lib/sourcerer/util/gem_uri.rb +34 -0
- data/lib/sourcerer/version.rb +1 -1
- data/lib/sourcerer.rb +0 -1
- data/specs/data/liquid-filters.yml +1314 -0
- metadata +26 -4
- data/specs/docs/frontmatter-reader_prd.adoc +0 -47
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sourcerer
|
|
4
|
+
module Util
|
|
5
|
+
# Resolve <tt>gem://</tt> URIs to absolute filesystem paths.
|
|
6
|
+
#
|
|
7
|
+
# Not required internally; callers must require this file explicitly.
|
|
8
|
+
module GemUri
|
|
9
|
+
GEM_URI_PATTERN = %r{\Agem://([^/]+)/(.+)\z}
|
|
10
|
+
|
|
11
|
+
# Resolve a +gem://+ URI to an absolute path within the named gem's directory.
|
|
12
|
+
# Returns +path+ unchanged if it is not a +gem://+ URI.
|
|
13
|
+
#
|
|
14
|
+
# URI format: <tt>gem://<gem-name>/<path-within-gem></tt>
|
|
15
|
+
# Example: <tt>gem://schemagraphy/lib/schemagraphy/cfgyml/templates/foo.liquid</tt>
|
|
16
|
+
#
|
|
17
|
+
# @param path [String] A gem:// URI or any other string.
|
|
18
|
+
# @return [String] The resolved absolute path, or the original string if not a gem:// URI.
|
|
19
|
+
# @raise [ArgumentError] If the gem:// URI is malformed.
|
|
20
|
+
# @raise [LoadError] If the referenced gem is not loaded.
|
|
21
|
+
def self.resolve path
|
|
22
|
+
return path unless path.is_a?(String) && path.start_with?('gem://')
|
|
23
|
+
|
|
24
|
+
match = GEM_URI_PATTERN.match(path)
|
|
25
|
+
raise ArgumentError, "Invalid gem:// URI: #{path}" unless match
|
|
26
|
+
|
|
27
|
+
spec = Gem.loaded_specs[match[1]]
|
|
28
|
+
raise LoadError, "Gem '#{match[1]}' not loaded (referenced in gem:// URI: #{path})" unless spec
|
|
29
|
+
|
|
30
|
+
File.join(spec.gem_dir, match[2])
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/sourcerer/version.rb
CHANGED
data/lib/sourcerer.rb
CHANGED
|
@@ -23,7 +23,6 @@ module Sourcerer
|
|
|
23
23
|
# File extensions recognised as AsciiDoc source files.
|
|
24
24
|
ASCIIDOC_EXTS = %w[.adoc .asciidoc .asc .ad].freeze
|
|
25
25
|
|
|
26
|
-
autoload :AttributesFilter, 'sourcerer/attributes_filter'
|
|
27
26
|
autoload :YamlFrontmatter, 'sourcerer/yaml_frontmatter'
|
|
28
27
|
autoload :Jekyll, 'sourcerer/jekyll'
|
|
29
28
|
autoload :MarkDownGrade, 'sourcerer/mark_down_grade'
|