Class: Campfire::Bot
- Inherits:
-
Object
- Object
- Campfire::Bot
- Defined in:
- lib/pagerduty_tools/campfire.rb
Instance Method Summary collapse
-
#initialize ⇒ Bot
constructor
A new instance of Bot.
- #paste(body) ⇒ Object
- #topic(topic) ⇒ Object
Constructor Details
#initialize ⇒ Bot
Returns a new instance of Bot.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pagerduty_tools/campfire.rb', line 41 def initialize # TODO: make sure that the file is there and that all the keys are, too. config = YAML.load_file(File.(CONFIG_FILE)) @uri = URI.parse config["site"] @room = config["room"] @token = config["token"] @pass = 'x' @http = Net::HTTP.new(@uri.host, @uri.port) @http.use_ssl = true @http.ca_file = File.(CA_FILE) @http.verify_mode = OpenSSL::SSL::VERIFY_PEER end |
Instance Method Details
#paste(body) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/pagerduty_tools/campfire.rb', line 65 def paste(body) request = Net::HTTP::Post.new("/room/#{@room}/speak.xml") = Nokogiri::XML::Builder.new do |xml| xml. { xml.type_ "PasteMessage" xml.body body } end return do_request(request, .to_xml) end |
#topic(topic) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/pagerduty_tools/campfire.rb', line 55 def topic(topic) request = Net::HTTP::Put.new "/room/#{@room}.xml" = Nokogiri::XML::Builder.new do |xml| xml.room { xml.topic topic } end return do_request(request, .to_xml) end |