Hello community, here is the log from the commit of package rubygem-execjs for openSUSE:Factory checked in at 2014-10-18 09:09:12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-execjs (Old) and /work/SRC/openSUSE:Factory/.rubygem-execjs.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-execjs" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-execjs/rubygem-execjs.changes 2014-10-14 07:11:24.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-execjs.new/rubygem-execjs.changes 2014-10-18 09:09:27.000000000 +0200 @@ -1,0 +2,5 @@ +Wed Oct 15 09:18:58 UTC 2014 - [email protected] + +- updated to version 2.2.2, no changelog + +------------------------------------------------------------------- Old: ---- execjs-2.0.2.gem New: ---- execjs-2.2.2.gem gem2rpm.yml ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-execjs.spec ++++++ --- /var/tmp/diff_new_pack.9jQqta/_old 2014-10-18 09:09:28.000000000 +0200 +++ /var/tmp/diff_new_pack.9jQqta/_new 2014-10-18 09:09:28.000000000 +0200 @@ -17,40 +17,30 @@ Name: rubygem-execjs -Version: 2.0.2 +Version: 2.2.2 Release: 0 %define mod_name execjs %define mod_full_name %{mod_name}-%{version} - BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: %{rubygem gem2rpm} +BuildRequires: %{ruby} BuildRequires: ruby-macros >= 5 Url: https://github.com/sstephenson/execjs Source: http://rubygems.org/gems/%{mod_full_name}.gem +Source1: gem2rpm.yml Summary: Run JavaScript code from Ruby License: MIT Group: Development/Languages/Ruby -# MANUAL We need at least one JavaScript engine, use Mozilla SpiderMonkey: -Requires: nodejs %description ExecJS lets you run JavaScript code from Ruby. -%package doc -Summary: RDoc documentation for %{mod_name} -Group: Development/Languages/Ruby -Requires: %{name} = %{version} - -%description doc -Documentation generated at gem installation time. -Usually in RDoc and RI formats. - %prep %build %install %gem_install \ - --symlink-binaries \ --doc-files="LICENSE README.md" \ -f ++++++ execjs-2.0.2.gem -> execjs-2.2.2.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/LICENSE new/LICENSE --- old/LICENSE 1970-01-01 01:00:00.000000000 +0100 +++ new/LICENSE 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +1,5 @@ -Copyright (c) 2013 Sam Stephenson -Copyright (c) 2013 Josh Peek +Copyright (c) 2014 Sam Stephenson +Copyright (c) 2014 Josh Peek Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/README.md 1970-01-01 01:00:00.000000000 +0100 @@ -17,26 +17,44 @@ A short example: - require "execjs" - ExecJS.eval "'red yellow blue'.split(' ')" - # => ["red", "yellow", "blue"] +``` ruby +require "execjs" +ExecJS.eval "'red yellow blue'.split(' ')" +# => ["red", "yellow", "blue"] +``` A longer example, demonstrating how to invoke the CoffeeScript compiler: - require "execjs" - require "open-uri" - source = open("http://jashkenas.github.com/coffee-script/extras/coffee-script.js").read - - context = ExecJS.compile(source) - context.call("CoffeeScript.compile", "square = (x) -> x * x", :bare => true) - # => "var square;\nsquare = function(x) {\n return x * x;\n};" +``` ruby +require "execjs" +require "open-uri" +source = open("http://coffeescript.org/extras/coffee-script.js").read + +context = ExecJS.compile(source) +context.call("CoffeeScript.compile", "square = (x) -> x * x", bare: true) +# => "var square;\nsquare = function(x) {\n return x * x;\n};" +``` # Installation - $ gem install execjs +``` +$ gem install execjs +``` + + +# FAQ + +**Why can't I use CommonJS `require()` inside ExecJS?** + +ExecJS provides a lowest common denominator interface to any JavaScript runtime. +Use ExecJS when it doesn't matter which JavaScript interpreter your code runs +in. If you want to access the Node API, you should check another library like +[commonjs.rb](https://github.com/cowboyd/commonjs.rb) designed to provide a +consistent interface. + # License -Copyright (c) 2013 Sam Stephenson and Josh Peek. +Copyright (c) 2014 Sam Stephenson and Josh Peek. Released under the MIT license. See `LICENSE` for details. Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/execjs/encoding.rb new/lib/execjs/encoding.rb --- old/lib/execjs/encoding.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/execjs/encoding.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,32 +1,25 @@ module ExecJS # Encodes strings as UTF-8 module Encoding - if "".respond_to?(:encode) - if RUBY_ENGINE == 'jruby' || RUBY_ENGINE == 'rbx' - # workaround for jruby bug http://jira.codehaus.org/browse/JRUBY-6588 - # workaround for rbx bug https://github.com/rubinius/rubinius/issues/1729 - def encode(string) - if string.encoding.name == 'ASCII-8BIT' - data = string.dup - data.force_encoding('UTF-8') + if RUBY_ENGINE == 'jruby' || RUBY_ENGINE == 'rbx' + # workaround for jruby bug http://jira.codehaus.org/browse/JRUBY-6588 + # workaround for rbx bug https://github.com/rubinius/rubinius/issues/1729 + def encode(string) + if string.encoding.name == 'ASCII-8BIT' + data = string.dup + data.force_encoding('UTF-8') - unless data.valid_encoding? - raise ::Encoding::UndefinedConversionError, "Could not encode ASCII-8BIT data #{string.dump} as UTF-8" - end - else - data = string.encode('UTF-8') + unless data.valid_encoding? + raise ::Encoding::UndefinedConversionError, "Could not encode ASCII-8BIT data #{string.dump} as UTF-8" end - data - end - else - def encode(string) - string.encode('UTF-8') + else + data = string.encode('UTF-8') end + data end else - # Define no-op on 1.8 def encode(string) - string + string.encode('UTF-8') end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/execjs/external_runtime.rb new/lib/execjs/external_runtime.rb --- old/lib/execjs/external_runtime.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/execjs/external_runtime.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +1,4 @@ -require "shellwords" -require "tempfile" +require "tmpdir" require "execjs/runtime" module ExecJS @@ -16,16 +15,20 @@ source = encode(source) if /\S/ =~ source - exec("return eval(#{::JSON.generate("(#{source})", :quirks_mode => true)})") + exec("return eval(#{::JSON.generate("(#{source})", quirks_mode: true)})") end end def exec(source, options = {}) source = encode(source) source = "#{@source}\n#{source}" if @source + source = @runtime.compile_source(source) - compile_to_tempfile(source) do |file| - extract_result(@runtime.send(:exec_runtime, file.path)) + tmpfile = write_to_tempfile(source) + begin + extract_result(@runtime.exec_runtime(tmpfile.path)) + ensure + File.unlink(tmpfile) end end @@ -34,32 +37,25 @@ end protected - def compile_to_tempfile(source) - tempfile = Tempfile.open(['execjs', '.js']) - tempfile.write compile(source) - tempfile.close - yield tempfile - ensure - tempfile.close! + # See Tempfile.create on Ruby 2.1 + def create_tempfile(basename) + tmpfile = nil + Dir::Tmpname.create(basename) do |tmpname| + mode = File::WRONLY | File::CREAT | File::EXCL + tmpfile = File.open(tmpname, mode, 0600) + end + tmpfile end - def compile(source) - @runtime.send(:runner_source).dup.tap do |output| - output.sub!('#{source}') do - source - end - output.sub!('#{encoded_source}') do - encoded_source = encode_unicode_codepoints(source) - ::JSON.generate("(function(){ #{encoded_source} })()", :quirks_mode => true) - end - output.sub!('#{json2_source}') do - IO.read(ExecJS.root + "/support/json2.js") - end - end + def write_to_tempfile(contents) + tmpfile = create_tempfile(['execjs', 'js']) + tmpfile.write(contents) + tmpfile.close + tmpfile end def extract_result(output) - status, value = output.empty? ? [] : ::JSON.parse(output, :create_additions => false) + status, value = output.empty? ? [] : ::JSON.parse(output, create_additions: false) if status == "ok" value elsif value =~ /SyntaxError:/ @@ -68,22 +64,6 @@ raise ProgramError, value end end - - if "".respond_to?(:codepoints) - def encode_unicode_codepoints(str) - str.gsub(/[\u0080-\uffff]/) do |ch| - "\\u%04x" % ch.codepoints.to_a - end - end - else - def encode_unicode_codepoints(str) - str.gsub(/([\xC0-\xDF][\x80-\xBF]| - [\xE0-\xEF][\x80-\xBF]{2}| - [\xF0-\xF7][\x80-\xBF]{3})+/nx) do |ch| - "\\u%04x" % ch.unpack("U*") - end - end - end end attr_reader :name @@ -92,11 +72,17 @@ @name = options[:name] @command = options[:command] @runner_path = options[:runner_path] - @test_args = options[:test_args] - @test_match = options[:test_match] @encoding = options[:encoding] @deprecated = !!options[:deprecated] @binary = nil + + @popen_options = {} + @popen_options[:external_encoding] = @encoding if @encoding + @popen_options[:internal_encoding] = ::Encoding.default_internal || 'UTF-8' + + if @runner_path + instance_eval generate_compile_method(@runner_path) + end end def available? @@ -110,7 +96,7 @@ private def binary - @binary ||= locate_binary + @binary ||= which(@command) end def locate_executable(cmd) @@ -130,65 +116,49 @@ end protected - def runner_source - @runner_source ||= IO.read(@runner_path) - end - - def exec_runtime(filename) - output = sh("#{shell_escape(*(binary.split(' ') << filename))} 2>&1") - if $?.success? - output - else - raise RuntimeError, output + def generate_compile_method(path) + <<-RUBY + def compile_source(source) + <<-RUNNER + #{IO.read(path)} + RUNNER end + RUBY end - def locate_binary - if binary = which(@command) - if @test_args - output = `#{shell_escape(binary, @test_args)} 2>&1` - binary if output.match(@test_match) - else - binary - end - end + def json2_source + @json2_source ||= IO.read(ExecJS.root + "/support/json2.js") end - def which(command) - Array(command).find do |name| - name, args = name.split(/\s+/, 2) - path = locate_executable(name) - - next unless path - - args ? "#{path} #{args}" : path - end + def encode_source(source) + encoded_source = encode_unicode_codepoints(source) + ::JSON.generate("(function(){ #{encoded_source} })()", quirks_mode: true) end - if "".respond_to?(:force_encoding) - def sh(command) - output, options = nil, {} - options[:external_encoding] = @encoding if @encoding - options[:internal_encoding] = ::Encoding.default_internal || 'UTF-8' - IO.popen(command, options) { |f| output = f.read } - output + def encode_unicode_codepoints(str) + str.gsub(/[\u0080-\uffff]/) do |ch| + "\\u%04x" % ch.codepoints.to_a end - else - require "iconv" + end - def sh(command) - output = nil - IO.popen(command) { |f| output = f.read } + if ExecJS.windows? + def exec_runtime(filename) + path = Dir::Tmpname.create(['execjs', 'json']) {} + begin + command = binary.split(" ") << filename + `#{shell_escape(*command)} 2>&1 > #{path}` + output = File.open(path, 'rb', @popen_options) { |f| f.read } + ensure + File.unlink(path) if path + end - if @encoding - Iconv.new('UTF-8', @encoding).iconv(output) - else + if $?.success? output + else + raise RuntimeError, output end end - end - if ExecJS.windows? def shell_escape(*args) # see http://technet.microsoft.com/en-us/library/cc723564.aspx#XSLTsection123121120120 args.map { |arg| @@ -197,8 +167,29 @@ }.join(" ") end else - def shell_escape(*args) - Shellwords.join(args) + def exec_runtime(filename) + io = IO.popen(binary.split(' ') << filename, @popen_options.merge({err: [:child, :out]})) + output = io.read + io.close + + if $?.success? + output + else + raise RuntimeError, output + end + end + end + # Internally exposed for Context. + public :exec_runtime + + def which(command) + Array(command).find do |name| + name, args = name.split(/\s+/, 2) + path = locate_executable(name) + + next unless path + + args ? "#{path} #{args}" : path end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/execjs/johnson_runtime.rb new/lib/execjs/johnson_runtime.rb --- old/lib/execjs/johnson_runtime.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/execjs/johnson_runtime.rb 1970-01-01 01:00:00.000000000 +0100 @@ -47,9 +47,7 @@ when function?(value) nil when string?(value) - value.respond_to?(:force_encoding) ? - value.force_encoding('UTF-8') : - value + value.force_encoding('UTF-8') when array?(value) value.map { |v| unbox(v) } when object?(value) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/execjs/ruby_racer_runtime.rb new/lib/execjs/ruby_racer_runtime.rb --- old/lib/execjs/ruby_racer_runtime.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/execjs/ruby_racer_runtime.rb 1970-01-01 01:00:00.000000000 +0100 @@ -64,9 +64,7 @@ vs end when String - value.respond_to?(:force_encoding) ? - value.force_encoding('UTF-8') : - value + value.force_encoding('UTF-8') else value end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/execjs/runtimes.rb new/lib/execjs/runtimes.rb --- old/lib/execjs/runtimes.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/execjs/runtimes.rb 1970-01-01 01:00:00.000000000 +0100 @@ -19,30 +19,30 @@ Mustang = MustangRuntime.new Node = ExternalRuntime.new( - :name => "Node.js (V8)", - :command => ["nodejs", "node"], - :runner_path => ExecJS.root + "/support/node_runner.js", - :encoding => 'UTF-8' + name: "Node.js (V8)", + command: ["nodejs", "node"], + runner_path: ExecJS.root + "/support/node_runner.js", + encoding: 'UTF-8' ) JavaScriptCore = ExternalRuntime.new( - :name => "JavaScriptCore", - :command => "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc", - :runner_path => ExecJS.root + "/support/jsc_runner.js" + name: "JavaScriptCore", + command: "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc", + runner_path: ExecJS.root + "/support/jsc_runner.js" ) SpiderMonkey = Spidermonkey = ExternalRuntime.new( - :name => "SpiderMonkey", - :command => "js", - :runner_path => ExecJS.root + "/support/spidermonkey_runner.js", - :deprecated => true + name: "SpiderMonkey", + command: "js", + runner_path: ExecJS.root + "/support/spidermonkey_runner.js", + deprecated: true ) JScript = ExternalRuntime.new( - :name => "JScript", - :command => "cscript //E:jscript //Nologo //U", - :runner_path => ExecJS.root + "/support/jscript_runner.js", - :encoding => 'UTF-16LE' # CScript with //U returns UTF-16LE + name: "JScript", + command: "cscript //E:jscript //Nologo //U", + runner_path: ExecJS.root + "/support/jscript_runner.js", + encoding: 'UTF-16LE' # CScript with //U returns UTF-16LE ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/execjs/support/jsc_runner.js new/lib/execjs/support/jsc_runner.js --- old/lib/execjs/support/jsc_runner.js 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/execjs/support/jsc_runner.js 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +1,5 @@ (function(program, execJS) { execJS(program) })(function() { - return eval(#{encoded_source}); + return eval(#{encode_source(source)}); }, function(program) { var output; try { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/execjs/support/jscript_runner.js new/lib/execjs/support/jscript_runner.js --- old/lib/execjs/support/jscript_runner.js 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/execjs/support/jscript_runner.js 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +1,5 @@ (function(program, execJS) { execJS(program) })(function() { - return eval(#{encoded_source}); + return eval(#{encode_source(source)}); }, function(program) { #{json2_source} var output, print = function(string) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/execjs/version.rb new/lib/execjs/version.rb --- old/lib/execjs/version.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/execjs/version.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +1,3 @@ module ExecJS - VERSION = "2.0.2" + VERSION = "2.2.2" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 1970-01-01 01:00:00.000000000 +0100 +++ new/metadata 1970-01-01 01:00:00.000000000 +0100 @@ -1,7 +1,8 @@ --- !ruby/object:Gem::Specification name: execjs version: !ruby/object:Gem::Version - version: 2.0.2 + version: 2.2.2 + prerelease: platform: ruby authors: - Sam Stephenson @@ -9,20 +10,22 @@ autorequire: bindir: bin cert_chain: [] -date: 2013-09-27 00:00:00.000000000 Z +date: 2014-10-14 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement + none: false requirements: - - - '>=' + - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement + none: false requirements: - - - '>=' + - - ! '>=' - !ruby/object:Gem::Version version: '0' description: ExecJS lets you run JavaScript code from Ruby. @@ -55,25 +58,26 @@ homepage: https://github.com/sstephenson/execjs licenses: - MIT -metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement + none: false requirements: - - - '>=' + - - ! '>=' - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement + none: false requirements: - - - '>=' + - - ! '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.0.3 +rubygems_version: 1.8.23 signing_key: -specification_version: 4 +specification_version: 3 summary: Run JavaScript code from Ruby test_files: [] ++++++ gem2rpm.yml ++++++ # --- # ## used by gem2rpm # :summary: this is a custom summary # ## used by gem2rpm # :description: |- # this is a custom description # # it can be multiline # ## used by gem2rpm # :license: MIT or Ruby # ## used by gem2rpm and gem_packages # :version_suffix: -x_y # ## used by gem2rpm and gem_packages # :disable_docs: true # ## used by gem2rpm # :disable_automatic_rdoc_dep: true # ## used by gem2rpm # :preamble: |- # BuildRequires: foobar # Requires: foobar # ## used by gem2rpm # :patches: # foo.patch: -p1 # bar.patch: # ## used by gem2rpm :sources: # - foo.desktop # - bar.desktop # :gem_install_args: '....' # ## used by gem2rpm # :pre_install: |- # %if 0%{?use_system_libev} # export USE_VENDORED_LIBEV="no" # %endif # ## used by gem2rpm # :post_install: |- # # delete custom files here or do other fancy stuff # install -D -m 0644 %{S:1} %{buildroot}%{_bindir}/gem2rpm-opensuse # ## used by gem2rpm # :testsuite_command: |- # (pushd %{buildroot}%{gem_base}/gems/%{mod_full_name} && rake test) # ## used by gem2rpm # :filelist: |- # /usr/bin/gem2rpm-opensuse # ## used by gem2rpm # :scripts: # :post: |- # /bin/echo foo # ## used by gem_packages # MANUAL We need at least one JavaScript engine, use Mozilla SpiderMonkey: :main: :preamble: |- Requires: nodejs -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
