pachuber 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -2,7 +2,7 @@ h1. First whack at a Ruby API for interacting with "Pachube":http://www.pachube.
2
2
 
3
3
  h2. Work in progress at this point
4
4
 
5
- Requires version 0.2.0 or greater of the eeml-simple EEML wrapper library. Thanks to James Smith for including my changes upstream.
5
+ Requires version 0.2.0 or greater of the eeml-simple EEML wrapper library (not the eeml gem). Thanks to James Smith for including my changes upstream.
6
6
 
7
7
  Take a peek at the test cases for examples of how to consume/contribute to Pachube in either EEML XML or EEML objects.
8
8
 
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pachuber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Kit Plummer
@@ -9,72 +15,61 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-01-10 00:00:00 -07:00
18
+ date: 2010-09-14 00:00:00 -07:00
13
19
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: httparty
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 0.4.5
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: eeml-simple
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 0.2.0
34
- version:
35
- description: Just a simple Ruby library to provides Ruby-style abstraction around the HTTP API at Pachube.
36
- email: kitplummer@gmail.com
20
+ dependencies: []
21
+
22
+ description: "%q{Just a simple Ruby library to provides Ruby-style abstraction around the HTTP API at Pachube.}"
23
+ email: kitplummer@dozersoftware.com
37
24
  executables: []
38
25
 
39
26
  extensions: []
40
27
 
41
- extra_rdoc_files: []
42
-
28
+ extra_rdoc_files:
29
+ - README.textile
43
30
  files:
44
- - Rakefile
45
31
  - README.textile
46
- - MIT-LICENSE
47
- - lib/pachuber.rb
48
- - resources/005.xsd
49
- - resources/key.rb
50
- - test/pachuber_test.rb
51
32
  has_rdoc: true
52
33
  homepage: http://github.com/kitplummer/pachuber
53
34
  licenses: []
54
35
 
55
- post_install_message:
56
- rdoc_options: []
36
+ post_install_message: |
37
+ **************************************************
38
+
39
+ Thank you for installing pachuber-0.2.0
40
+
41
+ Copyright 2010 - Dozer Software LLC.
42
+
43
+ **************************************************
57
44
 
45
+ rdoc_options:
46
+ - --charset=UTF-8
58
47
  require_paths:
59
48
  - lib
60
49
  required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
61
51
  requirements:
62
52
  - - ">="
63
53
  - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
64
57
  version: "0"
65
- version:
66
58
  required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
67
60
  requirements:
68
61
  - - ">="
69
62
  - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
70
66
  version: "0"
71
- version:
72
- requirements:
73
- - none
74
- rubyforge_project: pachuber
75
- rubygems_version: 1.3.5
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.3.7
76
71
  signing_key:
77
72
  specification_version: 3
78
- summary: Interact with the Pachube API via HTTParty.
73
+ summary: pachuber-0.2.0
79
74
  test_files: []
80
75
 
data/MIT-LICENSE DELETED
@@ -1,21 +0,0 @@
1
- Copyright (c) 2009 kitplummer@gmail.com
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
data/Rakefile DELETED
@@ -1,70 +0,0 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
- require 'rake/packagetask'
5
- require 'rake/gempackagetask'
6
-
7
- $:.unshift(File.dirname(__FILE__) + "/lib")
8
- require 'pachuber'
9
-
10
- PKG_NAME = 'pachuber'
11
- PKG_VERSION = Pachube::VERSION
12
- PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
13
-
14
- desc 'Default: run unit tests.'
15
- task :default => :test
16
-
17
- desc "Clean generated files"
18
- task :clean do
19
- #rm FileList['test/']
20
- rm_rf 'pkg'
21
- rm_rf 'rdoc'
22
- end
23
-
24
- desc 'Test the pachuber gem.'
25
- Rake::TestTask.new(:test) do |t|
26
- t.libs << 'lib'
27
- t.pattern = 'test/**/*_test.rb'
28
- t.verbose = true
29
- end
30
-
31
- desc 'Generate documentation for the pachuber gem.'
32
- Rake::RDocTask.new(:rdoc) do |rdoc|
33
- rdoc.rdoc_dir = 'rdoc'
34
- rdoc.title = 'pachuber'
35
- rdoc.options << '--line-numbers'
36
- rdoc.rdoc_files.include('README.textile')
37
- rdoc.rdoc_files.include('lib/**/*.rb')
38
- end
39
-
40
-
41
- # Create compressed packages
42
- spec = Gem::Specification.new do |s|
43
- s.platform = Gem::Platform::RUBY
44
- s.name = PKG_NAME
45
- s.summary = "Interact with the Pachube API via HTTParty."
46
- s.description = %q{Just a simple Ruby library to provides Ruby-style abstraction around the HTTP API at Pachube.}
47
- s.version = PKG_VERSION
48
-
49
- s.author = "Kit Plummer"
50
- s.email = "kitplummer@gmail.com"
51
- s.rubyforge_project = PKG_NAME
52
- s.homepage = "http://github.com/kitplummer/pachuber"
53
-
54
- s.has_rdoc = true
55
- s.requirements << 'none'
56
- s.require_path = 'lib'
57
- #s.autorequire = 'pachuber'
58
- s.add_dependency("httparty", ">= 0.4.5")
59
- s.add_dependency("eeml-simple", ">= 0.2.0")
60
- s.files = [ "Rakefile", "README.textile", "MIT-LICENSE" ]
61
- s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
62
- s.files = s.files + Dir.glob( "resources/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
63
- s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) || item.include?("\.png") }
64
- end
65
-
66
- Rake::GemPackageTask.new(spec) do |p|
67
- p.gem_spec = spec
68
- p.need_tar = false
69
- p.need_zip = true
70
- end
data/lib/pachuber.rb DELETED
@@ -1,40 +0,0 @@
1
- require 'rubygems'
2
- require 'httparty'
3
- require 'eeml'
4
-
5
- class Pachube
6
- VERSION = '0.1.1'
7
- class PachubeError < RuntimeError; end
8
-
9
- # Using HTTParty to hide the REST/HTTP interface
10
- include HTTParty
11
-
12
- # The Pachube API. Sure hope they don't change the URL.
13
- base_uri 'http://www.pachube.com/api'
14
-
15
- def initialize(key)
16
- @key = key
17
- end
18
-
19
- # Fetches the Pachube feed
20
- # Returns the latest datastream entry as XML
21
- def get_xml(feed_url)
22
- options = { :format => "xml", :headers => {"X-PachubeApiKey" => @key} }
23
- self.class.get(feed_url, options)
24
- end
25
-
26
- # Fetches the Pachube feed
27
- # Returns the latest datastream entry as EEML::Environment object
28
- def get_eeml(feed_url)
29
- xml = self.get_xml(feed_url)
30
- eeml = EEML::Environment.from_eeml(xml)
31
- end
32
-
33
- # Posts an update to a specified Pachube feed
34
- def update(feed_url, eeml)
35
- options = { :headers => {"X-PachubeApiKey" => @key},
36
- :body => eeml
37
- }
38
- self.class.put(feed_url, options)
39
- end
40
- end
data/resources/005.xsd DELETED
@@ -1,134 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <xsd:schema xmlns="http://www.eeml.org/xsd/005" elementFormDefault="qualified" targetNamespace="http://www.eeml.org/xsd/005" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3
- <xsd:element name="eeml">
4
- <xsd:complexType>
5
- <xsd:choice>
6
- <xsd:element maxOccurs="unbounded" name="environment">
7
- <xsd:complexType>
8
- <xsd:sequence>
9
- <xsd:element minOccurs="0" name="title" type="xsd:string" />
10
- <xsd:element minOccurs="0" name="feed" type="xsd:anyURI" />
11
- <xsd:element minOccurs="0" name="status">
12
- <xsd:simpleType>
13
- <xsd:restriction base="xsd:string">
14
- <xsd:enumeration value="frozen" />
15
- <xsd:enumeration value="live" />
16
- </xsd:restriction>
17
- </xsd:simpleType>
18
- </xsd:element>
19
- <xsd:element minOccurs="0" name="description" type="xsd:string" />
20
- <xsd:element minOccurs="0" name="icon" type="xsd:anyURI" />
21
- <xsd:element minOccurs="0" name="website" type="xsd:anyURI" />
22
- <xsd:element minOccurs="0" name="email" type="xsd:string" />
23
- <xsd:element minOccurs="0" name="location">
24
- <xsd:complexType>
25
- <xsd:sequence>
26
- <xsd:element minOccurs="0" name="name" type="xsd:string" />
27
- <xsd:element name="lat">
28
- <xsd:simpleType>
29
- <xsd:restriction base="xsd:double">
30
- <xsd:minInclusive value="-90" />
31
- <xsd:maxInclusive value="90" />
32
- </xsd:restriction>
33
- </xsd:simpleType>
34
- </xsd:element>
35
- <xsd:element name="lon">
36
- <xsd:simpleType>
37
- <xsd:restriction base="xsd:double">
38
- <xsd:minInclusive value="-180" />
39
- <xsd:maxInclusive value="180" />
40
- </xsd:restriction>
41
- </xsd:simpleType>
42
- </xsd:element>
43
- <xsd:element minOccurs="0" maxOccurs="1" name="ele" type="xsd:double" />
44
- </xsd:sequence>
45
- <xsd:attribute name="exposure" use="optional">
46
- <xsd:simpleType>
47
- <xsd:restriction base="xsd:string">
48
- <xsd:enumeration value="indoor" />
49
- <xsd:enumeration value="outdoor" />
50
- </xsd:restriction>
51
- </xsd:simpleType>
52
- </xsd:attribute>
53
- <xsd:attribute name="domain" use="required">
54
- <xsd:simpleType>
55
- <xsd:restriction base="xsd:string">
56
- <xsd:enumeration value="physical" />
57
- <xsd:enumeration value="virtual" />
58
- </xsd:restriction>
59
- </xsd:simpleType>
60
- </xsd:attribute>
61
- <xsd:attribute name="disposition" use="optional">
62
- <xsd:simpleType>
63
- <xsd:restriction base="xsd:string">
64
- <xsd:enumeration value="fixed" />
65
- <xsd:enumeration value="mobile" />
66
- </xsd:restriction>
67
- </xsd:simpleType>
68
- </xsd:attribute>
69
- </xsd:complexType>
70
- </xsd:element>
71
- <xsd:element minOccurs="1" maxOccurs="unbounded" name="data">
72
- <xsd:complexType>
73
- <xsd:sequence>
74
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="tag" type="xsd:string" />
75
- <xsd:element name="value">
76
- <xsd:complexType>
77
- <xsd:simpleContent>
78
- <xsd:extension base="xsd:string">
79
- <xsd:attribute name="minValue" type="xsd:string" use="optional" />
80
- <xsd:attribute name="maxValue" type="xsd:string" use="optional" />
81
- </xsd:extension>
82
- </xsd:simpleContent>
83
- </xsd:complexType>
84
- </xsd:element>
85
- <xsd:element minOccurs="0" maxOccurs="1" name="unit">
86
- <xsd:complexType>
87
- <xsd:simpleContent>
88
- <xsd:extension base="xsd:string">
89
- <xsd:attribute name="symbol" type="xsd:string" use="optional">
90
- </xsd:attribute>
91
- <xsd:attribute name="type" use="optional">
92
- <xsd:simpleType>
93
- <xsd:restriction base="xsd:string">
94
- <xsd:enumeration value="basicSI" />
95
- <xsd:enumeration value="derivedSI" />
96
- <xsd:enumeration value="conversionBasedUnits" />
97
- <xsd:enumeration value="derivedUnits" />
98
- <xsd:enumeration value="contextDependentUnits" />
99
- </xsd:restriction>
100
- </xsd:simpleType>
101
- </xsd:attribute>
102
- </xsd:extension>
103
- </xsd:simpleContent>
104
- </xsd:complexType>
105
- </xsd:element>
106
- </xsd:sequence>
107
- <xsd:attribute name="id" type="xsd:nonNegativeInteger" use="required" />
108
- </xsd:complexType>
109
- </xsd:element>
110
- </xsd:sequence>
111
- <xsd:attribute name="updated" use="optional">
112
- <xsd:simpleType>
113
- <xsd:restriction base="xsd:dateTime" />
114
- </xsd:simpleType>
115
- </xsd:attribute>
116
- <xsd:attribute fixed="http://www.haque.co.uk" name="creator" use="optional">
117
- <xsd:simpleType>
118
- <xsd:restriction base="xsd:string" />
119
- </xsd:simpleType>
120
- </xsd:attribute>
121
- <xsd:attribute name="id" type="xsd:nonNegativeInteger" use="optional" />
122
- </xsd:complexType>
123
- </xsd:element>
124
- </xsd:choice>
125
- <xsd:attribute name="version" use="optional">
126
- <xsd:simpleType>
127
- <xsd:restriction base="xsd:positiveInteger">
128
- <xsd:enumeration value="5" />
129
- </xsd:restriction>
130
- </xsd:simpleType>
131
- </xsd:attribute>
132
- </xsd:complexType>
133
- </xsd:element>
134
- </xsd:schema>
data/resources/key.rb DELETED
@@ -1,3 +0,0 @@
1
- def pachube_api_key
2
- 'c2c52190262b5a066ed86fc4e8f57071248a2f66d73c98b87d109469b07144eb'
3
- end
@@ -1,35 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'nokogiri'
4
-
5
- require File.join(File.dirname(__FILE__), '../lib/pachuber.rb')
6
- # The pachube_api_key needs to be your Pachube API key.
7
- # I happen to store mine in a key.rb file in resources/.
8
- require File.join(File.dirname(__FILE__), '../resources/key.rb')
9
- class PachubeTest < Test::Unit::TestCase
10
-
11
- def test_pachube_get_xml
12
- pach = Pachube.new(pachube_api_key)
13
- xml = pach.get_xml("/504.xml")
14
- assert xml
15
- assert_equal "Pachube Office environment",
16
- Nokogiri::XML.parse(xml).css('title').text.to_s
17
- end
18
-
19
- def test_pachube_get_eeml
20
- pach = Pachube.new(pachube_api_key)
21
- eeml = pach.get_eeml("/504.xml")
22
- assert eeml
23
- assert_equal "EEML::Environment", eeml.class.name
24
- assert_equal "office", eeml.location.name
25
- end
26
-
27
- def test_pachube_update_post
28
- env = EEML::Environment.new
29
- env << EEML::Data.new(42, :id => "ABC123")
30
- pach = Pachube.new(pachube_api_key)
31
- resp = pach.update("/4078.xml", env.to_eeml)
32
- assert_equal 200, resp.code
33
- end
34
-
35
- end