Sha256: 533a1bc91194468a211cd6ae0f5e442330d66dc4b88a8d109b583611b3a8d9df

Contents?: true

Size: 850 Bytes

Versions: 21

Compression:

Stored size: 850 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

21 entries across 21 versions & 1 rubygems

Version Path
bard-1.3.9 features/support/io.rb
bard-1.3.8 features/support/io.rb
bard-1.3.7 features/support/io.rb
bard-1.3.6 features/support/io.rb
bard-1.3.5 features/support/io.rb
bard-1.3.4 features/support/io.rb
bard-1.3.3 features/support/io.rb
bard-1.3.2 features/support/io.rb
bard-1.3.1 features/support/io.rb
bard-1.3.0 features/support/io.rb
bard-1.2.0 features/support/io.rb
bard-1.1.2 features/support/io.rb
bard-1.1.1 features/support/io.rb
bard-1.1.0 features/support/io.rb
bard-1.0.8 features/support/io.rb
bard-1.0.7 features/support/io.rb
bard-1.0.6 features/support/io.rb
bard-1.0.5 features/support/io.rb
bard-1.0.4 features/support/io.rb
bard-1.0.3 features/support/io.rb