Module: Engineyard::Local::Command::Helpers

Included in:
Vagrant::Command::Base
Defined in:
lib/engineyard-local/command/helpers.rb

Instance Method Summary collapse

Instance Method Details

#insert_linebreaks(txt, maxlength = 76, ensure_linebreaks = true) ⇒ Object

Stupid, simple formatter for text. Returns an array of lines.



7
8
9
10
11
12
13
14
15
# File 'lib/engineyard-local/command/helpers.rb', line 7

def insert_linebreaks(txt, maxlength = 76, ensure_linebreaks = true)
  "#{txt} ".scan(/.{0,#{maxlength}}\s+/).collect do |line|
    if ensure_linebreaks
      line =~ /\n$/ ? line : line + "\n"
    else
      line
    end
  end
end

#merge_run_options(vm, opts = {}) ⇒ Object

TODO borrowed entirely from vagrant, running outside it’s command structure is causing issues that need remedy



26
27
28
29
30
31
# File 'lib/engineyard-local/command/helpers.rb', line 26

def merge_run_options(vm, opts={})
  {
    :vm => vm,
    :ui => vm.env.ui.dup
  }.merge(opts || {})
end

#run(middleware, opts = {}, &block) ⇒ Object



17
18
19
20
21
22
# File 'lib/engineyard-local/command/helpers.rb', line 17

def run(middleware, opts={}, &block)
  with_target_vms do |vm|
    opts = merge_run_options(vm, opts)
    vm.env.action_runner.run(middleware, opts)
  end
end