Class: Skriptorium::Local::Destination

Inherits:
BaseDestination show all
Defined in:
lib/skriptorium/local/destination.rb

Instance Attribute Summary

Attributes inherited from BaseDestination

#cache, #config

Instance Method Summary collapse

Methods inherited from BaseDestination

#with_cache

Constructor Details

#initialize(config) ⇒ Destination

Returns a new instance of Destination.



6
7
8
9
10
# File 'lib/skriptorium/local/destination.rb', line 6

def initialize(config)
  super
  @path = config['path']
  @format = config.fetch('format', 'html')
end

Instance Method Details

#exists?(article) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/skriptorium/local/destination.rb', line 12

def exists?(article)
  File.exist?(filepath(article))
end

#publish(article) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/skriptorium/local/destination.rb', line 16

def publish(article)
  FileUtils.mkdir_p(@path)

  if @format == 'html'
    File.write(filepath(article), article.to_html)
  else
    File.write(filepath(article), article.to_markdown)
  end
  puts "  Saved to Local: #{filepath(article)}"
end