Class: Gumdrop::Site

Inherits:
Object
  • Object
show all
Includes:
Util::Configurable, Util::Eventable, Util::Loggable
Defined in:
lib/gumdrop/site.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::Loggable

#log

Methods included from Util::Eventable

#clear_events, #event_block, #fire

Methods included from Util::Configurable

included

Constructor Details

#initialize(sitefile, opts = {}) ⇒ Site

You shouldn’t call this yourself! Access it via Gumdrop.site



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/gumdrop/site.rb', line 41

def initialize(sitefile, opts={})
  Gumdrop.send :set_current_site, self
  @sitefile= sitefile.expand_path
  @options= Util::HashObject.from opts
  _options_updated!
  @root= File.dirname @sitefile
  @last_run= 0
  @_preparations= []

  @contents= ContentList.new
  @layouts= SpecialContentList.new ".layout"
  @partials= SpecialContentList.new
  @generators= []
  @data= DataManager.new

  clear
end

Instance Attribute Details

#active_builderObject

hmmm…



38
39
40
# File 'lib/gumdrop/site.rb', line 38

def active_builder
  @active_builder
end

#active_rendererObject

hmmm…



38
39
40
# File 'lib/gumdrop/site.rb', line 38

def active_renderer
  @active_renderer
end

#contentsObject (readonly)

Returns the value of attribute contents.



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

def contents
  @contents
end

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#generatorsObject (readonly)

Returns the value of attribute generators.



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

def generators
  @generators
end

#last_runObject (readonly)

Returns the value of attribute last_run.



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

def last_run
  @last_run
end

#layoutsObject (readonly)

Returns the value of attribute layouts.



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

def layouts
  @layouts
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

#partialsObject (readonly)

Returns the value of attribute partials.



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

def partials
  @partials
end

#rootObject (readonly)

Returns the value of attribute root.



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

def root
  @root
end

#sitefileObject (readonly)

Returns the value of attribute sitefile.



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

def sitefile
  @sitefile
end

Instance Method Details

#clearObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/gumdrop/site.rb', line 65

def clear()
  @contents.clear()
  @layouts.clear()
  @partials.clear()
  @generators.clear()
  @data.clear()

  # @contents= ContentList.new
  # @layouts= SpecialContentList.new ".layout"
  # @partials= SpecialContentList.new
  # @generators= []
  # @data= DataManager.new
  
  @is_scanned= false
  _reset_config!
  _load_sitefile
  self
end

#config_did_changeObject



166
167
168
# File 'lib/gumdrop/site.rb', line 166

def config_did_change
  Gumdrop.init_logging
end

#data_pathObject



134
135
136
# File 'lib/gumdrop/site.rb', line 134

def data_path
  @data_path ||= data_dir.expand_path(root)
end

#generateObject



102
103
104
105
106
# File 'lib/gumdrop/site.rb', line 102

def generate
  _execute_preparations
  _execute_generators
  self
end

#ignore_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


114
115
116
117
118
# File 'lib/gumdrop/site.rb', line 114

def ignore_path?(path)
  config.ignore.any? do |pattern|
    path.path_match? pattern
  end
end

#in_blacklist?(path) ⇒ Boolean

Returns:

  • (Boolean)


108
109
110
111
112
# File 'lib/gumdrop/site.rb', line 108

def in_blacklist?(path)
  blacklist.any? do |pattern|
    path.path_match? pattern
  end
end

#output_pathObject



130
131
132
# File 'lib/gumdrop/site.rb', line 130

def output_path
  @output_path ||= output_dir.expand_path(root)
end

#parentObject

Events stop bubbling here.



162
163
164
# File 'lib/gumdrop/site.rb', line 162

def parent
  nil
end

#prepare(&block) ⇒ Object



157
158
159
# File 'lib/gumdrop/site.rb', line 157

def prepare(&block)
  @_preparations << block
end

#resolve(path = nil, opts = {}) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/gumdrop/site.rb', line 138

def resolve(path=nil, opts={})
  case 
    when path.is_a?(Content)
      path
    when !path.nil?
      contents.first(path) || partials.first(path)
    when opts[:page]
      contents.first opts[:page]
    when opts[:partial]
      partials.first opts[:partial]
    when opts[:layout]
      layouts.first opts[:layout]
    when opts[:generator]
      generators.first opts[:generator]
    else
      nil
  end
end

#scan(force = false) ⇒ Object



84
85
86
87
88
89
90
91
92
# File 'lib/gumdrop/site.rb', line 84

def scan(force=false)
  if !@is_scanned or force
    clear if @is_scanned # ????
    _content_scanner
    @is_scanned= true
    generate
  end
  self
end

#scan_onlyObject

For testing…



94
95
96
97
98
99
100
# File 'lib/gumdrop/site.rb', line 94

def scan_only # For testing... 
  if !@is_scanned or force
    clear if @is_scanned # ????
    _content_scanner
  end
  self
end

#source_pathObject



126
127
128
# File 'lib/gumdrop/site.rb', line 126

def source_path
  @source_path ||= source_dir.expand_path(root)
end

#unrenderable?(path) ⇒ Boolean

Returns:

  • (Boolean)


120
121
122
123
124
# File 'lib/gumdrop/site.rb', line 120

def unrenderable?(path)
  config.no_render.any? do |pattern|
    path.path_match? pattern
  end
end