Use SecureRandom if uuid4r is not available
MODIFY
beetle.gemspec
beetle.gemspec
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
}
s.specification_version = 3
- s.add_runtime_dependency "uuid4r", ">= 0.1.2"
s.add_runtime_dependency "bunny", "~> 0.7.12"
s.add_runtime_dependency "redis", ">= 2.2.2"
s.add_runtime_dependency "hiredis", ">= 0.4.5"
@@ -31,6 +30,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "amqp", "= 1.6.0"
s.add_runtime_dependency "activesupport", ">= 2.3.4"
+ s.add_development_dependency "uuid4r", ">= 0.1.2"
s.add_development_dependency "activerecord", "~> 5.0"
s.add_development_dependency "cucumber", "~> 2.4.0"
s.add_development_dependency "daemon_controller", "~> 1.2.0"

MODIFY
lib/beetle.rb
lib/beetle.rb
$:.unshift(File.expand_path('..', __FILE__))
require 'bunny' # which bunny picks up
require 'qrack/errors' # needed by the publisher
-require 'uuid4r'
require 'redis/connection/hiredis' # require *before* redis as specified in the redis-rb gem docs
require 'redis'
require 'active_support/all'

MODIFY
lib/beetle/message.rb
lib/beetle/message.rb
@@ -146,9 +146,16 @@ module Beetle
end
# generate uuid for publishing
+ begin
+ require "uuid4r"
def self.generate_uuid
UUID4R::uuid(4)
end
+ rescue LoadError
+ def self.generate_uuid
+ SecureRandom.uuid
+ end
+ end
# whether the publisher has tried sending this message to two servers
def redundant?

Use SecureRandom if uuid4r is not available