smartermeter 0.1.0

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.
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0"?>
2
+ <feed xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
3
+ <% samples.each do |sample| %>
4
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
5
+ <id>https://www.google.com/powermeter/feeds<%= @config[:variable] %>/durMeasurement/<%= sample.utc_start_time.gsub(":", "_") %></id>
6
+ <category scheme="http://schemas.google.com/g/2005#kind"
7
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
8
+ <meter:subject>https://www.google.com/powermeter/feeds<%= @config[:variable] %></meter:subject>
9
+ <meter:startTime meter:uncertainty="1.000000"><%= sample.utc_start_time %></meter:startTime>
10
+ <meter:endTime meter:uncertainty="1.000000"><%= sample.utc_stop_time %></meter:endTime>
11
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
12
+ <%= sample.kwh %>
13
+ </meter:quantity>
14
+ </entry>
15
+ <% end %>
16
+ </feed>
@@ -0,0 +1,42 @@
1
+ require 'net/https'
2
+ require 'erb'
3
+
4
+ module SmarterMeter
5
+ module Transports
6
+ class GooglePowerMeter
7
+ def initialize(config)
8
+ @config = config
9
+ raise "The Google PowerMeter token must be configured" unless @config[:token]
10
+ raise "The Google PowerMeter variable must be configured" unless @config[:variable]
11
+ end
12
+
13
+ # Public: Uploads an array of Samples to Google PowerMeter
14
+ #
15
+ # samples - An array of samples to upload
16
+ #
17
+ # Returns true on success and false otherwise
18
+ def upload(samples)
19
+ url = URI.parse('https://www.google.com/powermeter/feeds/event')
20
+ http = Net::HTTP.new(url.host, url.port)
21
+ http.use_ssl = true
22
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
23
+ http.ca_file = File.join(File.dirname(__FILE__), "cacert.pem")
24
+ res, body = http.post(url.path, request_body(samples), {"Authorization" => 'AuthSub token="CMCc9puFFRDKivjpAhjgiZLuAg"', "Content-Type" => "application/atom+xml"})
25
+ case res
26
+ when Net::HTTPSuccess
27
+ true
28
+ else
29
+ false
30
+ end
31
+ end
32
+
33
+ # Creates the proper XML request to send to Google.
34
+ #
35
+ # Returns the proper atom/xml response to send to google
36
+ def request_body(samples)
37
+ template = ERB.new(File.read(File.join(File.dirname(__FILE__), "google_powermeter.erb")))
38
+ template.result(binding)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,8 @@
1
+ require 'smartermeter/sample'
2
+ require 'smartermeter/service'
3
+ require 'smartermeter/daemon'
4
+ require 'smartermeter/transports/google_powermeter'
5
+
6
+ module SmarterMeter
7
+ VERSION = "0.1.0"
8
+ end
@@ -0,0 +1,90 @@
1
+ ## This is the rakegem gemspec template. Make sure you read and understand
2
+ ## all of the comments. Some sections require modification, and others can
3
+ ## be deleted if you don't need them. Once you understand the contents of
4
+ ## this file, feel free to delete any comments that begin with two hash marks.
5
+ ## You can find comprehensive Gem::Specification documentation, at
6
+ ## http://docs.rubygems.org/read/chapter/20
7
+ Gem::Specification.new do |s|
8
+ s.specification_version = 2 if s.respond_to? :specification_version=
9
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.rubygems_version = '1.3.5'
11
+
12
+ ## Leave these as is they will be modified for you by the rake gemspec task.
13
+ ## If your rubyforge_project name is different, then edit it and comment out
14
+ ## the sub! line in the Rakefile
15
+ s.name = 'smartermeter'
16
+ s.version = '0.1.0'
17
+ s.date = '2011-01-08'
18
+ s.rubyforge_project = 'smartermeter'
19
+
20
+ ## Make sure your summary is short. The description may be as long
21
+ ## as you like.
22
+ s.summary = "Fetches smartmeter data from PG&E"
23
+ s.description = "Fetches smartmeter data from PG&E and can upload to Google PowerMeter"
24
+
25
+ ## List the primary authors. If there are a bunch of authors, it's probably
26
+ ## better to set the email to an email list or something. If you don't have
27
+ ## a custom homepage, consider using your GitHub URL or the like.
28
+ s.authors = ["Matt Colyer"]
29
+ s.email = 'matt.removethis@nospam.colyer.name'
30
+ s.homepage = 'http://github.com/mcolyer/smartermeter'
31
+
32
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
33
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
34
+ s.require_paths = %w[lib]
35
+
36
+ ## This sections is only necessary if you have C extensions.
37
+ #s.require_paths << 'ext'
38
+ #s.extensions = %w[ext/extconf.rb]
39
+
40
+ ## If your gem includes any executables, list them here.
41
+ s.executables = ["smartermeter"]
42
+ s.default_executable = 'smartermeter'
43
+
44
+ ## Specify any RDoc options here. You'll want to add your README and
45
+ ## LICENSE files to the extra_rdoc_files list.
46
+ #s.rdoc_options = ["--charset=UTF-8"]
47
+ #s.extra_rdoc_files = %w[README.md]
48
+
49
+ ## List your runtime dependencies here. Runtime dependencies are those
50
+ ## that are needed for an end user to actually USE your code.
51
+ s.add_dependency('mechanize', ["= 0.9.3"])
52
+ s.add_dependency('crypt', ["= 1.1.4"])
53
+
54
+ ## List your development dependencies here. Development dependencies are
55
+ ## those that are only needed during development
56
+ s.add_development_dependency('rawr', ["~> 1.4.5"])
57
+ s.add_development_dependency('rspec', ["~> 2.4.0"])
58
+
59
+ ## Leave this section as-is. It will be automatically generated from the
60
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
61
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
62
+ # = MANIFEST =
63
+ s.files = %w[
64
+ Gemfile
65
+ README.md
66
+ Rakefile
67
+ bin/smartermeter
68
+ build_configuration.rb
69
+ lib/smartermeter.rb
70
+ lib/smartermeter/daemon.rb
71
+ lib/smartermeter/main.rb
72
+ lib/smartermeter/sample.rb
73
+ lib/smartermeter/service.rb
74
+ lib/smartermeter/transports/cacert.pem
75
+ lib/smartermeter/transports/google_powermeter.erb
76
+ lib/smartermeter/transports/google_powermeter.rb
77
+ smartermeter.gemspec
78
+ specs/fixtures/data.csv
79
+ specs/fixtures/expected_google_request.xml
80
+ specs/sample_spec.rb
81
+ specs/service_spec.rb
82
+ specs/spec_helper.rb
83
+ specs/transports/google_powermeter_spec.rb
84
+ ]
85
+ # = MANIFEST =
86
+
87
+ ## Test files will be grabbed from the file list. Make sure the path glob
88
+ ## matches what you actually use.
89
+ s.test_files = s.files.select { |path| path =~ /^specs\/*_spec.rb/ }
90
+ end
@@ -0,0 +1,21 @@
1
+ "Name","DOE,JOHN "
2
+ "Address","1 MARKET ST, SAN FRANCSICO, CA 94110"
3
+ "Account Number",="12345678"
4
+ "Disclaimer","The information contained in this file is intended for the personal and confidential use of the recipient(s) named above. Any unauthorized use is prohibited."
5
+
6
+ "Title","Hourly Usage"
7
+ "Meter Number","Electric - 12345678"
8
+ "Selected Date","10/01/2009"
9
+ "Selected Period","Week"
10
+ "Primary Data Unit","kWh"
11
+ "Secondary Data Unit","-"
12
+
13
+ "","12:00 AM","1:00 AM","2:00 AM","3:00 AM","4:00 AM","5:00 AM","6:00 AM","7:00 AM","8:00 AM","9:00 AM","10:00 AM","11:00 AM","12:00 PM","1:00 PM","2:00 PM","3:00 PM","4:00 PM","5:00 PM","6:00 PM","7:00 PM","8:00 PM","9:00 PM","10:00 PM","11:00 PM"
14
+ "9/27/2009",".149",".205",".257",".131",".142",".136",".127",".137",".136",".134",".416","1.732","1.844",".190",".189",".182",".173","1.136","3.550","3.011","1.426",".508",".580",".316"
15
+ "9/28/2009",".142",".165",".140",".148",".157",".138",".140",".607",".709",".183",".131",".134",".144",".143",".135",".214",".179",".161",".165",".661",".461",".390",".467",".239"
16
+ "9/29/2009",".271",".124",".127",".122",".133",".131",".121",".149",".723",".409",".388",".317",".341",".335",".338",".341",".310",".298",".316","1.561",".601",".463",".494",".471"
17
+ "9/30/2009",".536",".224",".136",".131",".133",".128",".128",".104",".518",".706",".385",".320",".338",".373",".227",".097",".088",".097",".093",".099",".100",".090",".095",".092"
18
+ "10/01/2009",".097",".096",".094",".095",".082",".086",".094",".089",".080",".093",".074",".094",".087",".081",".096",".089",".080",".170",".143",".106",".096",".091",".099",".097"
19
+ "10/02/2009",".098",".095",".089",".083",".094",".095",".080",".088",".095",".073",".095",".094",".075",".094",".096",".075",".095",".097",".096",".098",".098",".096",".097",".086"
20
+ "10/03/2009",".093",".088",".097",".097",".094",".096",".092",".079",".094",".094",".095",".131",".151",".098",".083",".092",".097",".098",".092",".080",".095",".097",".097",".074"
21
+
@@ -0,0 +1,292 @@
1
+ <?xml version="1.0"?>
2
+ <feed xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
3
+
4
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
5
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
6
+ <category scheme="http://schemas.google.com/g/2005#kind"
7
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
8
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
9
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
10
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
11
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
12
+ 0.149
13
+ </meter:quantity>
14
+ </entry>
15
+
16
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
17
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
18
+ <category scheme="http://schemas.google.com/g/2005#kind"
19
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
20
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
21
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
22
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
23
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
24
+ 0.205
25
+ </meter:quantity>
26
+ </entry>
27
+
28
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
29
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
30
+ <category scheme="http://schemas.google.com/g/2005#kind"
31
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
32
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
33
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
34
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
35
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
36
+ 0.257
37
+ </meter:quantity>
38
+ </entry>
39
+
40
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
41
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
42
+ <category scheme="http://schemas.google.com/g/2005#kind"
43
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
44
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
45
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
46
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
47
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
48
+ 0.131
49
+ </meter:quantity>
50
+ </entry>
51
+
52
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
53
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
54
+ <category scheme="http://schemas.google.com/g/2005#kind"
55
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
56
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
57
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
58
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
59
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
60
+ 0.142
61
+ </meter:quantity>
62
+ </entry>
63
+
64
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
65
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
66
+ <category scheme="http://schemas.google.com/g/2005#kind"
67
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
68
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
69
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
70
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
71
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
72
+ 0.136
73
+ </meter:quantity>
74
+ </entry>
75
+
76
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
77
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
78
+ <category scheme="http://schemas.google.com/g/2005#kind"
79
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
80
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
81
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
82
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
83
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
84
+ 0.127
85
+ </meter:quantity>
86
+ </entry>
87
+
88
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
89
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
90
+ <category scheme="http://schemas.google.com/g/2005#kind"
91
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
92
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
93
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
94
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
95
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
96
+ 0.137
97
+ </meter:quantity>
98
+ </entry>
99
+
100
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
101
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
102
+ <category scheme="http://schemas.google.com/g/2005#kind"
103
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
104
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
105
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
106
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
107
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
108
+ 0.136
109
+ </meter:quantity>
110
+ </entry>
111
+
112
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
113
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
114
+ <category scheme="http://schemas.google.com/g/2005#kind"
115
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
116
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
117
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
118
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
119
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
120
+ 0.134
121
+ </meter:quantity>
122
+ </entry>
123
+
124
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
125
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
126
+ <category scheme="http://schemas.google.com/g/2005#kind"
127
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
128
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
129
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
130
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
131
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
132
+ 0.416
133
+ </meter:quantity>
134
+ </entry>
135
+
136
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
137
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
138
+ <category scheme="http://schemas.google.com/g/2005#kind"
139
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
140
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
141
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
142
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
143
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
144
+ 1.732
145
+ </meter:quantity>
146
+ </entry>
147
+
148
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
149
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
150
+ <category scheme="http://schemas.google.com/g/2005#kind"
151
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
152
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
153
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
154
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
155
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
156
+ 1.844
157
+ </meter:quantity>
158
+ </entry>
159
+
160
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
161
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
162
+ <category scheme="http://schemas.google.com/g/2005#kind"
163
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
164
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
165
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
166
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
167
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
168
+ 0.19
169
+ </meter:quantity>
170
+ </entry>
171
+
172
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
173
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
174
+ <category scheme="http://schemas.google.com/g/2005#kind"
175
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
176
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
177
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
178
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
179
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
180
+ 0.189
181
+ </meter:quantity>
182
+ </entry>
183
+
184
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
185
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
186
+ <category scheme="http://schemas.google.com/g/2005#kind"
187
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
188
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
189
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
190
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
191
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
192
+ 0.182
193
+ </meter:quantity>
194
+ </entry>
195
+
196
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
197
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
198
+ <category scheme="http://schemas.google.com/g/2005#kind"
199
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
200
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
201
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
202
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
203
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
204
+ 0.173
205
+ </meter:quantity>
206
+ </entry>
207
+
208
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
209
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
210
+ <category scheme="http://schemas.google.com/g/2005#kind"
211
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
212
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
213
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
214
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
215
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
216
+ 1.136
217
+ </meter:quantity>
218
+ </entry>
219
+
220
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
221
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
222
+ <category scheme="http://schemas.google.com/g/2005#kind"
223
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
224
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
225
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
226
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
227
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
228
+ 3.55
229
+ </meter:quantity>
230
+ </entry>
231
+
232
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
233
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
234
+ <category scheme="http://schemas.google.com/g/2005#kind"
235
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
236
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
237
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
238
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
239
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
240
+ 3.011
241
+ </meter:quantity>
242
+ </entry>
243
+
244
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
245
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
246
+ <category scheme="http://schemas.google.com/g/2005#kind"
247
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
248
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
249
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
250
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
251
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
252
+ 1.426
253
+ </meter:quantity>
254
+ </entry>
255
+
256
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
257
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
258
+ <category scheme="http://schemas.google.com/g/2005#kind"
259
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
260
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
261
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
262
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
263
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
264
+ 0.508
265
+ </meter:quantity>
266
+ </entry>
267
+
268
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
269
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
270
+ <category scheme="http://schemas.google.com/g/2005#kind"
271
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
272
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
273
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
274
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
275
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
276
+ 0.58
277
+ </meter:quantity>
278
+ </entry>
279
+
280
+ <entry xmlns="http://www.w3.org/2005/Atom" xmlns:meter="http://schemas.google.com/meter/2008">
281
+ <id>https://www.google.com/powermeter/feeds/path/durMeasurement/2009-09-27T07_00_00.000Z</id>
282
+ <category scheme="http://schemas.google.com/g/2005#kind"
283
+ term="http://schemas.google.com/meter/2008#durMeasurement"/>
284
+ <meter:subject>https://www.google.com/powermeter/feeds/path</meter:subject>
285
+ <meter:startTime meter:uncertainty="1.000000">2009-09-27T07:00:00.000Z</meter:startTime>
286
+ <meter:endTime meter:uncertainty="1.000000">2009-09-27T08:00:00.000Z</meter:endTime>
287
+ <meter:quantity meter:uncertainty="0.001000" meter:unit="kW h">
288
+ 0.316
289
+ </meter:quantity>
290
+ </entry>
291
+
292
+ </feed>
@@ -0,0 +1,18 @@
1
+ $:.unshift File.join(File.dirname(__FILE__))
2
+ require 'spec_helper'
3
+
4
+ describe SmarterMeter::Sample do
5
+ before(:all) do
6
+ @data = File.read(File.join($FIXTURES_DIR, 'data.csv'))
7
+ end
8
+
9
+ it "should be able to parse csv data returned by the api" do
10
+ date = Date.new(2009, 9, 30)
11
+ results = SmarterMeter::Sample.parse_csv(@data)
12
+
13
+ results.length.should > 0
14
+ results.keys.should include(date)
15
+ results[date].length.should == 24
16
+ results[date].each{|s| s.should be_kind_of(SmarterMeter::Sample)}
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ $:.unshift File.join(File.dirname(__FILE__))
2
+ require 'spec_helper'
3
+
4
+ describe SmarterMeter::Service do
5
+ before(:each) do
6
+ @subject = SmarterMeter::Service.new
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ Bundler.require(:default)
4
+ require 'rspec'
5
+
6
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
7
+ require 'smartermeter'
8
+
9
+ $FIXTURES_DIR = File.expand_path(File.join(File.dirname(__FILE__), "fixtures"))
@@ -0,0 +1,19 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..")
2
+ require 'spec_helper'
3
+
4
+ describe SmarterMeter::Transports::GooglePowerMeter do
5
+ before(:each) do
6
+ @subject = SmarterMeter::Transports::GooglePowerMeter.new(:token => "secret",
7
+ :variable => "/path")
8
+ data = File.read(File.join($FIXTURES_DIR, 'data.csv'))
9
+ @results = SmarterMeter::Sample.parse_csv(data)
10
+ end
11
+
12
+ it "can format a request for the API" do
13
+ fixture_file = File.join(File.dirname(__FILE__), "..", "fixtures", "expected_google_request.xml")
14
+ expected_result = File.read(fixture_file)
15
+
16
+ samples = @results.values.first
17
+ @subject.request_body(samples).should == expected_result
18
+ end
19
+ end