pachuber 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +11 -0
- data/Rakefile +28 -0
- data/lib/pachuber.rb +41 -0
- data/lib/pachuber/version.rb +3 -0
- data/pachuber.gemspec +30 -0
- metadata +11 -9
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'bundler'
|
5
|
+
|
6
|
+
Bundler.setup
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
desc 'Default: run unit tests.'
|
10
|
+
task :default => :test
|
11
|
+
|
12
|
+
desc "Clean generated files"
|
13
|
+
task :clean do
|
14
|
+
#rm FileList['test/']
|
15
|
+
rm_rf 'pkg'
|
16
|
+
rm_rf 'rdoc'
|
17
|
+
end
|
18
|
+
|
19
|
+
RSpec::Core::RakeTask.new(:spec)
|
20
|
+
|
21
|
+
desc 'Generate documentation for the pachuber gem.'
|
22
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
23
|
+
rdoc.rdoc_dir = 'rdoc'
|
24
|
+
rdoc.title = 'pachuber'
|
25
|
+
rdoc.options << '--line-numbers'
|
26
|
+
rdoc.rdoc_files.include('README.textile')
|
27
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
28
|
+
end
|
data/lib/pachuber.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'httparty'
|
3
|
+
require 'eeml'
|
4
|
+
|
5
|
+
require 'pachuber/version'
|
6
|
+
|
7
|
+
class Pachube
|
8
|
+
class PachubeError < RuntimeError; end
|
9
|
+
|
10
|
+
# Using HTTParty to hide the REST/HTTP interface
|
11
|
+
include HTTParty
|
12
|
+
|
13
|
+
# The Pachube API. Sure hope they don't change the URL.
|
14
|
+
base_uri 'http://www.pachube.com/api'
|
15
|
+
|
16
|
+
def initialize(key)
|
17
|
+
@key = key
|
18
|
+
end
|
19
|
+
|
20
|
+
# Fetches the Pachube feed
|
21
|
+
# Returns the latest datastream entry as XML
|
22
|
+
def get_xml(feed_url)
|
23
|
+
options = { :format => "xml", :headers => {"X-PachubeApiKey" => @key} }
|
24
|
+
self.class.get(feed_url, options)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Fetches the Pachube feed
|
28
|
+
# Returns the latest datastream entry as EEML::Environment object
|
29
|
+
def get_eeml(feed_url)
|
30
|
+
xml = self.get_xml(feed_url)
|
31
|
+
eeml = EEML::Environment.from_eeml(xml)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Posts an update to a specified Pachube feed
|
35
|
+
def update(feed_url, eeml)
|
36
|
+
options = { :headers => {"X-PachubeApiKey" => @key},
|
37
|
+
:body => eeml
|
38
|
+
}
|
39
|
+
self.class.put(feed_url, options)
|
40
|
+
end
|
41
|
+
end
|
data/pachuber.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
require "pachuber"
|
5
|
+
require "pachuber/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "pachuber"
|
9
|
+
s.version = Pachuber::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = ["Kit Plummer"]
|
12
|
+
s.email = "kitplummer@dozersoftware.com"
|
13
|
+
s.homepage = "http://github.com/kitplummer/pachuber"
|
14
|
+
s.summary = "pachuber-#{Pachuber::VERSION}"
|
15
|
+
s.description = "%q{Just a simple Ruby library to provides Ruby-style abstraction around the HTTP API at Pachube.}"
|
16
|
+
|
17
|
+
s.rubygems_version = "1.3.7"
|
18
|
+
|
19
|
+
s.extra_rdoc_files = [ "README.textile" ]
|
20
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
21
|
+
s.require_path = "lib"
|
22
|
+
s.files = ["Rakefile", "pachuber.gemspec", "Gemfile", "README.textile"] +
|
23
|
+
Dir.glob("lib/**/*")
|
24
|
+
s.post_install_message = %Q{**************************************************
|
25
|
+
Thank you for installing #{s.summary}
|
26
|
+
Copyright 2010 - Dozer Software LLC.
|
27
|
+
**************************************************
|
28
|
+
}
|
29
|
+
|
30
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pachuber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kit Plummer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-25 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -28,18 +28,20 @@ extensions: []
|
|
28
28
|
extra_rdoc_files:
|
29
29
|
- README.textile
|
30
30
|
files:
|
31
|
+
- Rakefile
|
32
|
+
- pachuber.gemspec
|
33
|
+
- Gemfile
|
31
34
|
- README.textile
|
35
|
+
- lib/pachuber/version.rb
|
36
|
+
- lib/pachuber.rb
|
32
37
|
has_rdoc: true
|
33
38
|
homepage: http://github.com/kitplummer/pachuber
|
34
39
|
licenses: []
|
35
40
|
|
36
41
|
post_install_message: |
|
37
42
|
**************************************************
|
38
|
-
|
39
|
-
Thank you for installing pachuber-0.2.0
|
40
|
-
|
43
|
+
Thank you for installing pachuber-0.2.1
|
41
44
|
Copyright 2010 - Dozer Software LLC.
|
42
|
-
|
43
45
|
**************************************************
|
44
46
|
|
45
47
|
rdoc_options:
|
@@ -70,6 +72,6 @@ rubyforge_project:
|
|
70
72
|
rubygems_version: 1.3.7
|
71
73
|
signing_key:
|
72
74
|
specification_version: 3
|
73
|
-
summary: pachuber-0.2.
|
75
|
+
summary: pachuber-0.2.1
|
74
76
|
test_files: []
|
75
77
|
|