File: command_helper.rb

package info (click to toggle)
ruby-mina 0.3.7-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 444 kB
  • sloc: ruby: 1,630; makefile: 31
file content (52 lines) | stat: -rw-r--r-- 905 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Invokes the main 'mina' command.
def run_command(*args)
  out = ''
  err = ''
  @result = nil

  if ENV['rake']
    rake_version = "~> #{ENV['rake'] || '0.9'}.0"
    script  = %[require 'rubygems' unless Object.const_defined?(:Gem);]
    script += %[gem 'rake', '#{rake_version}';]
    script += %[load '#{root('bin/mina')}']
    cmd = ['ruby', '-e', "#{script}", "--", *args]
  else
    cmd = [root('bin/mina'), *args]
  end

  status =
    Mina::Tools.popen4(*cmd) do |pid, i, o, e|
      out = o.read
      err = e.read
    end

  @result = status.exitstatus

  @out = out
  @err = err

  @result
end

# Invokes the main 'mina' command and ensures the exit status is success.
def mina(*args)
  run_command *args
  if exitstatus != 0 && ENV['verbose']
    puts stdout
    puts stderr
  end

  expect(exitstatus).to eq(0)
end

def stdout
  @out
end

def stderr
  @err
end

def exitstatus
  @result
end