Skip to content

Commit

Permalink
merging from ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Apr 24, 2010
1 parent e0e3ea1 commit b5b0c71
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
11 changes: 1 addition & 10 deletions lib/psych.rb
Expand Up @@ -191,21 +191,12 @@ def self.to_json o
# Load multiple documents given in +yaml+. Returns the parsed documents
# as a list. For example:
#
# Psych.load_documents("--- foo\n...\n--- bar\n...") # => ['foo', 'bar']
# Psych.load_stream("--- foo\n...\n--- bar\n...") # => ['foo', 'bar']
#
def self.load_stream yaml
parse_stream(yaml).children.map { |child| child.to_ruby }
end

def self.load_documents yaml, &block
if $VERBOSE
warn "#{caller[0]}: load_documents is deprecated, use load_stream"
end
list = load_stream yaml
return list unless block_given?
list.each(&block)
end

###
# Load the document contained in +filename+. Returns the yaml contained in
# +filename+ as a ruby object
Expand Down
10 changes: 10 additions & 0 deletions lib/psych/deprecated.rb
Expand Up @@ -20,6 +20,16 @@ def self.quick_emit thing, opts = {}, &block # :nodoc:
end
target.psych_to_yaml unless opts[:nodump]
end

def self.load_documents yaml, &block
if $VERBOSE
warn "#{caller[0]}: load_documents is deprecated, use load_stream"
end
list = load_stream yaml
return list unless block_given?
list.each(&block)
end

end

class Object
Expand Down
3 changes: 3 additions & 0 deletions test/psych/test_yaml.rb
Expand Up @@ -10,6 +10,9 @@ module Psych_Tests
end

class Psych_Unit_Tests < Psych::TestCase
def teardown
Psych.domain_types.clear
end
#
# Tests modified from 00basic.t in Psych.pm
#
Expand Down

0 comments on commit b5b0c71

Please sign in to comment.