Class: Soundwave::Site

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source = "./", destination = "./_site") ⇒ Site

Returns a new instance of Site.



45
46
47
# File 'lib/soundwave.rb', line 45

def initialize(source="./", destination="./_site")
  @source = Pathname(source).expand_path
end

Instance Attribute Details

#destinationObject

Returns the value of attribute destination.



43
44
45
# File 'lib/soundwave.rb', line 43

def destination
  @destination
end

#sourceObject

Returns the value of attribute source.



43
44
45
# File 'lib/soundwave.rb', line 43

def source
  @source
end

Instance Method Details

#data_trailObject



58
59
60
61
62
63
64
# File 'lib/soundwave.rb', line 58

def data_trail
  @_data_path ||= Hike::Trail.new(source.join("_data")).tap do |t|
    t.append_path "."
    t.append_extension ".json"
    t.append_extension ".yml", ".yaml"
  end
end

#generate(destination) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/soundwave.rb', line 49

def generate(destination)
  destination = Pathname(destination)
  Dir[source.join("**","*.mustache")].each do |path|
    next if File.basename(path).to_s =~ /^_/
    page = Page.new(self, path)
    page.write(destination.join(page.output_path))
  end
end