Class: Gumdrop::Site
- Inherits:
-
Object
- Object
- Gumdrop::Site
- Extended by:
- Callbacks
- Defined in:
- lib/gumdrop/site.rb
Instance Attribute Summary collapse
-
#blacklist ⇒ Object
readonly
Returns the value of attribute blacklist.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#content_filters ⇒ Object
readonly
Returns the value of attribute content_filters.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#generators ⇒ Object
readonly
Returns the value of attribute generators.
-
#greylist ⇒ Object
readonly
Returns the value of attribute greylist.
-
#last_run ⇒ Object
readonly
Returns the value of attribute last_run.
-
#layouts ⇒ Object
readonly
Returns the value of attribute layouts.
-
#node_tree ⇒ Object
readonly
Returns the value of attribute node_tree.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#partials ⇒ Object
readonly
Returns the value of attribute partials.
-
#redirects ⇒ Object
readonly
Returns the value of attribute redirects.
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
-
#sitefile ⇒ Object
readonly
Returns the value of attribute sitefile.
-
#src_path ⇒ Object
readonly
Returns the value of attribute src_path.
Instance Method Summary collapse
- #build ⇒ Object
- #contents(*args) ⇒ Object
-
#initialize(sitefile, opts = {}) ⇒ Site
constructor
A new instance of Site.
-
#render_context ⇒ Object
FIXME: Should a new Context be created for every page? For now it’s a single context for whole site.
- #report(msg, level = :info) ⇒ Object
- #rescan ⇒ Object
Methods included from Callbacks
Constructor Details
#initialize(sitefile, opts = {}) ⇒ Site
Returns a new instance of Site.
47 48 49 50 51 52 53 |
# File 'lib/gumdrop/site.rb', line 47 def initialize(sitefile, opts={}) @sitefile = File. sitefile @root_path = File.dirname @sitefile @opts = opts @last_run = nil reset_all() end |
Instance Attribute Details
#blacklist ⇒ Object (readonly)
Returns the value of attribute blacklist.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def blacklist @blacklist end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def config @config end |
#content_filters ⇒ Object (readonly)
Returns the value of attribute content_filters.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def content_filters @content_filters end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def data @data end |
#generators ⇒ Object (readonly)
Returns the value of attribute generators.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def generators @generators end |
#greylist ⇒ Object (readonly)
Returns the value of attribute greylist.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def greylist @greylist end |
#last_run ⇒ Object (readonly)
Returns the value of attribute last_run.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def last_run @last_run end |
#layouts ⇒ Object (readonly)
Returns the value of attribute layouts.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def layouts @layouts end |
#node_tree ⇒ Object (readonly)
Returns the value of attribute node_tree.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def node_tree @node_tree end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def opts @opts end |
#partials ⇒ Object (readonly)
Returns the value of attribute partials.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def partials @partials end |
#redirects ⇒ Object (readonly)
Returns the value of attribute redirects.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def redirects @redirects end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def root_path @root_path end |
#sitefile ⇒ Object (readonly)
Returns the value of attribute sitefile.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def sitefile @sitefile end |
#src_path ⇒ Object (readonly)
Returns the value of attribute src_path.
20 21 22 |
# File 'lib/gumdrop/site.rb', line 20 def src_path @src_path end |
Instance Method Details
#build ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'lib/gumdrop/site.rb', line 89 def build on_start(self) scan() render() @last_run= Time.now on_end(self) self end |
#contents(*args) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/gumdrop/site.rb', line 55 def contents(*args) opts= args. pattern= args[0] || nil if pattern.nil? if opts[:as] == :hash @node_tree else @node_tree.values end else nodes = opts[:as] == :hash ? {} : [] @node_tree.keys.each do |path| if path_match path, pattern if opts[:as] == :hash nodes[path]= @node_tree[path] else nodes << @node_tree[path] end end end nodes end end |
#render_context ⇒ Object
FIXME: Should a new Context be created for every page? For now
it's a single context for whole site
112 113 114 115 |
# File 'lib/gumdrop/site.rb', line 112 def render_context @context ||= Context.new self @context end |
#report(msg, level = :info) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/gumdrop/site.rb', line 98 def report(msg, level=:info) case level when :info @log.info msg when :warning @log.warn msg else puts msg @log.error msg end end |
#rescan ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/gumdrop/site.rb', line 79 def rescan on_start(self) reset_all() scan() @last_run= Time.now # TODO: should on_before_render and on_render be called for rescan()? on_end(self) self end |