Class: Hyde::Site
- Inherits:
-
Object
- Object
- Hyde::Site
- Defined in:
- lib/hyde/site.rb
Instance Attribute Summary collapse
-
#dest ⇒ Object
Returns the value of attribute dest.
-
#files ⇒ Object
Returns the value of attribute files.
-
#options ⇒ Object
Returns the value of attribute options.
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#posts ⇒ Object
Returns the value of attribute posts.
-
#source ⇒ Object
Returns the value of attribute source.
-
#template ⇒ Object
Returns the value of attribute template.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
-
#build ⇒ Object
runs Jekyll.
-
#cleanup ⇒ Object
cleanup.
- #copy_template ⇒ Object
-
#directories ⇒ Object
create the Hyde-to-Jekyll output directories.
-
#initialize(options) ⇒ Site
constructor
A new instance of Site.
- #process ⇒ Object
-
#read ⇒ Object
read files.
-
#reset ⇒ Object
reset the time.
-
#setup ⇒ Object
copy Jekyll source files.
-
#write ⇒ Object
write jekyll files.
Constructor Details
#initialize(options) ⇒ Site
Returns a new instance of Site.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hyde/site.rb', line 8 def initialize() self. = self.pages = ['pages'] self.posts = ['posts'] self.source = File.(['source']) self.template = File.(['template']['directory']) self.dest = File.(['intermediary']['directory']) self.reset self.setup end |
Instance Attribute Details
#dest ⇒ Object
Returns the value of attribute dest.
5 6 7 |
# File 'lib/hyde/site.rb', line 5 def dest @dest end |
#files ⇒ Object
Returns the value of attribute files.
6 7 8 |
# File 'lib/hyde/site.rb', line 6 def files @files end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/hyde/site.rb', line 4 def @options end |
#pages ⇒ Object
Returns the value of attribute pages.
4 5 6 |
# File 'lib/hyde/site.rb', line 4 def pages @pages end |
#posts ⇒ Object
Returns the value of attribute posts.
4 5 6 |
# File 'lib/hyde/site.rb', line 4 def posts @posts end |
#source ⇒ Object
Returns the value of attribute source.
5 6 7 |
# File 'lib/hyde/site.rb', line 5 def source @source end |
#template ⇒ Object
Returns the value of attribute template.
5 6 7 |
# File 'lib/hyde/site.rb', line 5 def template @template end |
#time ⇒ Object
Returns the value of attribute time.
6 7 8 |
# File 'lib/hyde/site.rb', line 6 def time @time end |
Instance Method Details
#build ⇒ Object
runs Jekyll
178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/hyde/site.rb', line 178 def build = Hash.new %w[safe verbose].each do |c| [c] = [c] if [c] end ['destination'] = ['destination']['directory'] ['source'] = self.dest = Jekyll::configuration() Jekyll::Commands::Build.process() end |
#cleanup ⇒ Object
cleanup
172 173 174 175 |
# File 'lib/hyde/site.rb', line 172 def cleanup self.files = Array.new FileUtils.rm_rf(self.dest) unless ['keep'] or ['watching'] or ['serving'] end |
#copy_template ⇒ Object
124 125 126 |
# File 'lib/hyde/site.rb', line 124 def copy_template FileUtils.cp_r(Dir[File.join(template, '*')], dest, :preserve => true) end |
#directories ⇒ Object
create the Hyde-to-Jekyll output directories
90 91 92 93 |
# File 'lib/hyde/site.rb', line 90 def directories directories_helper(pages) directories_helper(posts, '_posts') end |
#process ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/hyde/site.rb', line 22 def process self.reset self.copy_template self.directories self.read self.write self.build self.cleanup end |
#read ⇒ Object
read files
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/hyde/site.rb', line 129 def read self.files ||= Array.new read_files(pages) do | source, destination | files << Page.new(source, File.join(self.dest, destination)) end read_files(posts) do | source, destination | files << Post.new(source, File.join(self.dest, destination)) end end |
#reset ⇒ Object
reset the time
33 34 35 36 37 38 39 |
# File 'lib/hyde/site.rb', line 33 def reset self.time = if ['time'] Time.parse(['time'].to_s) else Time.now end end |
#setup ⇒ Object
copy Jekyll source files
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/hyde/site.rb', line 42 def setup if ['destination']['branch'] clone_directory(['destination']) else FileUtils.rm_rf(dest) end clone_directory(['template']) if ['template']['branch'] FileUtils.rm_rf(dest) FileUtils.mkdir_p(dest) end |
#write ⇒ Object
write jekyll files
165 166 167 168 169 |
# File 'lib/hyde/site.rb', line 165 def write files.each do |file| file.write end end |