Module: Bridgetown::Site::Processable

Included in:
Bridgetown::Site
Defined in:
lib/bridgetown-core/concerns/site/processable.rb

Instance Method Summary collapse

Instance Method Details

#processvoid

This method returns an undefined value.

Reset, Read, Generate, Render, Cleanup, Process, and Write this Site to output.



13
14
15
16
17
18
19
20
21
# File 'lib/bridgetown-core/concerns/site/processable.rb', line 13

def process
  reset
  read
  generate  # Extensible
  render    # Renderable
  cleanup   # Writable
  write     # Writable
  print_stats if config["profile"]
end

#readvoid

This method returns an undefined value.

Read data from disk and load it into internal memory.



70
71
72
73
74
# File 'lib/bridgetown-core/concerns/site/processable.rb', line 70

def read
  Bridgetown::Hooks.trigger :site, :pre_read, self
  reader.read
  Bridgetown::Hooks.trigger :site, :post_read, self
end

#refresh_layouts_and_dataObject

Read layouts and merge any new data collection contents into the site data



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/bridgetown-core/concerns/site/processable.rb', line 56

def refresh_layouts_and_data
  reader.read_layouts

  collections.data.tap do |coll|
    coll.resources.clear
    coll.read
    coll.merge_data_resources.each do |k, v|
      data[k] = v # refresh site data
    end
  end
end

#reset(soft: false) ⇒ void

This method returns an undefined value.

Reset all in-memory data and content.

Parameters:

  • soft (Boolean) (defaults to: false)

    if true, persist some state and do a light refresh of layouts and data



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/bridgetown-core/concerns/site/processable.rb', line 27

def reset(soft: false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  self.time = Time.now
  if config["time"]
    self.time = Bridgetown::Utils.parse_date(
      config["time"].to_s, "Invalid time in bridgetown.config.yml."
    )
  end
  self.layouts = HashWithDotAccess::Hash.new
  self.generated_pages = []
  self.static_files = []
  self.data = HashWithDotAccess::Hash.new unless soft
  @frontend_manifest = nil
  @collections = nil
  @documents = nil
  @docs_to_write = nil
  @liquid_renderer.reset
  tmp_cache.clear

  if soft
    refresh_layouts_and_data
  else
    frontmatter_defaults.reset
    Bridgetown::Cache.clear_if_config_changed config
  end

  Bridgetown::Hooks.trigger :site, (soft ? :after_soft_reset : :after_reset), self
end