3
# Hack to handle syck's DefaultKey bug
5
# This file is always loaded AFTER either syck or psych are already
6
# loaded. It then looks at what constants are available and creates
7
# a consistent view on all rubys.
9
# All this is so that there is always a YAML::Syck::DefaultKey
10
# class no matter if the full yaml library has loaded or not.
14
# In newer 1.9.2, there is a Syck toplevel constant instead of it
15
# being underneith YAML. If so, reference it back under YAML as
18
# for tests that change YAML::ENGINE
19
# 1.8 does not support the second argument to const_defined?
20
remove_const :Syck rescue nil
24
# JRuby's "Syck" is called "Yecht"
25
elsif defined? YAML::Yecht
28
# Otherwise, if there is no YAML::Syck, then we've got just psych
29
# loaded, so lets define a stub for DefaultKey.
30
elsif !defined? YAML::Syck
37
# Now that we've got something that is always here, define #to_s
38
# so when code tries to use this, it at least just shows up like it
42
remove_method :to_s rescue nil
51
# Sometime in the 1.9 dev cycle, the Syck constant was moved from under YAML
52
# to be a toplevel constant. So gemspecs created under these versions of Syck
53
# will have references to Syck::DefaultKey.
55
# So we need to be sure that we reference Syck at the toplevel too so that
56
# we can always load these kind of gemspecs.
62
# Now that we've got Syck setup in all the right places, store
63
# a reference to the DefaultKey class inside Gem. We do this so that
64
# if later on YAML, etc are redefined, we've still got a consistent
65
# place to find the DefaultKey class for comparison.
68
# for tests that change YAML::ENGINE
69
remove_const :SyckDefaultKey if const_defined? :SyckDefaultKey
71
SyckDefaultKey = YAML::Syck::DefaultKey
77
# Hack to handle syck's DefaultKey bug
79
# This file is always loaded AFTER either syck or psych are already
80
# loaded. It then looks at what constants are available and creates
81
# a consistent view on all rubys.
83
# All this is so that there is always a YAML::Syck::DefaultKey
84
# class no matter if the full yaml library has loaded or not.
88
# In newer 1.9.2, there is a Syck toplevel constant instead of it
89
# being underneith YAML. If so, reference it back under YAML as
92
# for tests that change YAML::ENGINE
93
remove_const :Syck if const_defined? :Syck, false
97
# JRuby's "Syck" is called "Yecht"
98
elsif defined? YAML::Yecht
101
# Otherwise, if there is no YAML::Syck, then we've got just psych
102
# loaded, so lets define a stub for DefaultKey.
103
elsif !defined? YAML::Syck
110
# Now that we've got something that is always here, define #to_s
111
# so when code tries to use this, it at least just shows up like it
122
# Sometime in the 1.9 dev cycle, the Syck constant was moved from under YAML
123
# to be a toplevel constant. So gemspecs created under these versions of Syck
124
# will have references to Syck::DefaultKey.
126
# So we need to be sure that we reference Syck at the toplevel too so that
127
# we can always load these kind of gemspecs.
133
# Now that we've got Syck setup in all the right places, store
134
# a reference to the DefaultKey class inside Gem. We do this so that
135
# if later on YAML, etc are redefined, we've still got a consistent
136
# place to find the DefaultKey class for comparison.
139
# for tests that change YAML::ENGINE
140
remove_const :SyckDefaultKey if const_defined? :SyckDefaultKey
142
SyckDefaultKey = YAML::Syck::DefaultKey