Class: Munge::System

Inherits:
Object
  • Object
show all
Defined in:
lib/munge/system.rb,
lib/munge/system/router.rb,
lib/munge/system/alterant.rb,
lib/munge/system/collection.rb,
lib/munge/system/item_factory.rb,
lib/munge/system/router/itemish.rb,
lib/munge/system/readers/filesystem.rb,
lib/munge/system/item_factory/content_parser.rb,
lib/munge/system/item_factory/item_identifier.rb

Defined Under Namespace

Modules: Readers Classes: Alterant, Collection, ItemFactory, Router

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_path, config) ⇒ System

rubocop:disable Metrics/AbcSize, Metrics/MethodLength



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/munge/system.rb', line 4

def initialize(root_path, config)
  source_path  = File.expand_path(config[:source], root_path)
  layouts_path = File.expand_path(config[:layouts], root_path)
  data_path    = File.expand_path(config[:data], root_path)

  @global_data = YAML.load_file(data_path) || {}

  @config = config

  source_item_factory =
    ItemFactory.new(
      text_extensions: config[:text_extensions] + config[:bintext_extensions],
      ignore_extensions: config[:dynamic_extensions]
    )

  layouts_item_factory =
    ItemFactory.new(
      text_extensions: config[:text_extensions] + config[:bintext_extensions],
      ignore_extensions: %w(.+)
    )

  @items =
    Collection.new(
      item_factory: source_item_factory,
      items: Readers::Filesystem.new(source_path)
    )

  @layouts =
    Collection.new(
      item_factory: layouts_item_factory,
      items: Readers::Filesystem.new(layouts_path)
    )

  @alterant =
    Alterant.new

  @router =
    Router.new(
      alterant: @alterant
    )
end

Instance Attribute Details

#alterantObject

rubocop:enable Metrics/AbcSize, Metrics/MethodLength



47
48
49
# File 'lib/munge/system.rb', line 47

def alterant
  @alterant
end

#configObject

Returns the value of attribute config.



48
49
50
# File 'lib/munge/system.rb', line 48

def config
  @config
end

#global_dataObject

Returns the value of attribute global_data.



49
50
51
# File 'lib/munge/system.rb', line 49

def global_data
  @global_data
end

#itemsObject

Returns the value of attribute items.



51
52
53
# File 'lib/munge/system.rb', line 51

def items
  @items
end

#routerObject

Returns the value of attribute router.



50
51
52
# File 'lib/munge/system.rb', line 50

def router
  @router
end