- Timestamp:
- 11/13/2005 17:43:56 (3 years ago)
- Location:
- trunk/ext/ruby
- Files:
-
- 6 modified
-
ext/syck/rubyext.c (modified) (3 diffs)
-
lib/yaml.rb (modified) (2 diffs)
-
lib/yaml/basenode.rb (modified) (1 diff)
-
lib/yaml/rubytypes.rb (modified) (1 diff)
-
lib/yaml/tag.rb (modified) (2 diffs)
-
lib/yaml/types.rb (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/ruby/ext/syck/rubyext.c
r223 r231 84 84 void rb_syck_emitter_handler _((SyckEmitter *, st_data_t)); 85 85 int syck_parser_assign_io _((SyckParser *, VALUE)); 86 VALUE syck_scalar_alloc _((VALUE class)); 87 VALUE syck_seq_alloc _((VALUE class)); 88 VALUE syck_map_alloc _((VALUE class)); 86 89 87 90 struct parser_xtra { … … 775 778 } 776 779 rb_ivar_set(self, s_options, options); 780 rb_ivar_set(self, s_input, Qnil); 777 781 return self; 778 782 } … … 1344 1348 VALUE 1345 1349 syck_domaintype_initialize( self, domain, type_id, val ) 1346 VALUE self, type_id, val;1350 VALUE self, domain, type_id, val; 1347 1351 { 1348 1352 rb_iv_set( self, "@domain", domain ); -
trunk/ext/ruby/lib/yaml.rb
r209 r231 13 13 require 'yaml/tag' 14 14 require 'yaml/stream' 15 require 'yaml/constants' 15 16 16 17 # == YAML … … 393 394 require 'yaml/types' 394 395 395 module Kernel # :nodoc:396 module Kernel 396 397 # 397 398 # ryan:: You know how Kernel.p is a really convenient way to dump ruby -
trunk/ext/ruby/lib/yaml/basenode.rb
r230 r231 149 149 case pred 150 150 when /^\.=/ 151 pred = $' 151 pred = $' # ' 152 152 match_nodes.reject! { |n| 153 153 n.last.value != pred -
trunk/ext/ruby/lib/yaml/rubytypes.rb
r228 r231 185 185 def Symbol.yaml_new( klass, tag, val ) 186 186 if String === val 187 val = YAML::load( val ) if val =~ /\A(["']).*\1\z/ 187 188 val.intern 188 189 else -
trunk/ext/ruby/lib/yaml/tag.rb
r216 r231 56 56 # taguris. 57 57 def yaml_as( tag, sc = true ) 58 class_eval <<-"end;" 59 attr_accessor :taguri 58 verbose, $VERBOSE = $VERBOSE, nil 59 class_eval <<-"end;", __FILE__, __LINE__+1 60 attr_writer :taguri 60 61 def taguri 61 62 if respond_to? :to_yaml_type 62 63 YAML::tagurize( to_yaml_type[1..-1] ) 63 64 else 64 return @taguri if @taguri65 return @taguri if defined?(@taguri) and @taguri 65 66 tag = #{ tag.dump } 66 67 if self.class.yaml_tag_subclasses? and self.class != YAML::tagged_classes[tag] … … 73 74 end; 74 75 YAML::tag_class tag, self 76 ensure 77 $VERBOSE = verbose 75 78 end 76 79 # Transforms the subclass name into a name suitable for display -
trunk/ext/ruby/lib/yaml/types.rb
r230 r231 1 # -*- mode: ruby; ruby-indent-level: 4 -*- vim: sw=4 1 2 # 2 3 # Classes required by the full core typeset … … 6 7 module YAML 7 8 8 #9 # Default private type10 #11 class PrivateType9 # 10 # Default private type 11 # 12 class PrivateType 12 13 def self.tag_subclasses?; false; end 13 old_init = instance_method(:initialize) 14 define_method(:initialize) do |*args| 15 old_init.call(*args) 14 attr_accessor :type_id, :value 15 verbose, $VERBOSE = $VERBOSE, nil 16 def initialize( type, val ) 17 @type_id = type; @value = val 16 18 @value.taguri = "x-private:#{ @type_id }" 17 end18 def to_yaml( opts = {} )19 end 20 def to_yaml( opts = {} ) 19 21 @value.to_yaml( opts ) 20 end 21 end 22 end 23 ensure 24 $VERBOSE = verbose 25 end 22 26 23 27 # … … 26 30 class DomainType 27 31 def self.tag_subclasses?; false; end 28 attr_accessor :domain, :type_id, :value29 old_init = instance_method(:initialize)30 def ine_method(:initialize) do |*args|31 old_init.call(*args)32 attr_accessor :domain, :type_id, :value 33 verbose, $VERBOSE = $VERBOSE, nil 34 def initialize( domain, type, val ) 35 @domain = domain; @type_id = type; @value = val 32 36 @value.taguri = "tag:#{ @domain }:#{ @type_id }" 33 end34 def to_yaml( opts = {} )37 end 38 def to_yaml( opts = {} ) 35 39 @value.to_yaml( opts ) 36 end 37 end 40 end 41 ensure 42 $VERBOSE = verbose 43 end 38 44 39 45 # … … 42 48 class Object 43 49 def self.tag_subclasses?; false; end 44 def to_yaml( opts = {} )50 def to_yaml( opts = {} ) 45 51 YAML::quick_emit( object_id, opts ) do |out| 46 52 out.map( "tag:ruby.yaml.org,2002:object:#{ @class }", to_yaml_style ) do |map| … … 50 56 end 51 57 end 52 end53 end58 end 59 end 54 60 55 #56 # YAML Hash class to support comments and defaults57 #58 class SpecialHash < ::Hash59 attr_accessor :default61 # 62 # YAML Hash class to support comments and defaults 63 # 64 class SpecialHash < ::Hash 65 attr_accessor :default 60 66 def inspect 61 67 self.default.to_s 62 68 end 63 def to_s64 self.default.to_s65 end66 def update( h )67 if YAML::SpecialHash === h68 @default = h.default if h.default69 end70 super( h )71 end69 def to_s 70 self.default.to_s 71 end 72 def update( h ) 73 if YAML::SpecialHash === h 74 @default = h.default if h.default 75 end 76 super( h ) 77 end 72 78 def to_yaml( opts = {} ) 73 79 opts[:DefaultKey] = self.default 74 80 super( opts ) 75 81 end 76 end82 end 77 83 78 84 #