Sha256: c050c4407f60a531148f2ea9f4a479fc8a30c0e552d40f901cc0a0f28276f2f6

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

module Munge
  class System
    # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
    def initialize(root_path, config)
      source_path  = File.expand_path(config[:source], root_path)
      layouts_path = File.expand_path(config[:layouts], root_path)
      output_path  = File.expand_path(config[:output], root_path)
      data_path    = File.expand_path(config[:data], root_path)

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

      @config = config

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

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

      @source =
        Core::Collection.new(
          item_factory: source_item_factory,
          items: Reader::Filesystem.new(source_path)
        )

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

      @alterant =
        Core::Alterant.new(scope: self)

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

      @writer =
        Core::Write.new(
          output: output_path
        )
    end
    # rubocop:enable Metrics/AbcSize, Metrics/MethodLength

    attr_accessor :alterant
    attr_accessor :config
    attr_accessor :global_data
    attr_accessor :router
    attr_accessor :source
    attr_accessor :writer
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
munge-0.5.0 lib/munge/system.rb