Sha256: b7da05f9249e9a7c7e937e8da759644615fdaf9fcbccc77bb2b57660833d2497

Contents?: true

Size: 851 Bytes

Versions: 52

Compression:

Stored size: 851 Bytes

Contents

require "open3"
def type(command)
  @stdout, @stderr, @status = Open3.capture3(@env, command)
  if ENV['DEBUG']
    puts '-' * 20
    puts "Executing command: #{command}"
    puts "  Status: #{@status}"
    puts "  Stdout:\n #{@stdout}"
    puts "  Stderr:\n #{@stderr}"
    puts '-' * 20
  end
  @stdout || @stderr
end

def file_append(file_name, contents)
  File.open(file_name, 'ab') { |file| file.puts("\n#{contents}") }
end

def file_inject(file_name, sentinel, string, before_after=:after)
  gsub_file file_name, /(#{Regexp.escape(sentinel)})/mi do |match|
    if before_after == :after 
      "#{match}\n#{string}"
    else
      "#{string}\n#{match}"
    end
  end
end

def gsub_file(file_name, regexp, *args, &block)
  content = File.read(file_name).gsub(regexp, *args, &block)
  File.open(file_name, 'wb') { |file| file.write(content) }
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
bard-1.0.1 features/support/io.rb
bard-1.0.0 features/support/io.rb
bard-0.69.2 features/support/io.rb
bard-0.69.1 features/support/io.rb
bard-0.69.0 features/support/io.rb
bard-0.68.0 features/support/io.rb
bard-0.67.0 features/support/io.rb
bard-0.66.0 features/support/io.rb
bard-0.65.0 features/support/io.rb
bard-0.64.1 features/support/io.rb
bard-0.64.0 features/support/io.rb
bard-0.63.0 features/support/io.rb
bard-0.62.2 features/support/io.rb
bard-0.62.1 features/support/io.rb
bard-0.62.0 features/support/io.rb
bard-0.61.0 features/support/io.rb
bard-0.60.0 features/support/io.rb
bard-0.59.3 features/support/io.rb
bard-0.59.2 features/support/io.rb
bard-0.59.1 features/support/io.rb