Sha256: 0bf75527c47c238ebb3c59c1f5f141d30d35bee11df353f97ba192f3c6af148c

Contents?: true

Size: 1.44 KB

Versions: 6

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

require "refinements/pathname"
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]

        using Refinements::Pathname

        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
          log_info "Building milestone..."

          format = input.build_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

6 entries across 6 versions & 1 rubygems

Version Path
milestoner-17.6.0 lib/milestoner/cli/commands/build.rb
milestoner-17.5.0 lib/milestoner/cli/commands/build.rb
milestoner-17.4.0 lib/milestoner/cli/commands/build.rb
milestoner-17.3.0 lib/milestoner/cli/commands/build.rb
milestoner-17.2.0 lib/milestoner/cli/commands/build.rb
milestoner-17.1.0 lib/milestoner/cli/commands/build.rb