Module: SmarterBundler::Shell

Included in:
Bundle
Defined in:
lib/smarter_bundler/shell.rb

Instance Method Summary collapse

Instance Method Details

#shell(command) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/smarter_bundler/shell.rb', line 3

def shell(command)
  puts '',"+ #{command}"
  output = [ ]
  IO.popen("#{command} 2>&1") do |io|
    while line = io.gets
      puts line.chomp
      output << line.chomp
    end
    io.close
  end
  puts "Command returned status: #{$?.to_i} (#{$?.success? ? 'success' : 'fail'})"
  Struct.new(:status, :output).new($?, output)
end

#shell?(command) ⇒ Boolean



17
18
19
20
# File 'lib/smarter_bundler/shell.rb', line 17

def shell?(command)
  result = shell(command)
  result.status.success?
end