summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-03-22 09:54:27 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-03-22 09:54:27 -0700
commitc908d22b6c9b502a99f7182d0a37952a4336e271 (patch)
tree869044a83eae01351be205cde15617b3e78e433e /lib
parenta086e89e5364c88350122c3608e1618b90d46b0d (diff)
downloadpsych-c908d22b6c9b502a99f7182d0a37952a4336e271.zip
adding support for add_builtin_type. fixes GH #1
Diffstat (limited to 'lib')
-rw-r--r--lib/psych.rb10
-rw-r--r--lib/psych/visitors/to_ruby.rb2
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/psych.rb b/lib/psych.rb
index 5f66849..d244ddf 100644
--- a/lib/psych.rb
+++ b/lib/psych.rb
@@ -170,7 +170,15 @@ module Psych
# :stopdoc:
@domain_types = {}
def self.add_domain_type domain, type_tag, &block
- @domain_types[type_tag] = [domain, block]
+ @domain_types[type_tag] = ["http://#{domain}", block]
+ end
+
+ def self.add_builtin_type type_tag, &block
+ @domain_types[type_tag] = ['yaml.org', block]
+ end
+
+ def self.remove_type type_tag
+ @domain_types.delete type_tag
end
@load_tags = {}
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb
index d5704bb..dfe4811 100644
--- a/lib/psych/visitors/to_ruby.rb
+++ b/lib/psych/visitors/to_ruby.rb
@@ -19,7 +19,7 @@ module Psych
short_name = target.tag.sub(/^!/, '').split('/', 2).last
if Psych.domain_types.key? short_name
url, block = Psych.domain_types[short_name]
- return block.call "http://#{url}:#{short_name}", result
+ return block.call "#{url}:#{short_name}", result
end
result