Class: Brandish::Application::BuildCommand Private

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/brandish/application/build_command.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The build command. This just builds the project in the set directory.

Constant Summary collapse

COMMAND_DESCRIPTION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The description for the build command.

Returns:

  • (::String)
"Builds an existing Brandish project.  If no directory is specified " \
" using --directory or -d, it defaults to the current directory."
DEFAULTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The default options for the build command.

Returns:

  • ({::Symbol => ::Object})
{ only: :all }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application, options) ⇒ BuildCommand

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize the build command.



51
52
53
54
# File 'lib/brandish/application/build_command.rb', line 51

def initialize(application, options)
  @application = application
  @options = DEFAULTS.merge(options)
end

Class Method Details

.call(application, options) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Performs the build command. This initializes the command, and calls #call.

Parameters:

  • application (Application)

    The application.

  • options ({::Symbol => ::Object})

    The options for the command.



44
45
46
# File 'lib/brandish/application/build_command.rb', line 44

def self.call(application, options)
  new(application, options).call
end

.define(application, command) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Defines the command on the given application. This sets the important data information for the command, for use for the help output.

Parameters:

  • application (Application)
  • command (Commander::Command)


23
24
25
26
27
28
29
30
# File 'lib/brandish/application/build_command.rb', line 23

def self.define(application, command)
  command.syntax = "brandish build"
  command.description = COMMAND_DESCRIPTION
  command.option "-o", "--only NAMES", [::String],
    "Which forms to build.  If this is omitted, it defaults to all."

  command.action { |_, o| call(application, o.__hash__) }
end

Instance Method Details

#callvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Performs the build. First, it loads the configuration file for the build. Then, it performs the build, calling Configure#build with the :only filter provided by the options. This uses a Commander native called progress to make it look nice on the output.



62
63
64
65
66
67
68
69
70
# File 'lib/brandish/application/build_command.rb', line 62

def call
  configure = @application.load_configuration_file
  @application.progress(configure.build(@options[:only]).to_a, &:call)
rescue => e
  say_error "\n!> Error while building!"
  say_error "!> #{e.location}" if e.respond_to?(:location)
  say_error "!> Received exception: #{e.class}: #{e.message}"
  e.backtrace.each { |l| say_warning "\t~> in #{l}" } if @options[:trace]
end