From 010c64e87a4e49d833fc386c8512b982d57e6a17 Mon Sep 17 00:00:00 2001 From: ari Date: Sun, 4 Dec 2022 14:04:29 +0300 Subject: [PATCH 1/5] Add Logger production path --- lib/rabbit_carrots/tasks/rmq.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rabbit_carrots/tasks/rmq.rake b/lib/rabbit_carrots/tasks/rmq.rake index 05c7e84..3fc3698 100644 --- a/lib/rabbit_carrots/tasks/rmq.rake +++ b/lib/rabbit_carrots/tasks/rmq.rake @@ -10,7 +10,7 @@ namespace :rabbit_carrots do { **mapping, handler: mapping[:handler].constantize } end - Rails.logger = Logger.new($stdout) + Rails.logger = Logger.new(Rails.env.production? ? '/proc/self/fd/1' : $stdout) # Run RMQ Subscriber for each channel channels.each do |channel| From 6b2fe8f329c86df52b669eefb3d0b2f96479e66b Mon Sep 17 00:00:00 2001 From: ari Date: Sun, 4 Dec 2022 14:06:08 +0300 Subject: [PATCH 2/5] Update version --- Gemfile.lock | 4 ++-- lib/rabbit_carrots/version.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d9c5cb1..63fa79b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rabbit_carrots (0.1.14) + rabbit_carrots (0.1.15) bunny (>= 2.19.0) connection_pool (~> 2.3.0) @@ -66,4 +66,4 @@ DEPENDENCIES rubocop (~> 1.21) BUNDLED WITH - 2.3.23 + 2.3.26 diff --git a/lib/rabbit_carrots/version.rb b/lib/rabbit_carrots/version.rb index 143cbac..72adf9d 100644 --- a/lib/rabbit_carrots/version.rb +++ b/lib/rabbit_carrots/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module RabbitCarrots - VERSION = "0.1.14" + VERSION = "0.1.15" end From afa47c6463140cc7b2c1edb1f85f298664164d25 Mon Sep 17 00:00:00 2001 From: ari Date: Sun, 4 Dec 2022 14:36:40 +0300 Subject: [PATCH 3/5] Update tests --- lib/rabbit_carrots/connection.rb | 6 +++--- spec/rabbit_carrots_spec.rb | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/rabbit_carrots/connection.rb b/lib/rabbit_carrots/connection.rb index 7512fd4..8a1b246 100644 --- a/lib/rabbit_carrots/connection.rb +++ b/lib/rabbit_carrots/connection.rb @@ -4,7 +4,7 @@ module RabbitCarrots class Connection include ::Singleton attr_reader :connection - + def initialize @connection = Bunny.new( host: RabbitCarrots.configuration.rabbitmq_host, @@ -16,11 +16,11 @@ module RabbitCarrots @connection.start end - + def channel @channel ||= ConnectionPool.new do connection.create_channel end end - end + end end diff --git a/spec/rabbit_carrots_spec.rb b/spec/rabbit_carrots_spec.rb index 303261f..1b5cd7d 100644 --- a/spec/rabbit_carrots_spec.rb +++ b/spec/rabbit_carrots_spec.rb @@ -4,8 +4,4 @@ RSpec.describe RabbitCarrots do it "has a version number" do expect(RabbitCarrots::VERSION).not_to be nil end - - it "does something useful" do - expect(false).to eq(true) - end end From cbc99c200752c4a0e5cf7b3b555390cac7300089 Mon Sep 17 00:00:00 2001 From: ari Date: Sun, 4 Dec 2022 14:41:13 +0300 Subject: [PATCH 4/5] Add rubocop-rails gem --- Gemfile | 2 ++ Gemfile.lock | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Gemfile b/Gemfile index 905a28e..5ea1484 100644 --- a/Gemfile +++ b/Gemfile @@ -10,3 +10,5 @@ gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "rubocop", "~> 1.21" + +gem "rubocop-rails", "~> 2.17" diff --git a/Gemfile.lock b/Gemfile.lock index 63fa79b..a8cdc6a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,17 +8,27 @@ PATH GEM remote: https://rubygems.org/ specs: + activesupport (7.0.4) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) amq-protocol (2.3.2) ast (2.4.2) bunny (2.19.0) amq-protocol (~> 2.3, >= 2.3.1) sorted_set (~> 1, >= 1.0.2) + concurrent-ruby (1.1.10) connection_pool (2.3.0) diff-lcs (1.5.0) + i18n (1.12.0) + concurrent-ruby (~> 1.0) json (2.6.2) + minitest (5.16.3) parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) + rack (3.0.1) rainbow (3.1.1) rake (13.0.6) rbtree (0.4.5) @@ -49,11 +59,17 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.23.0) parser (>= 3.1.1.0) + rubocop-rails (2.17.3) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.33.0, < 2.0) ruby-progressbar (1.11.0) set (1.0.3) sorted_set (1.0.3) rbtree set (~> 1.0) + tzinfo (2.0.5) + concurrent-ruby (~> 1.0) unicode-display_width (2.3.0) PLATFORMS @@ -64,6 +80,7 @@ DEPENDENCIES rake (~> 13.0) rspec (~> 3.0) rubocop (~> 1.21) + rubocop-rails (~> 2.17) BUNDLED WITH 2.3.26 From d729bf09cc4b4d73658b1266498f906831c43e7d Mon Sep 17 00:00:00 2001 From: ari Date: Sun, 4 Dec 2022 14:43:08 +0300 Subject: [PATCH 5/5] Fix rubocop errors --- Gemfile | 10 +++++----- Rakefile | 6 +++--- lib/rabbit_carrots.rb | 9 ++++----- lib/rabbit_carrots/railtie.rb | 2 +- lib/rabbit_carrots/version.rb | 2 +- rabbit_carrots.gemspec | 35 ++++++++++++++++++----------------- spec/rabbit_carrots_spec.rb | 2 +- spec/spec_helper.rb | 4 ++-- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Gemfile b/Gemfile index 5ea1484..bec74e4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,14 +1,14 @@ # frozen_string_literal: true -source "https://rubygems.org" +source 'https://rubygems.org' # Specify your gem's dependencies in rabbit_carrots.gemspec gemspec -gem "rake", "~> 13.0" +gem 'rake', '~> 13.0' -gem "rspec", "~> 3.0" +gem 'rspec', '~> 3.0' -gem "rubocop", "~> 1.21" +gem 'rubocop', '~> 1.21' -gem "rubocop-rails", "~> 2.17" +gem 'rubocop-rails', '~> 2.17' diff --git a/Rakefile b/Rakefile index cca7175..4964751 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,11 @@ # frozen_string_literal: true -require "bundler/gem_tasks" -require "rspec/core/rake_task" +require 'bundler/gem_tasks' +require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) -require "rubocop/rake_task" +require 'rubocop/rake_task' RuboCop::RakeTask.new diff --git a/lib/rabbit_carrots.rb b/lib/rabbit_carrots.rb index 2655e4e..9826ae6 100644 --- a/lib/rabbit_carrots.rb +++ b/lib/rabbit_carrots.rb @@ -1,24 +1,23 @@ # frozen_string_literal: true -require_relative "rabbit_carrots/version" +require_relative 'rabbit_carrots/version' require 'rabbit_carrots/connection' require 'rabbit_carrots/configuration' require 'rabbit_carrots/railtie' if defined?(Rails) - module RabbitCarrots class Error < StandardError; end + module EventHandlers module Errors class IrrelevantMessage < StandardError end - + class NackMessage < StandardError end - + class NackAndRequeueMessage < StandardError end end end - end diff --git a/lib/rabbit_carrots/railtie.rb b/lib/rabbit_carrots/railtie.rb index 28a41d1..0fa109d 100644 --- a/lib/rabbit_carrots/railtie.rb +++ b/lib/rabbit_carrots/railtie.rb @@ -10,4 +10,4 @@ module RabbitCarrots Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f } end end -end \ No newline at end of file +end diff --git a/lib/rabbit_carrots/version.rb b/lib/rabbit_carrots/version.rb index 72adf9d..be74ffa 100644 --- a/lib/rabbit_carrots/version.rb +++ b/lib/rabbit_carrots/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module RabbitCarrots - VERSION = "0.1.15" + VERSION = '0.1.15' end diff --git a/rabbit_carrots.gemspec b/rabbit_carrots.gemspec index 755f10b..0a4aedc 100644 --- a/rabbit_carrots.gemspec +++ b/rabbit_carrots.gemspec @@ -1,24 +1,24 @@ # frozen_string_literal: true -require_relative "lib/rabbit_carrots/version" +require_relative 'lib/rabbit_carrots/version' Gem::Specification.new do |spec| - spec.name = "rabbit_carrots" + spec.name = 'rabbit_carrots' spec.version = RabbitCarrots::VERSION - spec.authors = ["Brusk Awat"] - spec.email = ["broosk.edogawa@gmail.com"] + spec.authors = ['Brusk Awat'] + spec.email = ['broosk.edogawa@gmail.com'] - spec.summary = "A simple RabbitMQ consumer task" - spec.description = "A background task based on rake to consume RabbitMQ messages" - spec.homepage = "https://github.com/ditkrg" - spec.license = "MIT" - spec.required_ruby_version = ">= 3.1.0" + spec.summary = 'A simple RabbitMQ consumer task' + spec.description = 'A background task based on rake to consume RabbitMQ messages' + spec.homepage = 'https://github.com/ditkrg' + spec.license = 'MIT' + spec.required_ruby_version = '>= 3.1.0' - spec.metadata["allowed_push_host"] = "https://rubygems.org" + spec.metadata['allowed_push_host'] = 'https://rubygems.org' - spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = "https://github.com/ditkrg/rabbit_carrots" - spec.metadata["changelog_uri"] = "https://github.com/ditkrg/rabbit_carrots" + spec.metadata['homepage_uri'] = spec.homepage + spec.metadata['source_code_uri'] = 'https://github.com/ditkrg/rabbit_carrots' + spec.metadata['changelog_uri'] = 'https://github.com/ditkrg/rabbit_carrots' # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. @@ -27,14 +27,15 @@ Gem::Specification.new do |spec| (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)}) end end - spec.bindir = "exe" + spec.bindir = 'exe' spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] # Uncomment to register a new dependency of your gem - spec.add_dependency "bunny", ">= 2.19.0" - spec.add_dependency "connection_pool", "~> 2.3.0" + spec.add_dependency 'bunny', '>= 2.19.0' + spec.add_dependency 'connection_pool', '~> 2.3.0' # For more information and examples about making a new gem, check out our # guide at: https://bundler.io/guides/creating_gem.html + spec.metadata['rubygems_mfa_required'] = 'true' end diff --git a/spec/rabbit_carrots_spec.rb b/spec/rabbit_carrots_spec.rb index 1b5cd7d..4ad3c1f 100644 --- a/spec/rabbit_carrots_spec.rb +++ b/spec/rabbit_carrots_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe RabbitCarrots do - it "has a version number" do + it 'has a version number' do expect(RabbitCarrots::VERSION).not_to be nil end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7a4c7b4..6bedab1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require "rabbit_carrots" +require 'rabbit_carrots' RSpec.configure do |config| # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" + config.example_status_persistence_file_path = '.rspec_status' # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching!