lib/puppet-herald.rb in puppet-herald-0.1.0 vs lib/puppet-herald.rb in puppet-herald-0.1.1

- old
+ new

@@ -7,17 +7,13 @@ module PuppetHerald @@root = File.dirname(File.dirname(File.realpath(__FILE__))) def self.relative_dir dir - File.join @@root, dir + File.realpath(File.join @@root, dir) end - def self.port - @@port - end - def self.environment env = :production unless ENV['PUPPET_HERALD_ENV'].nil? env = ENV['PUPPET_HERALD_ENV'].to_sym end @@ -29,9 +25,25 @@ end def self.is_in_prod? return !is_in_dev? end + + def self.bug ex + file = Tempfile.new(['puppet-herald-bug', '.log']) + filepath = file.path + file.close + file.unlink + message = "v#{PuppetHerald::VERSION}-#{ex.class.to_s}: #{ex.message}" + contents = message + "\n\n" + ex.backtrace.join("\n") + "\n" + File.write(filepath, contents) + bugo = { + :message => message, + :homepage => PuppetHerald::HOMEPAGE, + :bugfile => filepath, + :help => "Please report this bug to #{PuppetHerald::HOMEPAGE} by passing contents of bug file: #{filepath}" + } + return bugo + end end require 'puppet-herald/database' -require 'puppet-herald/app'