Class: Jekyll::GeneratorSingleSource::Source::Base
- Inherits:
-
Object
- Object
- Jekyll::GeneratorSingleSource::Source::Base
- Defined in:
- lib/jekyll/generator-single-source/source/base.rb
Direct Known Subclasses
Constant Summary collapse
- PATH =
'src'
Class Method Summary collapse
Instance Method Summary collapse
- #file_path ⇒ Object
- #full_file_path ⇒ Object
-
#initialize(path, source_dir) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(path, source_dir) ⇒ Base
Returns a new instance of Base.
28 29 30 31 |
# File 'lib/jekyll/generator-single-source/source/base.rb', line 28 def initialize(path, source_dir) @path = path @source_dir = source_dir end |
Class Method Details
.make_for(path:, site:) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jekyll/generator-single-source/source/base.rb', line 9 def self.make_for(path:, site:) # Normalize path file_path = File.join( PATH, path.delete_prefix('/').delete_suffix('/') ) src_dir = File.('..', site.source) # Read the source file, either `<src>.md or <src>/index.md` if File.exist?(File.join(src_dir, "#{file_path}.md")) FileSource.new("#{file_path}.md", src_dir) elsif File.exist?(File.join(src_dir, "#{file_path}/index.md")) DirSource.new("#{file_path}/index.md", src_dir) else raise "Could not find a source file at '#{file_path}.md' or '#{file_path}/index.md'" end end |
Instance Method Details
#file_path ⇒ Object
33 34 35 |
# File 'lib/jekyll/generator-single-source/source/base.rb', line 33 def file_path @file_path ||= @path end |
#full_file_path ⇒ Object
37 38 39 |
# File 'lib/jekyll/generator-single-source/source/base.rb', line 37 def full_file_path @full_file_path ||= File.(@path, @source_dir) end |