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-0.59.0 features/support/io.rb
bard-0.58.0 features/support/io.rb
bard-0.57.0 features/support/io.rb
bard-0.56.0 features/support/io.rb
bard-0.55.0 features/support/io.rb
bard-0.54.0 features/support/io.rb
bard-0.53.0 features/support/io.rb
bard-0.52.2 features/support/io.rb
bard-0.52.1 features/support/io.rb
bard-0.52.0 features/support/io.rb
bard-0.51.2 features/support/io.rb
bard-0.51.1 features/support/io.rb
bard-0.51.0 features/support/io.rb
bard-0.50.5 features/support/io.rb
bard-0.50.4 features/support/io.rb
bard-0.50.3 features/support/io.rb
bard-0.50.2 features/support/io.rb
bard-0.50.1 features/support/io.rb
bard-0.50.0 features/support/io.rb
bard-0.49.0 features/support/io.rb