From d9c5500cd0e9043fc03bf5475633529c1c8df4b1 Mon Sep 17 00:00:00 2001 From: Tawan Sierek Date: Fri, 1 Jan 2016 15:40:00 +0100 Subject: [PATCH] Renamed gem to active_elastic_job The new name is easier to pronounce and easier to memorize. --- Gemfile.lock | 4 ++-- README.md | 2 +- Vagrantfile | 2 +- rails-eb-job.gemspec => active-elastic-job.gemspec | 8 ++++---- lib/active_elastic_job.rb | 8 ++++++++ .../rack/sqs_processor.rb | 2 +- lib/active_elastic_job/railtie.rb | 7 +++++++ lib/{rails_eb_job => active_elastic_job}/version.rb | 2 +- ...eb_job_adapter.rb => active_elastic_job_adapter.rb} | 4 ++-- lib/rails_eb_job.rb | 8 -------- lib/rails_eb_job/railtie.rb | 7 ------- .../rack/sqs_processor_spec.rb | 4 ++-- spec/active_elastic_job_spec.rb | 7 +++++++ ...pter_spec.rb => active_elastic_job_adapter_spec.rb} | 10 +++++----- spec/helpers.rb | 6 +++--- spec/integration/aws_sqs_client_spec.rb | 2 +- spec/integration/rails-app/Gemfile | 2 +- spec/integration/rails-app/Gemfile.lock | 6 +++--- spec/integration/rails-app/app/jobs/test_job.rb | 2 +- spec/integration/rails-app/config/application.rb | 2 +- spec/rails_eb_job_spec.rb | 7 ------- spec/spec_helper.rb | 2 +- 22 files changed, 52 insertions(+), 52 deletions(-) rename rails-eb-job.gemspec => active-elastic-job.gemspec (79%) create mode 100644 lib/active_elastic_job.rb rename lib/{rails_eb_job => active_elastic_job}/rack/sqs_processor.rb (96%) create mode 100644 lib/active_elastic_job/railtie.rb rename lib/{rails_eb_job => active_elastic_job}/version.rb (50%) rename lib/active_job/queue_adapters/{rails_eb_job_adapter.rb => active_elastic_job_adapter.rb} (81%) delete mode 100644 lib/rails_eb_job.rb delete mode 100644 lib/rails_eb_job/railtie.rb rename spec/{rails_eb_job => active_elastic_job}/rack/sqs_processor_spec.rb (90%) create mode 100644 spec/active_elastic_job_spec.rb rename spec/active_job/queue_adapters/{rails_eb_job_adapter_spec.rb => active_elastic_job_adapter_spec.rb} (72%) delete mode 100644 spec/rails_eb_job_spec.rb diff --git a/Gemfile.lock b/Gemfile.lock index 3d6b16d..7b978c4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rails_eb_job (0.1.0) + active_elastic_job (0.1.0) aws-sdk (~> 2) GEM @@ -140,12 +140,12 @@ PLATFORMS ruby DEPENDENCIES + active_elastic_job! bundler dotenv fuubar pry-byebug rails (~> 4.2) - rails_eb_job! rspec (~> 3.4) BUNDLED WITH diff --git a/README.md b/README.md index e7fb7ad..13d5847 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# rails-eb-job +# active-elastic-job diff --git a/Vagrantfile b/Vagrantfile index 9d942a6..48133f8 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -13,6 +13,6 @@ Vagrant.configure(2) do |config| # Every Vagrant development environment requires a box. You can search for # boxes at https://atlas.hashicorp.com/search. config.vm.box = "ubuntu/trusty64" - config.vm.hostname = 'rails-eb-job-dev-box' + config.vm.hostname = 'active-elastic-job-dev-box' config.vm.provision :shell, path: 'bootstrap.sh', keep_color: true end diff --git a/rails-eb-job.gemspec b/active-elastic-job.gemspec similarity index 79% rename from rails-eb-job.gemspec rename to active-elastic-job.gemspec index 3ba747b..337cc83 100644 --- a/rails-eb-job.gemspec +++ b/active-elastic-job.gemspec @@ -2,18 +2,18 @@ lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'rails_eb_job/version' +require 'active_elastic_job/version' Gem::Specification.new do |spec| spec.platform = Gem::Platform::RUBY - spec.name = 'rails_eb_job' - spec.version = RailsEbJob::VERSION + spec.name = 'active_elastic_job' + spec.version = ActiveElasticJob::VERSION spec.authors = ['Tawan Sierek'] spec.email = ['tawan@sierek.com'] spec.description = spec.summary = %q() spec.license = 'MIT' - spec.files = Dir.glob('lib/**/*') + [ 'rails-eb-job.gemspec' ] + spec.files = Dir.glob('lib/**/*') + [ 'active-elastic-job.gemspec' ] spec.executables = [] spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] diff --git a/lib/active_elastic_job.rb b/lib/active_elastic_job.rb new file mode 100644 index 0000000..72baee1 --- /dev/null +++ b/lib/active_elastic_job.rb @@ -0,0 +1,8 @@ +require 'aws-sdk-core' +require 'active_elastic_job/version' +require 'active_job/queue_adapters/active_elastic_job_adapter' +require 'active_elastic_job/rack/sqs_processor' + +module ActiveElasticJob; end; + +require "active_elastic_job/railtie" if defined? Rails diff --git a/lib/rails_eb_job/rack/sqs_processor.rb b/lib/active_elastic_job/rack/sqs_processor.rb similarity index 96% rename from lib/rails_eb_job/rack/sqs_processor.rb rename to lib/active_elastic_job/rack/sqs_processor.rb index 1d00fd3..522e5a1 100644 --- a/lib/rails_eb_job/rack/sqs_processor.rb +++ b/lib/active_elastic_job/rack/sqs_processor.rb @@ -1,6 +1,6 @@ require "action_dispatch" -module RailsEbJob +module ActiveElasticJob module Rack class SqsProcessor def initialize(app) diff --git a/lib/active_elastic_job/railtie.rb b/lib/active_elastic_job/railtie.rb new file mode 100644 index 0000000..e3a3fb0 --- /dev/null +++ b/lib/active_elastic_job/railtie.rb @@ -0,0 +1,7 @@ +module ActiveElasticJob + class Railtie < Rails::Railtie + initializer "active_elastic_job.insert_middleware" do |app| + app.config.middleware.use "ActiveElasticJob::Rack::SqsProcessor" + end + end +end diff --git a/lib/rails_eb_job/version.rb b/lib/active_elastic_job/version.rb similarity index 50% rename from lib/rails_eb_job/version.rb rename to lib/active_elastic_job/version.rb index 6e30534..2051c75 100644 --- a/lib/rails_eb_job/version.rb +++ b/lib/active_elastic_job/version.rb @@ -1,3 +1,3 @@ -module RailsEbJob +module ActiveElasticJob VERSION = '0.1.0' end diff --git a/lib/active_job/queue_adapters/rails_eb_job_adapter.rb b/lib/active_job/queue_adapters/active_elastic_job_adapter.rb similarity index 81% rename from lib/active_job/queue_adapters/rails_eb_job_adapter.rb rename to lib/active_job/queue_adapters/active_elastic_job_adapter.rb index 4b30283..444d9f9 100644 --- a/lib/active_job/queue_adapters/rails_eb_job_adapter.rb +++ b/lib/active_job/queue_adapters/active_elastic_job_adapter.rb @@ -1,11 +1,11 @@ module ActiveJob module QueueAdapters - class RailsEbJobAdapter + class ActiveElasticJobAdapter class << self attr_writer :aws_sqs_client def enqueue(job) - queue_url = aws_sqs_client.get_queue_url(queue_name: job.queue_name.to_s).queue_url + queue_url = aws_sqs_client.create_queue(queue_name: job.queue_name.to_s).queue_url aws_sqs_client.send_message( queue_url: queue_url, message_body: JSON.dump(job.serialize) diff --git a/lib/rails_eb_job.rb b/lib/rails_eb_job.rb deleted file mode 100644 index 17c1d5e..0000000 --- a/lib/rails_eb_job.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'aws-sdk-core' -require 'rails_eb_job/version' -require 'active_job/queue_adapters/rails_eb_job_adapter' -require 'rails_eb_job/rack/sqs_processor' - -module RailsEbJob; end; - -require "rails_eb_job/railtie" if defined? Rails diff --git a/lib/rails_eb_job/railtie.rb b/lib/rails_eb_job/railtie.rb deleted file mode 100644 index 7d2673b..0000000 --- a/lib/rails_eb_job/railtie.rb +++ /dev/null @@ -1,7 +0,0 @@ -module RailsEbJob - class Railtie < Rails::Railtie - initializer "rails_eb_job.insert_middleware" do |app| - app.config.middleware.use "RailsEbJob::Rack::SqsProcessor" - end - end -end diff --git a/spec/rails_eb_job/rack/sqs_processor_spec.rb b/spec/active_elastic_job/rack/sqs_processor_spec.rb similarity index 90% rename from spec/rails_eb_job/rack/sqs_processor_spec.rb rename to spec/active_elastic_job/rack/sqs_processor_spec.rb index c289395..5e2a509 100644 --- a/spec/rails_eb_job/rack/sqs_processor_spec.rb +++ b/spec/active_elastic_job/rack/sqs_processor_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' require 'rack/mock' -describe RailsEbJob::Rack::SqsProcessor do +describe ActiveElasticJob::Rack::SqsProcessor do let(:env) { Rack::MockRequest.env_for("http://example.com:8080/") } let(:app) { double("app") } let(:original_response) { double("original_response") } - subject(:sqs_processor) { RailsEbJob::Rack::SqsProcessor.new(app) } + subject(:sqs_processor) { ActiveElasticJob::Rack::SqsProcessor.new(app) } it "passes an ordinary request through" do expect(app).to receive(:call).with(env).and_return(original_response) diff --git a/spec/active_elastic_job_spec.rb b/spec/active_elastic_job_spec.rb new file mode 100644 index 0000000..5a3c2ee --- /dev/null +++ b/spec/active_elastic_job_spec.rb @@ -0,0 +1,7 @@ +require 'spec_helper' + +describe ActiveElasticJob do + it 'has a version' do + expect(ActiveElasticJob::VERSION).to be_a(String) + end +end diff --git a/spec/active_job/queue_adapters/rails_eb_job_adapter_spec.rb b/spec/active_job/queue_adapters/active_elastic_job_adapter_spec.rb similarity index 72% rename from spec/active_job/queue_adapters/rails_eb_job_adapter_spec.rb rename to spec/active_job/queue_adapters/active_elastic_job_adapter_spec.rb index 29016f2..911f5bd 100644 --- a/spec/active_job/queue_adapters/rails_eb_job_adapter_spec.rb +++ b/spec/active_job/queue_adapters/active_elastic_job_adapter_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe ActiveJob::QueueAdapters::RailsEbJobAdapter do - subject(:adapter) { ActiveJob::QueueAdapters::RailsEbJobAdapter } +describe ActiveJob::QueueAdapters::ActiveElasticJobAdapter do + subject(:adapter) { ActiveJob::QueueAdapters::ActiveElasticJobAdapter } let(:aws_sqs_client) { double("aws_sqs_client") @@ -17,16 +17,16 @@ describe ".enqueue" do it "selects the correct queue" do expected_args = { queue_name: job.queue_name.to_s } - expect(aws_sqs_client).to receive(:get_queue_url).with(expected_args) + expect(aws_sqs_client).to receive(:create_queue).with(expected_args) - allow(aws_sqs_client).to receive(:get_queue_url) { queue_url_resp } + allow(aws_sqs_client).to receive(:create_queue) { queue_url_resp } allow(queue_url_resp).to receive(:queue_url) { queue_url } allow(aws_sqs_client).to receive(:send_message) { } adapter.enqueue job end it "sends the serialized job as a message to an AWS SQS queue" do - allow(aws_sqs_client).to receive(:get_queue_url) { queue_url_resp } + allow(aws_sqs_client).to receive(:create_queue) { queue_url_resp } allow(queue_url_resp).to receive(:queue_url) { queue_url } expected_args = { queue_url: queue_url, diff --git a/spec/helpers.rb b/spec/helpers.rb index d2b08dc..88dd8ed 100644 --- a/spec/helpers.rb +++ b/spec/helpers.rb @@ -66,7 +66,7 @@ def create_random_string(random_string) private def build_gem - unless system("gem build rails-eb-job.gemspec") + unless system("gem build active-elastic-job.gemspec") raise "Could not build gem package!" end begin @@ -85,14 +85,14 @@ def unpack_gem_into_vendor_dir raise "Could not unpack gem" end Dir.chdir(target_dir) do - unless system("rm -rf rails_eb_job-current") && system("mv #{gem_package_name} rails_eb_job-current") + unless system("rm -rf active_elastic_job-current") && system("mv #{gem_package_name} active_elastic_job-current") raise "Could not move gem" end end end def gem_package_name - "rails_eb_job-#{RailsEbJob::VERSION}" + "active_elastic_job-#{ActiveElasticJob::VERSION}" end def root_dir diff --git a/spec/integration/aws_sqs_client_spec.rb b/spec/integration/aws_sqs_client_spec.rb index 660308c..57da856 100644 --- a/spec/integration/aws_sqs_client_spec.rb +++ b/spec/integration/aws_sqs_client_spec.rb @@ -17,7 +17,7 @@ def perform(test_arg) end describe "message dispatching" do - let(:queue_name) { "RailsEbJob-integration-testing" } + let(:queue_name) { "ActiveElasticJob-integration-testing" } let(:queue_url) do response = aws_client.create_queue(queue_name: queue_name) response.queue_url diff --git a/spec/integration/rails-app/Gemfile b/spec/integration/rails-app/Gemfile index d995d26..b9fcdad 100644 --- a/spec/integration/rails-app/Gemfile +++ b/spec/integration/rails-app/Gemfile @@ -31,7 +31,7 @@ gem 'sdoc', '~> 0.4.0', group: :doc # Use Capistrano for deployment # gem 'capistrano-rails', group: :development -gem 'rails_eb_job', :path => 'vendor/gems/rails_eb_job-current' +gem 'active_elastic_job', :path => 'vendor/gems/active_elastic_job-current' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/spec/integration/rails-app/Gemfile.lock b/spec/integration/rails-app/Gemfile.lock index cccfc8c..ccac243 100644 --- a/spec/integration/rails-app/Gemfile.lock +++ b/spec/integration/rails-app/Gemfile.lock @@ -1,7 +1,7 @@ PATH - remote: vendor/gems/rails_eb_job-current + remote: vendor/gems/active_elastic_job-current specs: - rails_eb_job (0.1.0) + active_elastic_job (0.1.0) aws-sdk (~> 2) GEM @@ -152,12 +152,12 @@ PLATFORMS ruby DEPENDENCIES + active_elastic_job! byebug coffee-rails (~> 4.1.0) jbuilder (~> 2.0) jquery-rails rails (= 4.2.5) - rails_eb_job! sass-rails (~> 5.0) sdoc (~> 0.4.0) spring diff --git a/spec/integration/rails-app/app/jobs/test_job.rb b/spec/integration/rails-app/app/jobs/test_job.rb index 3d836ef..5945cd5 100644 --- a/spec/integration/rails-app/app/jobs/test_job.rb +++ b/spec/integration/rails-app/app/jobs/test_job.rb @@ -1,5 +1,5 @@ class TestJob < ActiveJob::Base - queue_as :rails_eb_job_integration_testing + queue_as :active_elastic_job_integration_testing WEB_ENV_HOST = ENV['WEB_ENV_HOST'] WEB_ENV_PORT = ENV['WEB_ENV_PORT'] diff --git a/spec/integration/rails-app/config/application.rb b/spec/integration/rails-app/config/application.rb index 8f46680..8f3d7b2 100644 --- a/spec/integration/rails-app/config/application.rb +++ b/spec/integration/rails-app/config/application.rb @@ -23,6 +23,6 @@ class Application < Rails::Application # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true - config.active_job.queue_adapter = :rails_eb_job + config.active_job.queue_adapter = :active_elastic_job end end diff --git a/spec/rails_eb_job_spec.rb b/spec/rails_eb_job_spec.rb deleted file mode 100644 index e2d13dd..0000000 --- a/spec/rails_eb_job_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'spec_helper' - -describe RailsEbJob do - it 'has a version' do - expect(RailsEbJob::VERSION).to be_a(String) - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 78bed3b..45ffbcd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,7 @@ Bundler.setup require 'pry-byebug' -require 'rails_eb_job' +require 'active_elastic_job' require 'dotenv' Dotenv.load