Sha256: baf51ca8cf88104fd719e4867711defd5b76637c6ce753b4bee622db4ee181e2
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
module Kernel # Dumps and serialize an object to a YAML file # @param [#to_s] file the file to write to # @param [Object] obj the object to serialize def yaml_dump(file, obj) File.open(file.to_s, 'w+') {|f| f.write obj.to_yaml} end # Loads and deserialiaze the contents of a YAML file # @param [#to_s] file the YAML file to load # @return [Object] the contents of the YAML file, deserialized def yaml_load(file) YAML.load_file(file.to_s) end # Loads the contents of a file # @param [#to_s] file the file to load # @return [String] the contents of the file def file_load(file) result = "" File.open(file.to_s, 'r') do |f| while l = f.gets result << l end end result end # Writes a string to a file # @param [#to_s] file the file to write # @param [String] contents the string to write # @return [String] the string written to the file def file_write(file, contents="") File.open(file.to_s, 'w+') do |f| f.print contents end contents end # An alias for FileUtils#cp # @param [String] source the source file # @param [String] dest the destination file or directory # @param [Hash] options copy options def file_copy(source, dest, options={}) FileUtils.cp source, dest, options end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
glyph-0.3.0 | lib/glyph/system_extensions.rb |
glyph-0.2.0 | lib/glyph/system_extensions.rb |