Class: Locomotive::Mounter::Reader::FileSystem::PagesReader

Inherits:
Base
  • Object
show all
Defined in:
lib/locomotive/mounter/reader/file_system/pages_reader.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#items, #runner

Instance Method Summary collapse

Methods inherited from Base

#mounting_point

Constructor Details

#initialize(runner) ⇒ PagesReader

Returns a new instance of PagesReader.



10
11
12
13
# File 'lib/locomotive/mounter/reader/file_system/pages_reader.rb', line 10

def initialize(runner)
  self.pages = {}
  super
end

Instance Attribute Details

#pagesObject

Returns the value of attribute pages.



8
9
10
# File 'lib/locomotive/mounter/reader/file_system/pages_reader.rb', line 8

def pages
  @pages
end

Instance Method Details

#readHash

Build the tree of pages based on the filesystem structure

Returns:

  • (Hash)

    The pages organized as a Hash (using the fullpath as the key)



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/locomotive/mounter/reader/file_system/pages_reader.rb', line 19

def read
  self.fetch

  index, not_found = self.pages['index'], self.pages['404']

  # localize the fullpath for the 2 core pages: index and 404
  [index, not_found].each { |p| p.localize_fullpath(self.locales) }

  self.build_relationships(index, self.pages_to_list)

  # Locomotive::Mounter.with_locale(:en) { self.to_s } # DEBUG

  # Locomotive::Mounter.with_locale(:fr) { self.to_s } # DEBUG

  self.pages
end