desc 'Publisher renote_dac Tasks' namespace :publisher_renote_dac do
namespace :rabbitmq do desc "Setup routing" task :setup do require "bunny" require 'json' if Rails.env.production? conn_params = ENV['RABBITMQ_BIGWIG_TX_URL'] else conn_params = { :vhost => '/', :user => 'guest', :password => 'guest' } end conn = Bunny.new(ENV['RABBITMQ_BIGWIG_TX_URL']) conn.start ch = conn.create_channel # connect one exchange to multiple queues x = ch.fanout('publisher_renote_dac.email') ch.queue('consumer_renote_dac.email', durable: true).bind('publisher_renote_dac.email') conn.close end end desc 'Deploy tasks' task :deploy do puts "Removing old .gem files" FileUtils.rm_rf(Dir["#{PublisherRenoteDac::Engine.root}/*.gem"]) puts "Incrementing Minor Patch Version" file = File.read(PublisherRenoteDac::Engine.root.join('lib','publisher_renote_dac','version.rb')) version = file.match(/\d+\.\d+\.\d+/).to_s new_version = "#{version.split(".")[(0..1)].join(".")}.#{version.split(".").last.to_i + 1}" FileUtils.rm_rf(Dir["#{PublisherRenoteDac::Engine.root}/lib/publisher_renote_dac/version.rb"]) File.open(PublisherRenoteDac::Engine.root.join('lib', 'publisher_renote_dac', 'version.rb'), 'w') {|f| f.write("#{file.gsub(version, "#{new_version}")}") } system "gem build publisher_renote_dac.gemspec" system "bin/deploy 'rake app:publisher_renote_dac automatic deployment - #{version} to version #{new_version}'" end
end