module Rhino

Constants

RubyConstructor
RubyFunction
RubyObject
VERSION

Public Class Methods

const_missing(name) click to toggle source
Calls superclass method
# File lib/rhino/deprecations.rb, line 6
def self.const_missing(name) # :nodoc
  case name.to_s
  when 'J' then
    warn "[DEPRECATION] `Rhino::J` is deprecated, use `Rhino::JS` instead."
    return JS
  when 'JavascriptError' then
    warn "[DEPRECATION] `Rhino::JavascriptError` is deprecated, use `Rhino::JSError` instead."
    return JSError
  when 'NativeObject' then
    warn "[DEPRECATION] `Rhino::NativeObject` is no longer used, returning a stub."
    return @@stub_class
  when 'NativeFunction' then
    warn "[DEPRECATION] `Rhino::NativeFunction` is no longer used, returning a stub."
    return @@stub_class
  else super
  end
end
implementation_version() click to toggle source

Helper to resolve what version of Rhino's .jar we're really using.

# File lib/rhino.rb, line 21
def self.implementation_version
  @@implementation_version ||= begin
    urls = JS::Kit.java_class.to_java.getClassLoader.
      getResources('META-INF/MANIFEST.MF').to_a
    rhino_jar_urls = urls.select { |url| url.toString.index(JAR_PATH) }
    if rhino_jar_urls.empty?
      raise "could not find #{JAR_PATH} manifest among: #{urls.map(&:toString).join(', ')}"
    elsif rhino_jar_urls.size > 1
      raise "could not find #{JAR_PATH} manifest among: #{urls.map(&:toString).join(', ')}"
    end
    manifest = java.util.jar.Manifest.new rhino_jar_urls.first.openStream
    manifest.getMainAttributes.getValue 'Implementation-Version'
  end
end
silence!() click to toggle source

Silence ! (… or I kill you)

# File lib/rhino.rb, line 40
def self.silence!; @@silence = true; end
silence?() click to toggle source

Should we be silent - no warnings will be printed.

# File lib/rhino.rb, line 38
def self.silence?; @@silence; end
warn(msg) click to toggle source
Calls superclass method
# File lib/rhino.rb, line 44
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