Class: Gumdrop::Site

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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.expand_path sitefile
  @root_path       = File.dirname @sitefile
  @opts            = opts
  reset_all()
end

Instance Attribute Details

#blacklistObject (readonly)

Returns the value of attribute blacklist.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def blacklist
  @blacklist
end

#configObject (readonly)

Returns the value of attribute config.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def config
  @config
end

#content_filtersObject (readonly)

Returns the value of attribute content_filters.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def content_filters
  @content_filters
end

#dataObject (readonly)

Returns the value of attribute data.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def data
  @data
end

#generatorsObject (readonly)

Returns the value of attribute generators.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def generators
  @generators
end

#greylistObject (readonly)

Returns the value of attribute greylist.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def greylist
  @greylist
end

#last_runObject (readonly)

Returns the value of attribute last_run.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def last_run
  @last_run
end

#layoutsObject (readonly)

Returns the value of attribute layouts.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def layouts
  @layouts
end

#node_treeObject (readonly)

Returns the value of attribute node_tree.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def node_tree
  @node_tree
end

#optsObject (readonly)

Returns the value of attribute opts.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def opts
  @opts
end

#partialsObject (readonly)

Returns the value of attribute partials.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def partials
  @partials
end

#redirectsObject (readonly)

Returns the value of attribute redirects.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def redirects
  @redirects
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def root_path
  @root_path
end

#sitefileObject (readonly)

Returns the value of attribute sitefile.



22
23
24
# File 'lib/gumdrop/site.rb', line 22

def sitefile
  @sitefile
end

#src_pathObject (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

#buildObject



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_contextObject

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

#rescanObject



75
76
77
78
79
80
# File 'lib/gumdrop/site.rb', line 75

def rescan
  reset_all()
  scan()
  @last_run= Time.now
  self
end

#scanObject



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