Class: Plz::CommandBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/plz/command_builder.rb

Constant Summary collapse

SCHEMA_FILE_PATH_PATTERN =
"schema.{json,yml}"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CommandBuilder

Returns a new instance of CommandBuilder.

Parameters:

  • argv (Array<String>)

    Raw ARGV



22
23
24
# File 'lib/plz/command_builder.rb', line 22

def initialize(argv)
  @argv = argv
end

Class Method Details

.call(arguments) ⇒ Plz::Command

Builds callable command object from given ARGV

Examples:

Plz::CommandBuilder.call(ARGV).call

Returns:



9
10
11
# File 'lib/plz/command_builder.rb', line 9

def self.call(arguments)
  new(arguments).call
end

Instance Method Details

#callPlz::Command

Returns Callable command object.

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/plz/command_builder.rb', line 27

def call
  validate!
  Command.new(
    method: method,
    base_url: base_url,
    path: path,
    headers: headers,
    params: request_params,
  )
rescue Error => error
  ErrorCommand.new(error)
end