Module: Lambit::Commands::Build

Defined in:
lib/lambit/commands/build.rb

Defined Under Namespace

Classes: Base, CompressPackageCommand, PackagePipCommand, PackageSourceCommand, PackageTemplatesCommand

Class Method Summary collapse

Class Method Details

.handler_for(cmd) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/lambit/commands/build.rb', line 27

def self.handler_for(cmd)
  if @handlers
    @handlers[normalize_cmd(cmd)]
  else
    raise 'Uh Oh!'
  end
end

.normalize_cmd(cmd) ⇒ Object



23
24
25
# File 'lib/lambit/commands/build.rb', line 23

def self.normalize_cmd(cmd)
  cmd.to_s.downcase
end

.register_handler_for(cmd, handler = nil) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/lambit/commands/build.rb', line 35

def self.register_handler_for(cmd, handler=nil)
  normalized_cmd = normalize_cmd(cmd)
  handler        = self.const_get(normalized_cmd.classify) if handler.nil?

  @handlers ||= {}
  @handlers[normalized_cmd] = handler
end

.run(cmd, opts, args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/lambit/commands/build.rb', line 10

def self.run(cmd, opts, args)
  handler            = handler_for cmd
  output, exitstatus = handler.run opts, args

  # Send Subcommand output to STDOUT if :debug
  if Lambit.is_debug?
    puts output unless output.nil? || output.empty?
  end

  # Return exit status
  exitstatus
end