Class: Broadway::Processor::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/broadway/processors/site.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, settings) ⇒ Site

Returns a new instance of Site.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/broadway/processors/site.rb', line 6

def initialize(site, settings)
  self.site            = Broadway.site = site
  
  site.configuration   = Broadway::Configuration.new(site, settings)
  
  self.lists           = []
  self.source          = settings[:source]
  self.lsi             = settings[:lsi]
  self.pygments        = settings[:pygments]
  self.exclude         = settings[:exclude] || []
  
  reset
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



4
5
6
# File 'lib/broadway/processors/site.rb', line 4

def configuration
  @configuration
end

#destinationObject

Returns the value of attribute destination.



4
5
6
# File 'lib/broadway/processors/site.rb', line 4

def destination
  @destination
end

#excludeObject

Returns the value of attribute exclude.



4
5
6
# File 'lib/broadway/processors/site.rb', line 4

def exclude
  @exclude
end

#listsObject

Returns the value of attribute lists.



4
5
6
# File 'lib/broadway/processors/site.rb', line 4

def lists
  @lists
end

#lsiObject

Returns the value of attribute lsi.



4
5
6
# File 'lib/broadway/processors/site.rb', line 4

def lsi
  @lsi
end

#pygmentsObject

Returns the value of attribute pygments.



4
5
6
# File 'lib/broadway/processors/site.rb', line 4

def pygments
  @pygments
end

#siteObject

Returns the value of attribute site.



4
5
6
# File 'lib/broadway/processors/site.rb', line 4

def site
  @site
end

#sourceObject

Returns the value of attribute source.



4
5
6
# File 'lib/broadway/processors/site.rb', line 4

def source
  @source
end

Instance Method Details

#buildObject



43
44
45
46
47
# File 'lib/broadway/processors/site.rb', line 43

def build
  self.reset
  self.read
  site
end

#generate(&block) ⇒ Object



49
50
51
52
53
54
# File 'lib/broadway/processors/site.rb', line 49

def generate(&block)
  raise "pass a block to `generate`" unless block_given?
  raise "define a destination for the site to be written to" if destination.blank?
  Broadway::Sinatra::Processor.new(site).run(&block) if defined?(::Sinatra)
  site
end


65
66
67
68
# File 'lib/broadway/processors/site.rb', line 65

def links
  #@links ||= Broadway::Processor::Link.build(source, site)
  @links
end

#processObject



38
39
40
41
# File 'lib/broadway/processors/site.rb', line 38

def process
  build
  generate
end

#readObject



56
57
58
59
# File 'lib/broadway/processors/site.rb', line 56

def read
  roots
  links
end

#resetObject

first



21
22
23
24
25
26
27
28
# File 'lib/broadway/processors/site.rb', line 21

def reset
  site.posts           = []
  site.assets          = []
  site.links           = []
  site.files           = []
  site.categories      = Hash.new { |hash, key| hash[key] = [] }
  site.tags            = Hash.new { |hash, key| hash[key] = [] }
end

#rootsObject



61
62
63
# File 'lib/broadway/processors/site.rb', line 61

def roots
  site.roots = Broadway::Processor::Post.build(source, site) if source
end

#settingsObject



34
35
36
# File 'lib/broadway/processors/site.rb', line 34

def settings
  site.settings
end

#writeObject



70
71
72
73
74
# File 'lib/broadway/processors/site.rb', line 70

def write
  site.files.each do |file|
    file.write(self.destination)
  end
end