Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Add deprecated runtime flag
  • Loading branch information
josh committed May 20, 2012
1 parent bfe14c2 commit 304a225
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -7,7 +7,7 @@ require "execjs/runtimes"

tests = namespace :test do |tests|
ExecJS::Runtimes.names.each do |name|
next if name.to_s == "Disabled"
next if ExecJS::Runtimes.const_get(name).deprecated?

task(name.downcase) do
ENV["EXECJS_RUNTIME"] = name.to_s
Expand Down
4 changes: 4 additions & 0 deletions lib/execjs/disabled_runtime.rb
Expand Up @@ -18,6 +18,10 @@ def compile(source)
raise Error, "ExecJS disabled"
end

def deprecated?
true
end

def available?
true
end
Expand Down
5 changes: 5 additions & 0 deletions lib/execjs/external_runtime.rb
Expand Up @@ -95,6 +95,7 @@ def initialize(options)
@test_args = options[:test_args]
@test_match = options[:test_match]
@encoding = options[:encoding]
@deprecated = !!options[:deprecated]
@binary = nil
end

Expand All @@ -103,6 +104,10 @@ def available?
binary ? true : false
end

def deprecated?
@deprecated
end

private
def binary
@binary ||= locate_binary
Expand Down
4 changes: 4 additions & 0 deletions lib/execjs/runtime.rb
Expand Up @@ -44,6 +44,10 @@ def compile(source)
context_class.new(self, source)
end

def deprecated?
false
end

def available?
raise NotImplementedError
end
Expand Down
2 changes: 1 addition & 1 deletion lib/execjs/runtimes.rb
Expand Up @@ -52,7 +52,7 @@ def self.autodetect
end

def self.best_available
runtimes.find(&:available?)
runtimes.reject(&:deprecated?).find(&:available?)
end

def self.from_environment
Expand Down

0 comments on commit 304a225

Please sign in to comment.