@@ -48,7 +48,7 @@ def array_class_proc(array_class, on_load)
48
48
end
49
49
end
50
50
51
- # TODO: exctract :create_additions support to another gem for version 3.0
51
+ # TODO: extract :create_additions support to another gem for version 3.0
52
52
def create_additions_proc ( opts )
53
53
if opts [ :symbolize_names ]
54
54
raise ArgumentError , "options :symbolize_names and :create_additions cannot be used in conjunction"
@@ -87,31 +87,32 @@ def create_additions_proc(opts)
87
87
opts
88
88
end
89
89
90
- GEM_ROOT = File . expand_path ( "../../../" , __FILE__ ) + "/"
91
90
def create_additions_warning
92
- message = "JSON.load implicit support for `create_additions: true` is deprecated " \
91
+ JSON . deprecation_warning "JSON.load implicit support for `create_additions: true` is deprecated " \
93
92
"and will be removed in 3.0, use JSON.unsafe_load or explicitly " \
94
93
"pass `create_additions: true`"
94
+ end
95
+ end
96
+ end
95
97
96
- uplevel = 4
97
- caller_locations ( uplevel , 10 ) . each do |frame |
98
- if frame . path . nil? || frame . path . start_with? ( GEM_ROOT ) || frame . path . end_with? ( "/truffle/cext_ruby.rb" , ".c" )
99
- uplevel += 1
100
- else
101
- break
102
- end
103
- end
104
-
105
- if RUBY_VERSION >= "3.0"
106
- warn ( message , uplevel : uplevel - 1 , category : :deprecated )
98
+ class << self
99
+ def deprecation_warning ( message , uplevel = 4 ) # :nodoc:
100
+ gem_root = File . expand_path ( "../../../" , __FILE__ ) + "/"
101
+ caller_locations ( uplevel , 10 ) . each do |frame |
102
+ if frame . path . nil? || frame . path . start_with? ( gem_root ) || frame . path . end_with? ( "/truffle/cext_ruby.rb" , ".c" )
103
+ uplevel += 1
107
104
else
108
- warn ( message , uplevel : uplevel - 1 )
105
+ break
109
106
end
110
107
end
108
+
109
+ if RUBY_VERSION >= "3.0"
110
+ warn ( message , uplevel : uplevel - 1 , category : :deprecated )
111
+ else
112
+ warn ( message , uplevel : uplevel - 1 )
113
+ end
111
114
end
112
- end
113
115
114
- class << self
115
116
# :call-seq:
116
117
# JSON[object] -> new_array or new_string
117
118
#
0 commit comments