ce-greenbutton 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/lib/ce-greenbutton/version.rb +1 -1
- data/lib/ce-greenbutton.rb +30 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99c0de9e3a288e6750ba5fe4886b27948954c56d
|
4
|
+
data.tar.gz: 6fc9f7a405b59b6dda74c499d8a175ea058d4dac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b4673328dbfd1a7c01e28db58397fefa2ff81ffea8b22ee5c7a2795314025ac81770d1dfe199c4300636acff23fa0c04840f6ccde882051e201d90cb42c61c9
|
7
|
+
data.tar.gz: 71699309ae8e2776c3b3a6c9b6363ecd1acfac31191f71a048f89ba996f4f813e9f39231ddc01a5c21f8f94ef48c51533b40eb80ae5c5c7e3d2fb0df489d7bef
|
data/lib/ce-greenbutton.rb
CHANGED
@@ -130,6 +130,36 @@ module GreenButton
|
|
130
130
|
parse_data(@ftp_user, open(ftp_url))
|
131
131
|
end
|
132
132
|
|
133
|
+
|
134
|
+
def self.parse_file_data(data)
|
135
|
+
feed = GreenButton::Parser.parse(data)
|
136
|
+
gb = []
|
137
|
+
unsupported_kinds = []
|
138
|
+
feed.entries.each_pair do |key, entry|
|
139
|
+
if entry.is_a? GreenButton::Parser::GbEntry
|
140
|
+
if entry.type == 'UsagePoint'
|
141
|
+
usage_point = entry.content.usage_point
|
142
|
+
if @interpreters[usage_point.kind].nil?
|
143
|
+
unsupported_kinds << usage_point.kind
|
144
|
+
else
|
145
|
+
gb_data_description = @interpreters[usage_point.kind]
|
146
|
+
.get_gb_data_description(entry, feed)
|
147
|
+
gb_data_description.custodian = nil
|
148
|
+
gb_data_description.user_id = nil
|
149
|
+
gb << gb_data_description
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
if gb.length == 0 and unsupported_kinds.length > 0
|
156
|
+
raise InvalidGbDataError, "Received unsupported GreenButton data #{unsupported_kinds.to_s}
|
157
|
+
Only Electricity (kind = 0) is supported."
|
158
|
+
end
|
159
|
+
gb
|
160
|
+
end
|
161
|
+
|
162
|
+
|
133
163
|
# Parses the given greenbutton data to the corresponding ruby objects.
|
134
164
|
#
|
135
165
|
# user_id - identifies the owner of the data.
|