Sha256: 4b4fd484cc826cc6d30d5902f4caaf70a5404664728b8e47570b84913b311cb5
Contents?: true
Size: 784 Bytes
Versions: 18
Compression:
Stored size: 784 Bytes
Contents
module FileHelpers def append_to(path, contents) in_current_dir 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) in_current_dir 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
18 entries across 16 versions & 2 rubygems