mirror of
https://github.com/rubyjs/therubyrhino
synced 2023-03-27 23:21:34 -04:00
move warn out of deprecations + allow for (warn) silence!
This commit is contained in:
parent
05ece36c5d
commit
24eb2ab70c
2 changed files with 21 additions and 14 deletions
20
lib/rhino.rb
20
lib/rhino.rb
|
@ -16,7 +16,7 @@ module Rhino
|
|||
end
|
||||
end
|
||||
|
||||
@@implementation_version = nil
|
||||
@@implementation_version = nil # :nodoc
|
||||
# Helper to resolve what version of Rhino's .jar we're really using.
|
||||
def self.implementation_version
|
||||
@@implementation_version ||= begin
|
||||
|
@ -33,6 +33,24 @@ module Rhino
|
|||
end
|
||||
end
|
||||
|
||||
@@silence = java.lang.Boolean.getBoolean('rhino.silence') # :nodoc
|
||||
# Should we be silent - no warnings will be printed.
|
||||
def self.silence?; @@silence; end
|
||||
# Silence ! (... or I kill you)
|
||||
def self.silence!; @@silence = true; end
|
||||
|
||||
@@warnings = {} # :nodoc
|
||||
|
||||
def self.warn(msg) # :nodoc
|
||||
return if silence?
|
||||
# only print out deprecations once (even when non-silent)
|
||||
if msg[0, 13] == '[DEPRECATION]'
|
||||
return nil if @@warnings[msg]
|
||||
@@warnings[msg] = true
|
||||
end
|
||||
super # Kernel.warn
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
require 'rhino/version'
|
||||
|
|
|
@ -21,30 +21,19 @@ module Rhino
|
|||
end
|
||||
end
|
||||
|
||||
@@warnings = {}
|
||||
|
||||
def self.warn(msg) # :nodoc
|
||||
# only print out deprecation warnings once
|
||||
if msg[0, 13] == '[DEPRECATION]'
|
||||
return nil if @@warnings[msg]
|
||||
@@warnings[msg] = true
|
||||
end
|
||||
super # Kernel.warn
|
||||
end
|
||||
|
||||
module To # :nodoc
|
||||
|
||||
extend self
|
||||
|
||||
# #deprecated use {Rhino#to_ruby} instead
|
||||
def self.ruby(object)
|
||||
Rhino.warn "[DEPRECATION] `Rhino::To.ruby` is deprecated, use `Rhino.to_ruby` instead."
|
||||
warn "[DEPRECATION] `Rhino::To.ruby` is deprecated, use `Rhino.to_ruby` instead."
|
||||
to_ruby(object)
|
||||
end
|
||||
|
||||
# #deprecated use {Rhino#to_javascript} instead
|
||||
def self.javascript(object, scope = nil)
|
||||
Rhino.warn "[DEPRECATION] `Rhino::To.javascript` is deprecated, use `Rhino.to_javascript` instead."
|
||||
warn "[DEPRECATION] `Rhino::To.javascript` is deprecated, use `Rhino.to_javascript` instead."
|
||||
to_javascript(object, scope)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue