diff options
author | Xavier Noria <fxn@hashref.com> | 2016-08-06 18:40:07 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-08-06 18:40:07 +0200 |
commit | 93c9534c9871d4adad4bc33b5edc355672b59c61 (patch) | |
tree | c9d8782bfb88207cd5857eb903b5f169fe593fea /activejob/lib | |
parent | 4c208254573c3428d82bd8744860bd86e1c78acb (diff) | |
download | rails-93c9534c9871d4adad4bc33b5edc355672b59c61.tar.gz rails-93c9534c9871d4adad4bc33b5edc355672b59c61.tar.bz2 rails-93c9534c9871d4adad4bc33b5edc355672b59c61.zip |
applies new string literal convention in activejob/lib
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
Diffstat (limited to 'activejob/lib')
28 files changed, 99 insertions, 99 deletions
diff --git a/activejob/lib/active_job.rb b/activejob/lib/active_job.rb index 4b9065cf50..20ca7085c6 100644 --- a/activejob/lib/active_job.rb +++ b/activejob/lib/active_job.rb @@ -21,10 +21,10 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ -require 'active_support' -require 'active_support/rails' -require 'active_job/version' -require 'global_id' +require "active_support" +require "active_support/rails" +require "active_job/version" +require "global_id" module ActiveJob extend ActiveSupport::Autoload diff --git a/activejob/lib/active_job/arguments.rb b/activejob/lib/active_job/arguments.rb index a5c749e5e7..d94b015014 100644 --- a/activejob/lib/active_job/arguments.rb +++ b/activejob/lib/active_job/arguments.rb @@ -1,4 +1,4 @@ -require 'active_support/core_ext/hash' +require "active_support/core_ext/hash" module ActiveJob # Raised when an exception is raised during job arguments deserialization. @@ -55,11 +55,11 @@ module ActiveJob private # :nodoc: - GLOBALID_KEY = '_aj_globalid'.freeze + GLOBALID_KEY = "_aj_globalid".freeze # :nodoc: - SYMBOL_KEYS_KEY = '_aj_symbol_keys'.freeze + SYMBOL_KEYS_KEY = "_aj_symbol_keys".freeze # :nodoc: - WITH_INDIFFERENT_ACCESS_KEY = '_aj_hash_with_indifferent_access'.freeze + WITH_INDIFFERENT_ACCESS_KEY = "_aj_hash_with_indifferent_access".freeze private_constant :GLOBALID_KEY, :SYMBOL_KEYS_KEY, :WITH_INDIFFERENT_ACCESS_KEY def serialize_argument(argument) diff --git a/activejob/lib/active_job/base.rb b/activejob/lib/active_job/base.rb index 94a1faba3f..18e8641e50 100644 --- a/activejob/lib/active_job/base.rb +++ b/activejob/lib/active_job/base.rb @@ -1,13 +1,13 @@ -require 'active_job/core' -require 'active_job/queue_adapter' -require 'active_job/queue_name' -require 'active_job/queue_priority' -require 'active_job/enqueuing' -require 'active_job/execution' -require 'active_job/callbacks' -require 'active_job/exceptions' -require 'active_job/logging' -require 'active_job/translation' +require "active_job/core" +require "active_job/queue_adapter" +require "active_job/queue_name" +require "active_job/queue_priority" +require "active_job/enqueuing" +require "active_job/execution" +require "active_job/callbacks" +require "active_job/exceptions" +require "active_job/logging" +require "active_job/translation" module ActiveJob #:nodoc: # = Active Job diff --git a/activejob/lib/active_job/callbacks.rb b/activejob/lib/active_job/callbacks.rb index b206522a60..d5b17de8b5 100644 --- a/activejob/lib/active_job/callbacks.rb +++ b/activejob/lib/active_job/callbacks.rb @@ -1,4 +1,4 @@ -require 'active_support/callbacks' +require "active_support/callbacks" module ActiveJob # = Active Job Callbacks diff --git a/activejob/lib/active_job/core.rb b/activejob/lib/active_job/core.rb index 1b5ddff17b..a338061766 100644 --- a/activejob/lib/active_job/core.rb +++ b/activejob/lib/active_job/core.rb @@ -36,7 +36,7 @@ module ActiveJob module ClassMethods # Creates a new job instance from a hash created with +serialize+ def deserialize(job_data) - job = job_data['job_class'].constantize.new + job = job_data["job_class"].constantize.new job.deserialize(job_data) job end @@ -78,13 +78,13 @@ module ActiveJob # queueing adapter. def serialize { - 'job_class' => self.class.name, - 'job_id' => job_id, - 'queue_name' => queue_name, - 'priority' => priority, - 'arguments' => serialize_arguments(arguments), - 'executions' => executions, - 'locale' => I18n.locale.to_s + "job_class" => self.class.name, + "job_id" => job_id, + "queue_name" => queue_name, + "priority" => priority, + "arguments" => serialize_arguments(arguments), + "executions" => executions, + "locale" => I18n.locale.to_s } end @@ -109,13 +109,13 @@ module ActiveJob # end # end def deserialize(job_data) - self.job_id = job_data['job_id'] - self.provider_job_id = job_data['provider_job_id'] - self.queue_name = job_data['queue_name'] - self.priority = job_data['priority'] - self.serialized_arguments = job_data['arguments'] - self.executions = job_data['executions'] - self.locale = job_data['locale'] || I18n.locale.to_s + self.job_id = job_data["job_id"] + self.provider_job_id = job_data["provider_job_id"] + self.queue_name = job_data["queue_name"] + self.priority = job_data["priority"] + self.serialized_arguments = job_data["arguments"] + self.executions = job_data["executions"] + self.locale = job_data["locale"] || I18n.locale.to_s end private diff --git a/activejob/lib/active_job/enqueuing.rb b/activejob/lib/active_job/enqueuing.rb index 7bc0fe6c3a..e69f76021b 100644 --- a/activejob/lib/active_job/enqueuing.rb +++ b/activejob/lib/active_job/enqueuing.rb @@ -1,4 +1,4 @@ -require 'active_job/arguments' +require "active_job/arguments" module ActiveJob # Provides behavior for enqueuing jobs. diff --git a/activejob/lib/active_job/exceptions.rb b/activejob/lib/active_job/exceptions.rb index acbe0c4057..a8ff55fbe4 100644 --- a/activejob/lib/active_job/exceptions.rb +++ b/activejob/lib/active_job/exceptions.rb @@ -1,4 +1,4 @@ -require 'active_support/core_ext/numeric/time' +require "active_support/core_ext/numeric/time" module ActiveJob # Provides behavior for retrying and discarding jobs on exceptions. diff --git a/activejob/lib/active_job/execution.rb b/activejob/lib/active_job/execution.rb index e374a9489d..94d30c8eaf 100644 --- a/activejob/lib/active_job/execution.rb +++ b/activejob/lib/active_job/execution.rb @@ -1,5 +1,5 @@ -require 'active_support/rescuable' -require 'active_job/arguments' +require "active_support/rescuable" +require "active_job/arguments" module ActiveJob module Execution diff --git a/activejob/lib/active_job/logging.rb b/activejob/lib/active_job/logging.rb index d5c7920131..fd77c94d4f 100644 --- a/activejob/lib/active_job/logging.rb +++ b/activejob/lib/active_job/logging.rb @@ -1,7 +1,7 @@ -require 'active_support/core_ext/hash/transform_values' -require 'active_support/core_ext/string/filters' -require 'active_support/tagged_logging' -require 'active_support/logger' +require "active_support/core_ext/hash/transform_values" +require "active_support/core_ext/string/filters" +require "active_support/tagged_logging" +require "active_support/logger" module ActiveJob module Logging #:nodoc: @@ -82,15 +82,15 @@ module ActiveJob private def queue_name(event) - event.payload[:adapter].class.name.demodulize.remove('Adapter') + "(#{event.payload[:job].queue_name})" + event.payload[:adapter].class.name.demodulize.remove("Adapter") + "(#{event.payload[:job].queue_name})" end def args_info(job) if job.arguments.any? - ' with arguments: ' + - job.arguments.map { |arg| format(arg).inspect }.join(', ') + " with arguments: " + + job.arguments.map { |arg| format(arg).inspect }.join(", ") else - '' + "" end end diff --git a/activejob/lib/active_job/queue_adapter.rb b/activejob/lib/active_job/queue_adapter.rb index 72e4ebf935..b651b30134 100644 --- a/activejob/lib/active_job/queue_adapter.rb +++ b/activejob/lib/active_job/queue_adapter.rb @@ -1,6 +1,6 @@ -require 'active_job/queue_adapters/inline_adapter' -require 'active_support/core_ext/class/attribute' -require 'active_support/core_ext/string/inflections' +require "active_job/queue_adapters/inline_adapter" +require "active_support/core_ext/class/attribute" +require "active_support/core_ext/string/inflections" module ActiveJob # The <tt>ActiveJob::QueueAdapter</tt> module is used to load the diff --git a/activejob/lib/active_job/queue_adapters.rb b/activejob/lib/active_job/queue_adapters.rb index 71154d8785..86cc880b14 100644 --- a/activejob/lib/active_job/queue_adapters.rb +++ b/activejob/lib/active_job/queue_adapters.rb @@ -121,7 +121,7 @@ module ActiveJob autoload :SuckerPunchAdapter autoload :TestAdapter - ADAPTER = 'Adapter'.freeze + ADAPTER = "Adapter".freeze private_constant :ADAPTER class << self diff --git a/activejob/lib/active_job/queue_adapters/async_adapter.rb b/activejob/lib/active_job/queue_adapters/async_adapter.rb index 922bc4afce..e2bff9e646 100644 --- a/activejob/lib/active_job/queue_adapters/async_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/async_adapter.rb @@ -1,7 +1,7 @@ -require 'securerandom' -require 'concurrent/scheduled_task' -require 'concurrent/executor/thread_pool_executor' -require 'concurrent/utility/processor_counter' +require "securerandom" +require "concurrent/scheduled_task" +require "concurrent/executor/thread_pool_executor" +require "concurrent/utility/processor_counter" module ActiveJob module QueueAdapters diff --git a/activejob/lib/active_job/queue_adapters/backburner_adapter.rb b/activejob/lib/active_job/queue_adapters/backburner_adapter.rb index 17703e3e41..e3eccce62b 100644 --- a/activejob/lib/active_job/queue_adapters/backburner_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/backburner_adapter.rb @@ -1,4 +1,4 @@ -require 'backburner' +require "backburner" module ActiveJob module QueueAdapters diff --git a/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb b/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb index 0a785fad3b..83ad2e767d 100644 --- a/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb @@ -1,4 +1,4 @@ -require 'delayed_job' +require "delayed_job" module ActiveJob module QueueAdapters diff --git a/activejob/lib/active_job/queue_adapters/qu_adapter.rb b/activejob/lib/active_job/queue_adapters/qu_adapter.rb index 0e198922fc..c5521bc7ea 100644 --- a/activejob/lib/active_job/queue_adapters/qu_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/qu_adapter.rb @@ -1,4 +1,4 @@ -require 'qu' +require "qu" module ActiveJob module QueueAdapters diff --git a/activejob/lib/active_job/queue_adapters/que_adapter.rb b/activejob/lib/active_job/queue_adapters/que_adapter.rb index ab13689747..0e698f0d79 100644 --- a/activejob/lib/active_job/queue_adapters/que_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/que_adapter.rb @@ -1,4 +1,4 @@ -require 'que' +require "que" module ActiveJob module QueueAdapters diff --git a/activejob/lib/active_job/queue_adapters/queue_classic_adapter.rb b/activejob/lib/active_job/queue_adapters/queue_classic_adapter.rb index 0ee41407d8..1115eb88ae 100644 --- a/activejob/lib/active_job/queue_adapters/queue_classic_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/queue_classic_adapter.rb @@ -1,4 +1,4 @@ -require 'queue_classic' +require "queue_classic" module ActiveJob module QueueAdapters @@ -26,9 +26,9 @@ module ActiveJob def enqueue_at(job, timestamp) #:nodoc: queue = build_queue(job.queue_name) unless queue.respond_to?(:enqueue_at) - raise NotImplementedError, 'To be able to schedule jobs with queue_classic ' \ - 'the QC::Queue needs to respond to `enqueue_at(timestamp, method, *args)`. ' \ - 'You can implement this yourself or you can use the queue_classic-later gem.' + raise NotImplementedError, "To be able to schedule jobs with queue_classic " \ + "the QC::Queue needs to respond to `enqueue_at(timestamp, method, *args)`. " \ + "You can implement this yourself or you can use the queue_classic-later gem." end qc_job = queue.enqueue_at(timestamp, "#{JobWrapper.name}.perform", job.serialize) job.provider_job_id = qc_job["id"] if qc_job.is_a?(Hash) diff --git a/activejob/lib/active_job/queue_adapters/resque_adapter.rb b/activejob/lib/active_job/queue_adapters/resque_adapter.rb index 417854afd8..8620401cc1 100644 --- a/activejob/lib/active_job/queue_adapters/resque_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/resque_adapter.rb @@ -1,12 +1,12 @@ -require 'resque' -require 'active_support/core_ext/enumerable' -require 'active_support/core_ext/array/access' +require "resque" +require "active_support/core_ext/enumerable" +require "active_support/core_ext/array/access" begin - require 'resque-scheduler' + require "resque-scheduler" rescue LoadError begin - require 'resque_scheduler' + require "resque_scheduler" rescue LoadError false end diff --git a/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb b/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb index 3d33b3923b..895cc1f981 100644 --- a/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb @@ -1,4 +1,4 @@ -require 'sidekiq' +require "sidekiq" module ActiveJob module QueueAdapters @@ -18,26 +18,26 @@ module ActiveJob def enqueue(job) #:nodoc: #Sidekiq::Client does not support symbols as keys job.provider_job_id = Sidekiq::Client.push \ - 'class' => JobWrapper, - 'wrapped' => job.class.to_s, - 'queue' => job.queue_name, - 'args' => [ job.serialize ] + "class" => JobWrapper, + "wrapped" => job.class.to_s, + "queue" => job.queue_name, + "args" => [ job.serialize ] end def enqueue_at(job, timestamp) #:nodoc: job.provider_job_id = Sidekiq::Client.push \ - 'class' => JobWrapper, - 'wrapped' => job.class.to_s, - 'queue' => job.queue_name, - 'args' => [ job.serialize ], - 'at' => timestamp + "class" => JobWrapper, + "wrapped" => job.class.to_s, + "queue" => job.queue_name, + "args" => [ job.serialize ], + "at" => timestamp end class JobWrapper #:nodoc: include Sidekiq::Worker def perform(job_data) - Base.execute job_data.merge('provider_job_id' => jid) + Base.execute job_data.merge("provider_job_id" => jid) end end end diff --git a/activejob/lib/active_job/queue_adapters/sneakers_adapter.rb b/activejob/lib/active_job/queue_adapters/sneakers_adapter.rb index d78bdecdcb..f00acfc04a 100644 --- a/activejob/lib/active_job/queue_adapters/sneakers_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/sneakers_adapter.rb @@ -1,5 +1,5 @@ -require 'sneakers' -require 'monitor' +require "sneakers" +require "monitor" module ActiveJob module QueueAdapters @@ -33,7 +33,7 @@ module ActiveJob class JobWrapper #:nodoc: include Sneakers::Worker - from_queue 'default' + from_queue "default" def work(msg) job_data = ActiveSupport::JSON.decode(msg) diff --git a/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb b/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb index 163c8eb212..dd59a79813 100644 --- a/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb @@ -1,4 +1,4 @@ -require 'sucker_punch' +require "sucker_punch" module ActiveJob module QueueAdapters @@ -31,7 +31,7 @@ module ActiveJob delay = timestamp - Time.current.to_f JobWrapper.perform_in delay, job.serialize else - raise NotImplementedError, 'sucker_punch 1.0 does not support `enqueued_at`. Please upgrade to version ~> 2.0.0 to enable this behavior.' + raise NotImplementedError, "sucker_punch 1.0 does not support `enqueued_at`. Please upgrade to version ~> 2.0.0 to enable this behavior." end end diff --git a/activejob/lib/active_job/queue_adapters/test_adapter.rb b/activejob/lib/active_job/queue_adapters/test_adapter.rb index 9b7b7139f4..28a6235429 100644 --- a/activejob/lib/active_job/queue_adapters/test_adapter.rb +++ b/activejob/lib/active_job/queue_adapters/test_adapter.rb @@ -40,7 +40,7 @@ module ActiveJob private def job_to_hash(job, extras = {}) - { job: job.class, args: job.serialize.fetch('arguments'), queue: job.queue_name }.merge!(extras) + { job: job.class, args: job.serialize.fetch("arguments"), queue: job.queue_name }.merge!(extras) end def enqueue_or_perform(perform, job, job_data) diff --git a/activejob/lib/active_job/queue_name.rb b/activejob/lib/active_job/queue_name.rb index 65786a49ff..79c0432294 100644 --- a/activejob/lib/active_job/queue_name.rb +++ b/activejob/lib/active_job/queue_name.rb @@ -36,7 +36,7 @@ module ActiveJob class_attribute :queue_name_delimiter, instance_accessor: false self.queue_name = default_queue_name - self.queue_name_delimiter = '_' # set default delimiter to '_' + self.queue_name_delimiter = "_" # set default delimiter to '_' end # Returns the name of the queue the job will be run on. diff --git a/activejob/lib/active_job/railtie.rb b/activejob/lib/active_job/railtie.rb index a47caa4a7e..e4198a40a5 100644 --- a/activejob/lib/active_job/railtie.rb +++ b/activejob/lib/active_job/railtie.rb @@ -1,12 +1,12 @@ -require 'global_id/railtie' -require 'active_job' +require "global_id/railtie" +require "active_job" module ActiveJob # = Active Job Railtie class Railtie < Rails::Railtie # :nodoc: config.active_job = ActiveSupport::OrderedOptions.new - initializer 'active_job.logger' do + initializer "active_job.logger" do ActiveSupport.on_load(:active_job) { self.logger = ::Rails.logger } end diff --git a/activejob/lib/active_job/test_case.rb b/activejob/lib/active_job/test_case.rb index d894a7b5cd..0d97e00bfa 100644 --- a/activejob/lib/active_job/test_case.rb +++ b/activejob/lib/active_job/test_case.rb @@ -1,4 +1,4 @@ -require 'active_support/test_case' +require "active_support/test_case" module ActiveJob class TestCase < ActiveSupport::TestCase diff --git a/activejob/lib/active_job/test_helper.rb b/activejob/lib/active_job/test_helper.rb index e16af1947f..35fee7452c 100644 --- a/activejob/lib/active_job/test_helper.rb +++ b/activejob/lib/active_job/test_helper.rb @@ -1,5 +1,5 @@ -require 'active_support/core_ext/class/subclasses' -require 'active_support/core_ext/hash/keys' +require "active_support/core_ext/class/subclasses" +require "active_support/core_ext/hash/keys" module ActiveJob # Provides helper methods for testing Active Job diff --git a/activejob/lib/active_job/version.rb b/activejob/lib/active_job/version.rb index 971ba9fe0c..60b463817f 100644 --- a/activejob/lib/active_job/version.rb +++ b/activejob/lib/active_job/version.rb @@ -1,4 +1,4 @@ -require_relative 'gem_version' +require_relative "gem_version" module ActiveJob # Returns the version of the currently loaded Active Job as a <tt>Gem::Version</tt> diff --git a/activejob/lib/rails/generators/job/job_generator.rb b/activejob/lib/rails/generators/job/job_generator.rb index 6e43e4a269..6a509056c8 100644 --- a/activejob/lib/rails/generators/job/job_generator.rb +++ b/activejob/lib/rails/generators/job/job_generator.rb @@ -1,13 +1,13 @@ -require 'rails/generators/named_base' +require "rails/generators/named_base" module Rails # :nodoc: module Generators # :nodoc: class JobGenerator < Rails::Generators::NamedBase # :nodoc: - desc 'This generator creates an active job file at app/jobs' + desc "This generator creates an active job file at app/jobs" - class_option :queue, type: :string, default: 'default', desc: 'The queue name for the generated job' + class_option :queue, type: :string, default: "default", desc: "The queue name for the generated job" - check_class_collision suffix: 'Job' + check_class_collision suffix: "Job" hook_for :test_framework @@ -16,11 +16,11 @@ module Rails # :nodoc: end def create_job_file - template 'job.rb', File.join('app/jobs', class_path, "#{file_name}_job.rb") + template "job.rb", File.join("app/jobs", class_path, "#{file_name}_job.rb") in_root do if self.behavior == :invoke && !File.exist?(application_job_file_name) - template 'application_job.rb', application_job_file_name + template "application_job.rb", application_job_file_name end end end @@ -30,7 +30,7 @@ module Rails # :nodoc: @application_job_file_name ||= if mountable_engine? "app/jobs/#{namespaced_path}/application_job.rb" else - 'app/jobs/application_job.rb' + "app/jobs/application_job.rb" end end end |