Sha256: 8198effb2c2ffb552edfeab5a8f508e8bd859893dc7ae6730dc72c44f831e37b

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

require "sod"

module Milestoner
  module CLI
    module Commands
      # Handles the building of milestone output.
      class Build < Sod::Command
        include Import[:input, :logger, :kernel]
        include Builders::Import[:ascii_doc, :markdown, :stream, :web]

        handle "build"

        description "Build milestone."

        on Actions::Build::Label
        on Actions::Build::Version
        on Actions::Build::Layout
        on Actions::Build::Format
        on Actions::Build::Root

        # :reek:TooManyStatements
        def call
          format = input.build_format

          log_info "Building #{input.project_label} milestone (#{format})..."

          case format
            when "ascii_doc" then build_ascii_doc
            when "markdown" then build_markdown
            when "stream" then build_stream
            when "web" then build_web
            else logger.abort "Invalid build format: #{format}."
          end
        end

        private

        attr_reader :view, :enricher

        def build_ascii_doc = log_info("Milestone built: #{ascii_doc.call}.")

        def build_markdown = log_info("Milestone built: #{markdown.call}.")

        def build_stream
          kernel.puts
          stream.call
        end

        def build_web = log_info "Milestone built: #{web.call}."

        def log_info(message) = logger.info { message }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
milestoner-17.11.0 lib/milestoner/cli/commands/build.rb
milestoner-17.10.0 lib/milestoner/cli/commands/build.rb
milestoner-17.9.0 lib/milestoner/cli/commands/build.rb