summaryrefslogtreecommitdiff
path: root/extra/rest_client.rb
blob: 2c58d04419ee13f266ad84620c2e48800b53cab7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Oxidized
  class RestClient
    require 'net/http'
    require 'json'
    HOST = 'localhost'
    PORT = 8888

    class << self
      def next node, opt={}, host=HOST, port=PORT
        web = new host, port
        web.next node, opt
      end
    end

    def initialize host=HOST, port=PORT
      @web = Net::HTTP.new host, port
    end

    def next node, opt={}
      data = JSON.dump :node => node, :user => opt[:user], :msg => opt[:msg],  :from => opt[:from]
      @web.put '/nodes/next/' + node.to_s, data
    end

  end
end