From 304a225058d64614de44c086ed424d4d772d9616 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 20 May 2012 14:25:13 -0500 Subject: [PATCH] Add deprecated runtime flag --- Rakefile | 2 +- lib/execjs/disabled_runtime.rb | 4 ++++ lib/execjs/external_runtime.rb | 5 +++++ lib/execjs/runtime.rb | 4 ++++ lib/execjs/runtimes.rb | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 34e997b..b80407d 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/lib/execjs/disabled_runtime.rb b/lib/execjs/disabled_runtime.rb index 27a33e2..dc67e82 100644 --- a/lib/execjs/disabled_runtime.rb +++ b/lib/execjs/disabled_runtime.rb @@ -18,6 +18,10 @@ module ExecJS raise Error, "ExecJS disabled" end + def deprecated? + true + end + def available? true end diff --git a/lib/execjs/external_runtime.rb b/lib/execjs/external_runtime.rb index 54b4e22..4877975 100644 --- a/lib/execjs/external_runtime.rb +++ b/lib/execjs/external_runtime.rb @@ -95,6 +95,7 @@ module ExecJS @test_args = options[:test_args] @test_match = options[:test_match] @encoding = options[:encoding] + @deprecated = !!options[:deprecated] @binary = nil end @@ -103,6 +104,10 @@ module ExecJS binary ? true : false end + def deprecated? + @deprecated + end + private def binary @binary ||= locate_binary diff --git a/lib/execjs/runtime.rb b/lib/execjs/runtime.rb index 92603f4..f64b67f 100644 --- a/lib/execjs/runtime.rb +++ b/lib/execjs/runtime.rb @@ -44,6 +44,10 @@ module ExecJS context_class.new(self, source) end + def deprecated? + false + end + def available? raise NotImplementedError end diff --git a/lib/execjs/runtimes.rb b/lib/execjs/runtimes.rb index cb4d837..467c226 100644 --- a/lib/execjs/runtimes.rb +++ b/lib/execjs/runtimes.rb @@ -52,7 +52,7 @@ module ExecJS end def self.best_available - runtimes.find(&:available?) + runtimes.reject(&:deprecated?).find(&:available?) end def self.from_environment