Class: Brandish::Application::InitializeCommand Private

Inherits:
Object
  • Object
show all
Includes:
Thor::Actions, Thor::Base
Defined in:
lib/brandish/application/initialize_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 initialize command for the application. This creates a new project at a given directory. The Brandish project is placed at directory/name.

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 initialize command.

Returns:

  • (::String)
"Creates a new Brandish project.  The name given should not contain " \
"any path seperators - if a brandish project needs to be placed in " \
"a seperate directory, use the --directory (or -d) option."

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(application, arguments, _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 initialize command. Since this class uses Thor, this performs some setup to interface with the Thor class.

Parameters:

  • application (Application)
  • arguments (<::String>)

    The arguments passed to the initialize command. This should contain one value - the name.

  • _options (Hash)

    The options for the command. Since this command takes no specific options, this is ignored.



53
54
55
56
57
# File 'lib/brandish/application/initialize_command.rb', line 53

def self.call(application, arguments, _options)
  name = arguments[0]
  directory = application.directory / name
  new([], { name: name }, destination_root: directory).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)


37
38
39
40
41
42
# File 'lib/brandish/application/initialize_command.rb', line 37

def self.define(application, command)
  command.syntax = "brandish initialize NAME"
  command.description = COMMAND_DESCRIPTION

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

.source_root::String

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.

The source root for the templates used by Thor for initialization.

Returns:

  • (::String)


27
28
29
# File 'lib/brandish/application/initialize_command.rb', line 27

def self.source_root
  File.expand_path("../../../../templates/initialize", __FILE__)
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 initialize command, setting up the project.



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

def call
  template "brandish.config.rb"
  %w(source source/assets source/assets/styles source/assets/scripts
    templates output).each { |d| empty_directory(d) }
  template "Gemfile"
  inside(".") { run "bundle install" }
end