Class: Blogdown::FilePipeline
- Inherits:
-
Object
- Object
- Blogdown::FilePipeline
- Defined in:
- lib/blogdown/file_pipeline.rb
Instance Attribute Summary collapse
-
#stack ⇒ Object
Returns the value of attribute stack.
Instance Method Summary collapse
-
#initialize(root) ⇒ FilePipeline
constructor
A new instance of FilePipeline.
- #load_files ⇒ Object
- #writer(name, contents) ⇒ Object
Constructor Details
#initialize(root) ⇒ FilePipeline
4 5 6 7 8 9 |
# File 'lib/blogdown/file_pipeline.rb', line 4 def initialize(root) @root=root @base=Pathname(@root) @stack=[] load_files end |
Instance Attribute Details
#stack ⇒ Object
Returns the value of attribute stack.
3 4 5 |
# File 'lib/blogdown/file_pipeline.rb', line 3 def stack @stack end |
Instance Method Details
#load_files ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/blogdown/file_pipeline.rb', line 11 def load_files base_input=@root+'/posts' base=Pathname.new(base_input) unless base.exist? raise Blogdown::Exceptions::DirectoryNotFound, "please make sure the posts folder is present" end if base.exist? base.each_child do|child| if child.basename.to_s=~/^*.md$/ self.stack<<child end end end end |
#writer(name, contents) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/blogdown/file_pipeline.rb', line 27 def writer(name,contents) file=@base.to_s+"/output/#{name}.html" file=File.new(file.to_s,"w") file.write(contents) file.close end |