Class: Blogdown::FilePipeline
- Inherits:
-
Object
- Object
- Blogdown::FilePipeline
- Defined in:
- lib/blogdown/file_pipeline.rb
Instance Attribute Summary collapse
-
#stack ⇒ Object
THis keeps track of files being processed.
Instance Method Summary collapse
-
#initialize(root) ⇒ FilePipeline
constructor
A new instance of FilePipeline.
-
#load_files ⇒ Array
The files under posts folder.
-
#writer(name, contents) ⇒ Object
Writes given contents into a file with a name given as a parameter.
Constructor Details
#initialize(root) ⇒ FilePipeline
Returns a new instance of FilePipeline.
6 7 8 9 10 11 |
# File 'lib/blogdown/file_pipeline.rb', line 6 def initialize(root) @root=root @base=Pathname(@root) @stack=[] load_files end |
Instance Attribute Details
#stack ⇒ Object
THis keeps track of files being processed
5 6 7 |
# File 'lib/blogdown/file_pipeline.rb', line 5 def stack @stack end |
Instance Method Details
#load_files ⇒ Array
Returns The files under posts folder.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/blogdown/file_pipeline.rb', line 14 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
Writes given contents into a file with a name given as a parameter
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/blogdown/file_pipeline.rb', line 33 def writer(name,contents) file=@base.to_s+"/output/#{name}.html" begin file=File.new(file.to_s,"w") file.write(contents) file.close rescue Exception=>e raise e end end |