Sha256: ee46038b8773be1ab98550fce31fde7bb754d8b7bcee144e60f3271a22931829

Contents?: true

Size: 655 Bytes

Versions: 11

Compression:

Stored size: 655 Bytes

Contents

require "yaml"

=begin
support #respond_to?(:path). e.g. Pa

  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

11 entries across 11 versions & 1 rubygems

Version Path
tagen-1.1.7 lib/tagen/yaml.rb
tagen-1.1.6 lib/tagen/yaml.rb
tagen-1.1.5 lib/tagen/yaml.rb
tagen-1.1.4 lib/tagen/yaml.rb
tagen-1.1.3 lib/tagen/yaml.rb
tagen-1.1.2 lib/tagen/yaml.rb
tagen-1.1.1 lib/tagen/yaml.rb
tagen-1.1.0 lib/tagen/yaml.rb
tagen-1.0.4 lib/tagen/yaml.rb
tagen-1.0.3 lib/tagen/yaml.rb
tagen-1.0.2 lib/tagen/yaml.rb