Class: Blogdown::FilePipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/blogdown/file_pipeline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#stackObject

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_filesObject



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