Class: Adva::Static::Import::Source::Site

Inherits:
Base
  • Object
show all
Defined in:
lib/adva/static/import/source/site.rb

Instance Attribute Summary

Attributes inherited from Base

#path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#<=>, #initialize, #model_name, #to_hash

Constructor Details

This class inherits a constructor from Adva::Static::Import::Source::Base

Class Method Details

.recognize(paths) ⇒ Object



9
10
11
# File 'lib/adva/static/import/source/site.rb', line 9

def recognize(paths)
  paths.map { |path| new(path.delete(path).root) if path.filename == 'site' }.compact.sort # TODO ???
end

Instance Method Details

#dataObject



30
31
32
# File 'lib/adva/static/import/source/site.rb', line 30

def data
  super.merge(:sections => sections, :host => host, :name => name, :title => title)
end

#hostObject



18
19
20
# File 'lib/adva/static/import/source/site.rb', line 18

def host
  @host ||= read.host || File.basename(path.root)
end

#nameObject



22
23
24
# File 'lib/adva/static/import/source/site.rb', line 22

def name
  @name ||= read.name || host.titleize
end

#sectionsObject



14
15
16
# File 'lib/adva/static/import/source/site.rb', line 14

def sections
  @sections ||= Section.recognize(path.glob.delete_if { |path| path.filename == 'site' })
end

#titleObject



26
27
28
# File 'lib/adva/static/import/source/site.rb', line 26

def title
  @title ||= read.title || name
end