Sha256: afb6b31800f8f385903f3be5d24034a71423ee978ee360244e4189170692a00c

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

module Munge
  module Cli
    module Commands
      class Build
        def initialize(bootloader, dry_run:, reporter:)
          destination_root = bootloader.root_path
          config = bootloader.config
          @app = application(bootloader)

          runner =
            Munge::Runner.new(
              items: @app.vomit(:items),
              router: @app.vomit(:router),
              alterant: @app.vomit(:alterant),
              writer: writer(dry_run),
              reporter: reporter(reporter),
              destination: File.expand_path(config[:output], destination_root)
            )

          runner.write
        end

        private

        def application(bootloader)
          bootstrap = bootloader.init

          bootstrap.app
        end

        def writer(dry_run)
          if dry_run
            Munge::Writers::Noop.new
          else
            Munge::Writers::Filesystem.new
          end
        end

        def reporter(class_name)
          Munge::Reporters.const_get(class_name).new
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
munge-0.10.0 lib/munge/cli/commands/build.rb
munge-0.9.0 lib/munge/cli/commands/build.rb
munge-0.8.0 lib/munge/cli/commands/build.rb
munge-0.7.1 lib/munge/cli/commands/build.rb