From 2f9258e4fe77991c526f7a65c92bcf792eef8338 Mon Sep 17 00:00:00 2001 From: Edward Anderson Date: Tue, 22 Nov 2016 23:39:00 -0500 Subject: [PATCH] Put source encoding comment as line for (j)ruby 1.9 compatibility (#3255) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In jruby 1.7.22 (1.9.3p551 compatibility mode), UTF-8 encoding is not properly detected, because the encoding comment is not on the first line as required in ruby 1.9. The frozen_string_literal magic comment did not come into existence until ruby 2.3, and ruby 1.9 does not look past the first line for magic comments. This results encoding-related syntax errors. Examples: SyntaxError: /home/nilbus/ws/rental_express/ROOT/rails/vendor/bundle/jruby/1.9/gems/sidekiq-4.2.6/lib/sidekiq.rb:52: Invalid char `\235' ('') in expression def self.❨╯°□°❩╯︵┻━┻ ^ SyntaxError: /home/nilbus/ws/rental_express/ROOT/rails/vendor/bundle/jruby/1.9/gems/sidekiq-4.2.6/lib/sidekiq/api.rb:269: Invalid char `\237' ('Ÿ') in expression alias_method :💣, :clear ^ This patch should restore compatibility with ruby 1.9 and greater. --- lib/sidekiq.rb | 2 +- lib/sidekiq/api.rb | 2 +- lib/sidekiq/cli.rb | 2 +- lib/sidekiq/launcher.rb | 2 +- lib/sidekiq/manager.rb | 2 +- test/test_retry.rb | 2 +- test/test_sidekiq.rb | 2 +- test/test_web.rb | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/sidekiq.rb b/lib/sidekiq.rb index cf163451..ffcbb477 100644 --- a/lib/sidekiq.rb +++ b/lib/sidekiq.rb @@ -1,5 +1,5 @@ -# frozen_string_literal: true # encoding: utf-8 +# frozen_string_literal: true require 'sidekiq/version' fail "Sidekiq #{Sidekiq::VERSION} does not support Ruby versions below 2.0.0." if RUBY_PLATFORM != 'java' && RUBY_VERSION < '2.0.0' diff --git a/lib/sidekiq/api.rb b/lib/sidekiq/api.rb index 27a53034..347522e8 100644 --- a/lib/sidekiq/api.rb +++ b/lib/sidekiq/api.rb @@ -1,5 +1,5 @@ -# frozen_string_literal: true # encoding: utf-8 +# frozen_string_literal: true require 'sidekiq' module Sidekiq diff --git a/lib/sidekiq/cli.rb b/lib/sidekiq/cli.rb index cdd03666..c1437ef2 100644 --- a/lib/sidekiq/cli.rb +++ b/lib/sidekiq/cli.rb @@ -1,5 +1,5 @@ -# frozen_string_literal: true # encoding: utf-8 +# frozen_string_literal: true $stdout.sync = true require 'yaml' diff --git a/lib/sidekiq/launcher.rb b/lib/sidekiq/launcher.rb index 46154a37..e086846c 100644 --- a/lib/sidekiq/launcher.rb +++ b/lib/sidekiq/launcher.rb @@ -1,5 +1,5 @@ -# frozen_string_literal: true # encoding: utf-8 +# frozen_string_literal: true require 'sidekiq/manager' require 'sidekiq/fetch' require 'sidekiq/scheduled' diff --git a/lib/sidekiq/manager.rb b/lib/sidekiq/manager.rb index b033e40d..75d10e25 100644 --- a/lib/sidekiq/manager.rb +++ b/lib/sidekiq/manager.rb @@ -1,5 +1,5 @@ -# frozen_string_literal: true # encoding: utf-8 +# frozen_string_literal: true require 'sidekiq/util' require 'sidekiq/processor' require 'sidekiq/fetch' diff --git a/test/test_retry.rb b/test/test_retry.rb index 92defcc8..181f271c 100644 --- a/test/test_retry.rb +++ b/test/test_retry.rb @@ -1,5 +1,5 @@ -# frozen_string_literal: true # encoding: utf-8 +# frozen_string_literal: true require_relative 'helper' require 'sidekiq/scheduled' require 'sidekiq/middleware/server/retry_jobs' diff --git a/test/test_sidekiq.rb b/test/test_sidekiq.rb index f0df7240..480f83db 100644 --- a/test/test_sidekiq.rb +++ b/test/test_sidekiq.rb @@ -1,5 +1,5 @@ -# frozen_string_literal: true # encoding: utf-8 +# frozen_string_literal: true require_relative 'helper' class TestSidekiq < Sidekiq::Test diff --git a/test/test_web.rb b/test/test_web.rb index a54b9b0d..4c6e772c 100644 --- a/test/test_web.rb +++ b/test/test_web.rb @@ -1,5 +1,5 @@ -# frozen_string_literal: true # encoding: utf-8 +# frozen_string_literal: true require_relative 'helper' require 'sidekiq/web' require 'rack/test'