@@ -48,7 +48,7 @@ def array_class_proc(array_class, on_load)
4848 end
4949 end
5050
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
5252 def create_additions_proc ( opts )
5353 if opts [ :symbolize_names ]
5454 raise ArgumentError , "options :symbolize_names and :create_additions cannot be used in conjunction"
@@ -87,31 +87,32 @@ def create_additions_proc(opts)
8787 opts
8888 end
8989
90- GEM_ROOT = File . expand_path ( "../../../" , __FILE__ ) + "/"
9190 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 " \
9392 "and will be removed in 3.0, use JSON.unsafe_load or explicitly " \
9493 "pass `create_additions: true`"
94+ end
95+ end
96+ end
9597
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
107104 else
108- warn ( message , uplevel : uplevel - 1 )
105+ break
109106 end
110107 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
111114 end
112- end
113115
114- class << self
115116 # :call-seq:
116117 # JSON[object] -> new_array or new_string
117118 #
0 commit comments