Class: Gumdrop::Site
- Inherits:
-
Object
- Object
- Gumdrop::Site
- 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(pattern = nil, opts = {}) ⇒ 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
- #scan ⇒ Object
Constructor Details
#initialize(sitefile, opts = {}) ⇒ Site
Returns a new instance of Site.
39 40 41 42 43 44 |
# File 'lib/gumdrop/site.rb', line 39 def initialize(sitefile, opts={}) @sitefile = File. sitefile @root_path = File.dirname @sitefile @opts = opts reset_all() end |
Instance Attribute Details
#blacklist ⇒ Object (readonly)
Returns the value of attribute blacklist.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def blacklist @blacklist end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def config @config end |
#content_filters ⇒ Object (readonly)
Returns the value of attribute content_filters.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def content_filters @content_filters end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def data @data end |
#generators ⇒ Object (readonly)
Returns the value of attribute generators.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def generators @generators end |
#greylist ⇒ Object (readonly)
Returns the value of attribute greylist.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def greylist @greylist end |
#last_run ⇒ Object (readonly)
Returns the value of attribute last_run.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def last_run @last_run end |
#layouts ⇒ Object (readonly)
Returns the value of attribute layouts.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def layouts @layouts end |
#node_tree ⇒ Object (readonly)
Returns the value of attribute node_tree.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def node_tree @node_tree end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def opts @opts end |
#partials ⇒ Object (readonly)
Returns the value of attribute partials.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def partials @partials end |
#redirects ⇒ Object (readonly)
Returns the value of attribute redirects.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def redirects @redirects end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def root_path @root_path end |
#sitefile ⇒ Object (readonly)
Returns the value of attribute sitefile.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def sitefile @sitefile end |
#src_path ⇒ Object (readonly)
Returns the value of attribute src_path.
22 23 24 |
# File 'lib/gumdrop/site.rb', line 22 def src_path @src_path end |
Instance Method Details
#build ⇒ Object
82 83 84 85 86 87 |
# File 'lib/gumdrop/site.rb', line 82 def build scan() render() @last_run= Time.now self end |
#contents(pattern = nil, opts = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/gumdrop/site.rb', line 46 def contents(pattern=nil, opts={}) 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
104 105 106 107 |
# File 'lib/gumdrop/site.rb', line 104 def render_context @context ||= Context.new self @context end |
#report(msg, level = :info) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/gumdrop/site.rb', line 89 def report(msg, level=:info) # ll= @config.log_level case level when :info @log.info msg when :warning @log.warn msg else puts msg @log.error msg end end |
#rescan ⇒ Object
75 76 77 78 79 80 |
# File 'lib/gumdrop/site.rb', line 75 def rescan reset_all() scan() @last_run= Time.now self end |
#scan ⇒ Object
68 69 70 71 72 73 |
# File 'lib/gumdrop/site.rb', line 68 def scan build_tree() run_generators() @last_run= Time.now self end |