pachuber 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pachuber.rb +9 -1
- metadata +1 -1
data/lib/pachuber.rb
CHANGED
@@ -3,26 +3,34 @@ require 'httparty'
|
|
3
3
|
require 'eeml'
|
4
4
|
|
5
5
|
class Pachube
|
6
|
-
VERSION = '0.1.
|
6
|
+
VERSION = '0.1.1'
|
7
7
|
class PachubeError < RuntimeError; end
|
8
8
|
|
9
|
+
# Using HTTParty to hide the REST/HTTP interface
|
9
10
|
include HTTParty
|
11
|
+
|
12
|
+
# The Pachube API. Sure hope they don't change the URL.
|
10
13
|
base_uri 'http://www.pachube.com/api'
|
11
14
|
|
12
15
|
def initialize(key)
|
13
16
|
@key = key
|
14
17
|
end
|
15
18
|
|
19
|
+
# Fetches the Pachube feed
|
20
|
+
# Returns the latest datastream entry as XML
|
16
21
|
def get_xml(feed_url)
|
17
22
|
options = { :format => "xml", :headers => {"X-PachubeApiKey" => @key} }
|
18
23
|
self.class.get(feed_url, options)
|
19
24
|
end
|
20
25
|
|
26
|
+
# Fetches the Pachube feed
|
27
|
+
# Returns the latest datastream entry as EEML::Environment object
|
21
28
|
def get_eeml(feed_url)
|
22
29
|
xml = self.get_xml(feed_url)
|
23
30
|
eeml = EEML::Environment.from_eeml(xml)
|
24
31
|
end
|
25
32
|
|
33
|
+
# Posts an update to a specified Pachube feed
|
26
34
|
def update(feed_url, eeml)
|
27
35
|
options = { :headers => {"X-PachubeApiKey" => @key},
|
28
36
|
:body => eeml
|