Class: Vacation::Jekyll

Inherits:
Object
  • Object
show all
Defined in:
lib/vacation/jekyll.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Jekyll

Returns a new instance of Jekyll.



7
8
9
10
# File 'lib/vacation/jekyll.rb', line 7

def initialize(source)
  @source = source
  throw StandardError unless File::readable_real?(source) and File::directory?(source)
end

Instance Attribute Details

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/vacation/jekyll.rb', line 5

def source
  @source
end

Instance Method Details

#compile_to(destination, options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/vacation/jekyll.rb', line 23

def compile_to(destination, options = {})
  options = config_hash.deep_merge('destination' => destination).deep_merge(options)
  site = ::Jekyll::Site.new options
  site.process
end

#config_hashObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/vacation/jekyll.rb', line 12

def config_hash
  config_file = File.join(source, '_config.yml')
  begin
    config = YAML.load_file(config_file)
  rescue => err
    config = {}
  end
  
  ::Jekyll::DEFAULTS.deep_merge(config).deep_merge('source' => source)
end