From beb0057335c9b8f826e01e63454ecab9bb28eef2 Mon Sep 17 00:00:00 2001 From: Shota Iguchi Date: Sat, 31 Dec 2016 02:32:30 +0900 Subject: [PATCH 1/2] Make use `config_for` method for loading config file Since Rails 4.2 YAML configuration files can be easily loaded with the new config_for --- lib/kuroko2/configuration.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/kuroko2/configuration.rb b/lib/kuroko2/configuration.rb index 46275b2f..a566fdf0 100644 --- a/lib/kuroko2/configuration.rb +++ b/lib/kuroko2/configuration.rb @@ -9,10 +9,10 @@ def config @config ||= build_config end + private + def build_config - filename = Rails.root.join('config', 'kuroko2.yml') - yaml = YAML::load(ERB.new(File.read(filename)).result) - Hashie::Mash.new(DEFAULT_CONFIG.merge(yaml[Rails.env])) + Hashie::Mash.new(DEFAULT_CONFIG.merge(Rails.application.config_for('kuroko2'))) end end end From c86c19088bc7aacb4c4195503c881d75cd1057e2 Mon Sep 17 00:00:00 2001 From: Shota Iguchi Date: Sat, 31 Dec 2016 02:47:55 +0900 Subject: [PATCH 2/2] Remove warnings duplicated character range occured with: RUBYOPT="-w" bundle exec rspec spec message `warning: character class has duplicated range` --- lib/autoload/kuroko2/workflow/task/queue.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/autoload/kuroko2/workflow/task/queue.rb b/lib/autoload/kuroko2/workflow/task/queue.rb index 16dce268..9b7afe10 100644 --- a/lib/autoload/kuroko2/workflow/task/queue.rb +++ b/lib/autoload/kuroko2/workflow/task/queue.rb @@ -13,8 +13,8 @@ def execute end def validate - unless /\A\@?[\w_-]{1,180}\z/ === option - raise Workflow::AssertionError, "Queue name must be match with /\A\@?[\w_-]{1,255}\z/: #{option}" + unless /\A\@?[\w-]{1,180}\z/ === option + raise Workflow::AssertionError, "Queue name must be match with /\A\@?[\w-]{1,255}\z/: #{option}" end unless Worker.where(queue: option, working: true).exists?