Class: Mrsk::Cli::Build

Inherits:
Base
  • Object
show all
Defined in:
lib/mrsk/cli/build.rb

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?, #initialize

Constructor Details

This class inherits a constructor from Mrsk::Cli::Base

Instance Method Details

#createObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mrsk/cli/build.rb', line 37

def create
  run_locally do
    begin
      debug "Using builder: #{MRSK.builder.name}"
      execute *MRSK.builder.create
    rescue SSHKit::Command::Failed => e
      if e.message =~ /stderr=(.*)/
        error "Couldn't create remote builder: #{$1}"
        false
      else
        raise
      end
    end
  end
end

#deliverObject



5
6
7
8
# File 'lib/mrsk/cli/build.rb', line 5

def deliver
  invoke :push
  invoke :pull
end

#detailsObject



62
63
64
65
66
67
# File 'lib/mrsk/cli/build.rb', line 62

def details
  run_locally do
    puts "Builder: #{MRSK.builder.name}"
    puts capture(*MRSK.builder.info)
  end
end

#pullObject



32
33
34
# File 'lib/mrsk/cli/build.rb', line 32

def pull
  on(MRSK.hosts) { execute *MRSK.builder.pull }
end

#pushObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mrsk/cli/build.rb', line 11

def push
  cli = self

  run_locally do 
    begin
      MRSK.with_verbosity(:debug) { execute *MRSK.builder.push }
    rescue SSHKit::Command::Failed => e
      if e.message =~ /(no builder)|(no such file or directory)/
        error "Missing compatible builder, so creating a new one first"

        if cli.create
          MRSK.with_verbosity(:debug) { execute *MRSK.builder.push }
        end
      else
        raise
      end
    end
  end
end

#removeObject



54
55
56
57
58
59
# File 'lib/mrsk/cli/build.rb', line 54

def remove
  run_locally do
    debug "Using builder: #{MRSK.builder.name}"
    execute *MRSK.builder.remove
  end
end