mirror of
https://github.com/jimeh/bunnyrun.git
synced 2026-02-18 23:46:39 +00:00
Update examples
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'bunnyrun', path: '../..'
|
||||
|
||||
@@ -5,14 +5,4 @@ $LOAD_PATH.unshift(File.expand_path('../../lib', File.realpath(__FILE__)))
|
||||
require 'bunnyrun'
|
||||
require 'foobar'
|
||||
|
||||
module Foobar
|
||||
class Application < BunnyRun::Application
|
||||
name File.basename(__FILE__)
|
||||
usage '<options> [<path>]'
|
||||
version Foobar::VERSION
|
||||
|
||||
option :log_message, 'Message to log after success', type: :string
|
||||
end
|
||||
end
|
||||
|
||||
Foobar::Application.run(argv: ARGV)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
require 'foobar/consumers'
|
||||
require 'foobar/version'
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'foobar/application'
|
||||
require 'foobar/ping_consumer'
|
||||
require 'foobar/pong_consumer'
|
||||
|
||||
module Foobar
|
||||
end
|
||||
|
||||
14
examples/application-example/lib/foobar/application.rb
Normal file
14
examples/application-example/lib/foobar/application.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'foobar/version'
|
||||
|
||||
module Foobar
|
||||
class Application < BunnyRun::Application
|
||||
name 'foobar'
|
||||
usage '<options> [<path>]'
|
||||
version Foobar::VERSION
|
||||
|
||||
option :success_message, 'Message to log after success',
|
||||
type: :string, default: ENV['MESSAGE']
|
||||
end
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
require 'foobar/ping_consumer'
|
||||
require 'foobar/pong_consumer'
|
||||
@@ -17,7 +17,9 @@ module Foobar
|
||||
|
||||
publish('ping-pong', 'PONG', routing_key: 'pong')
|
||||
message.ack
|
||||
logger.info
|
||||
|
||||
return unless options[:success_message]
|
||||
logger.info("#{self.class}: #{options[:success_message]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'bunnyrun'
|
||||
|
||||
module Foobar
|
||||
@@ -15,6 +17,9 @@ module Foobar
|
||||
|
||||
publish('ping-pong', 'PING', routing_key: 'ping')
|
||||
message.ack
|
||||
|
||||
return unless options[:success_message]
|
||||
logger.info("#{self.class}: #{options[:success_message]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Foobar
|
||||
VERSION = '0.1.0'.freeze
|
||||
VERSION = '0.1.0'
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'bunnyrun'
|
||||
|
||||
class PingConsumer < BunnyRun::Consumer
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'bunnyrun'
|
||||
|
||||
class PongConsumer < BunnyRun::Consumer
|
||||
|
||||
Reference in New Issue
Block a user