summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2009-09-28 12:13:43 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2009-09-28 12:13:43 -0700
commit5afbd2432372d0d137cd8ef579a1e73e6deb7d87 (patch)
tree0627599eda6bcd2903d94d5cba288fc7981abff0
parent1d0463ca1f63f84032b5b983962e59f88ff123a0 (diff)
downloadpsych-5afbd2432372d0d137cd8ef579a1e73e6deb7d87.zip
initial load is working
-rw-r--r--lib/psych.rb8
-rw-r--r--test/test_psych.rb6
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/psych.rb b/lib/psych.rb
index bdc2458..bbb8662 100644
--- a/lib/psych.rb
+++ b/lib/psych.rb
@@ -19,7 +19,11 @@ module Psych
VERSION = '1.0.0'
LIBYAML_VERSION = Psych.libyaml_version.join '.'
- def self.parse thing
- Psych::Parser.new.parse thing
+ ###
+ # Load +yaml+ in to a Ruby data structure
+ def self.load yaml
+ parser = Psych::Parser.new(TreeBuilder.new)
+ parser.parse yaml
+ parser.handler.root.children.first.to_ruby
end
end
diff --git a/test/test_psych.rb b/test/test_psych.rb
index 865024f..96d0f69 100644
--- a/test/test_psych.rb
+++ b/test/test_psych.rb
@@ -2,9 +2,9 @@ require 'minitest/autorun'
require 'psych'
class TestPsych < MiniTest::Unit::TestCase
- #def test_simple
- # assert_equal 'foo', Psych.parse("--- foo\n")
- #end
+ def test_simple
+ assert_equal 'foo', Psych.load("--- foo\n")
+ end
def test_libyaml_version
assert Psych.libyaml_version