Update examples

This commit is contained in:
2017-10-24 01:10:51 +01:00
parent 899ad6bdb6
commit 743efbf647
10 changed files with 36 additions and 16 deletions

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
source 'https://rubygems.org'
gem 'bunnyrun', path: '../..'

View File

@@ -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)

View File

@@ -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

View 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

View File

@@ -1,2 +0,0 @@
require 'foobar/ping_consumer'
require 'foobar/pong_consumer'

View File

@@ -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

View File

@@ -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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Foobar
VERSION = '0.1.0'.freeze
VERSION = '0.1.0'
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'bunnyrun'
class PingConsumer < BunnyRun::Consumer

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'bunnyrun'
class PongConsumer < BunnyRun::Consumer