Sha256: 912b8ca95de24150ded4e5af007d1b57b88afcd441ba8bfc515e3427f57cd15b

Contents?: true

Size: 617 Bytes

Versions: 5

Compression:

Stored size: 617 Bytes

Contents

require "yaml"

=begin
  YAML.load(Pa('/tmp/a'))
	YAML.dump("x", Pa('/tmp/a'))
=end
module YAML
	class << self
		alias original_load load
		alias original_dump dump

		# add #path support 
		# @param [String,IO,#path] path
		def load path
			if path.respond_to?(:path)
				path = path.path
				open(path){|f| original_load(f)}

			else
				original_load path
			end
		end

		# add String, #path support 
		# @param [String,IO,#path] path
		def dump obj, path
			if path.respond_to?(:path)
				path = path.path
				open(path, "w+"){|f| original_dump(obj, f)}
			else
				original_dump obj, path
			end
		end

	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tagen-1.0.1 lib/tagen/yaml.rb
tagen-1.0.0 lib/tagen/yaml.rb
tagen-0.2.5 lib/tagen/yaml.rb
tagen-0.2.4 lib/tagen/yaml.rb
tagen-0.2.3 lib/tagen/yaml.rb