Class: Broadway::Processor::Site
- Inherits:
-
Object
- Object
- Broadway::Processor::Site
- Defined in:
- lib/broadway/processors/site.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#exclude ⇒ Object
Returns the value of attribute exclude.
-
#lists ⇒ Object
Returns the value of attribute lists.
-
#lsi ⇒ Object
Returns the value of attribute lsi.
-
#pygments ⇒ Object
Returns the value of attribute pygments.
-
#site ⇒ Object
Returns the value of attribute site.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #build ⇒ Object
- #generate(&block) ⇒ Object
-
#initialize(site, settings) ⇒ Site
constructor
A new instance of Site.
- #links ⇒ Object
- #process ⇒ Object
- #read ⇒ Object
-
#reset ⇒ Object
first.
- #roots ⇒ Object
- #settings ⇒ Object
- #write ⇒ Object
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
#configuration ⇒ Object
Returns the value of attribute configuration.
4 5 6 |
# File 'lib/broadway/processors/site.rb', line 4 def configuration @configuration end |
#destination ⇒ Object
Returns the value of attribute destination.
4 5 6 |
# File 'lib/broadway/processors/site.rb', line 4 def destination @destination end |
#exclude ⇒ Object
Returns the value of attribute exclude.
4 5 6 |
# File 'lib/broadway/processors/site.rb', line 4 def exclude @exclude end |
#lists ⇒ Object
Returns the value of attribute lists.
4 5 6 |
# File 'lib/broadway/processors/site.rb', line 4 def lists @lists end |
#lsi ⇒ Object
Returns the value of attribute lsi.
4 5 6 |
# File 'lib/broadway/processors/site.rb', line 4 def lsi @lsi end |
#pygments ⇒ Object
Returns the value of attribute pygments.
4 5 6 |
# File 'lib/broadway/processors/site.rb', line 4 def pygments @pygments end |
#site ⇒ Object
Returns the value of attribute site.
4 5 6 |
# File 'lib/broadway/processors/site.rb', line 4 def site @site end |
#source ⇒ Object
Returns the value of attribute source.
4 5 6 |
# File 'lib/broadway/processors/site.rb', line 4 def source @source end |
Instance Method Details
#build ⇒ Object
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 |
#links ⇒ Object
65 66 67 68 |
# File 'lib/broadway/processors/site.rb', line 65 def links #@links ||= Broadway::Processor::Link.build(source, site) @links end |
#process ⇒ Object
38 39 40 41 |
# File 'lib/broadway/processors/site.rb', line 38 def process build generate end |
#read ⇒ Object
56 57 58 59 |
# File 'lib/broadway/processors/site.rb', line 56 def read roots links end |
#reset ⇒ Object
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. = Hash.new { |hash, key| hash[key] = [] } end |
#roots ⇒ Object
61 62 63 |
# File 'lib/broadway/processors/site.rb', line 61 def roots site.roots = Broadway::Processor::Post.build(source, site) if source end |
#settings ⇒ Object
34 35 36 |
# File 'lib/broadway/processors/site.rb', line 34 def settings site.settings end |
#write ⇒ Object
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 |