Sha256: 6170fcbb3ebb2006bbeadc67577cefaf8bdd1bd16f115a7b5ff3a8850aa00cf2

Contents?: true

Size: 771 Bytes

Versions: 14

Compression:

Stored size: 771 Bytes

Contents

module FileHelpers
  def append_to(path, contents)
    cd(".") do
      File.open(path, "a") do |file|
        file.puts
        file.puts contents
      end
    end
  end

  def append_to_gemfile(contents)
    append_to("Gemfile", contents)
  end

  def comment_out_gem_in_gemfile(gemname)
    cd(".") do
      gemfile = File.read("Gemfile")
      gemfile.sub!(/^(\s*)(gem\s*['"]#{gemname})/, "\\1# \\2")
      File.open("Gemfile", "w") { |file| file.write(gemfile) }
    end
  end

  def read_from_web(url)
    file = if url.match %r{^https?://}
             Net::HTTP.get(URI.parse(url))
           else
             visit(url)
             page.source
           end
    file.force_encoding("UTF-8") if file.respond_to?(:force_encoding)
  end
end

World(FileHelpers)

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kt-paperclip-7.2.2 features/support/file_helpers.rb
kt-paperclip-7.2.1 features/support/file_helpers.rb
kt-paperclip-7.2.0 features/support/file_helpers.rb
kt-paperclip-6.4.2 features/support/file_helpers.rb
kt-paperclip-7.1.1 features/support/file_helpers.rb
kt-paperclip-7.1.0 features/support/file_helpers.rb
kt-paperclip-7.0.1 features/support/file_helpers.rb
kt-paperclip-7.0.0 features/support/file_helpers.rb
kt-paperclip-6.4.1 features/support/file_helpers.rb
kt-paperclip-6.4.0 features/support/file_helpers.rb
kt-paperclip-6.3.0 features/support/file_helpers.rb
kt-paperclip-6.2.2 features/support/file_helpers.rb
kt-paperclip-6.2.1 features/support/file_helpers.rb
kt-paperclip-6.2.0 features/support/file_helpers.rb