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



40
41
42
43
44
45
46
47
48
# File 'lib/gumdrop/site.rb', line 40

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
  clear
end

Instance Attribute Details

#active_builderObject

hmmm…



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

def active_builder
  @active_builder
end

#active_rendererObject

hmmm…



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

def active_renderer
  @active_renderer
end

#contentsObject (readonly)

Returns the value of attribute contents.



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

def contents
  @contents
end

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#generatorsObject (readonly)

Returns the value of attribute generators.



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

def generators
  @generators
end

#last_runObject (readonly)

Returns the value of attribute last_run.



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

def last_run
  @last_run
end

#layoutsObject (readonly)

Returns the value of attribute layouts.



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

def layouts
  @layouts
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

#partialsObject (readonly)

Returns the value of attribute partials.



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

def partials
  @partials
end

#rootObject (readonly)

Returns the value of attribute root.



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

def root
  @root
end

#sitefileObject (readonly)

Returns the value of attribute sitefile.



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

def sitefile
  @sitefile
end

Instance Method Details

#clearObject



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/gumdrop/site.rb', line 56

def 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



139
140
141
# File 'lib/gumdrop/site.rb', line 139

def config_did_change
  Gumdrop.init_logging
end

#data_pathObject



111
112
113
# File 'lib/gumdrop/site.rb', line 111

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

#generateObject



86
87
88
89
# File 'lib/gumdrop/site.rb', line 86

def generate
  _execute_generators
  self
end

#ignore_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


97
98
99
100
101
# File 'lib/gumdrop/site.rb', line 97

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

#in_blacklist?(path) ⇒ Boolean

Returns:

  • (Boolean)


91
92
93
94
95
# File 'lib/gumdrop/site.rb', line 91

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

#output_pathObject



107
108
109
# File 'lib/gumdrop/site.rb', line 107

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

#parentObject

Events stop bubbling here.



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

def parent
  nil
end

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



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/gumdrop/site.rb', line 115

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



68
69
70
71
72
73
74
75
76
# File 'lib/gumdrop/site.rb', line 68

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…



78
79
80
81
82
83
84
# File 'lib/gumdrop/site.rb', line 78

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

#source_pathObject



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

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