ce-greenbutton 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88077ada622c8e2f788d1a085ad2781bc7102241
4
- data.tar.gz: a220f3f112ea8430bb67d7ee46e19bc59f200553
3
+ metadata.gz: 99c0de9e3a288e6750ba5fe4886b27948954c56d
4
+ data.tar.gz: 6fc9f7a405b59b6dda74c499d8a175ea058d4dac
5
5
  SHA512:
6
- metadata.gz: 645b9bc44287d696b7f61a351c3148eeed1a6e8f7f42a517bb1aa807d88d10f78fad4c2aec5860a190121c414bd02c7dd44209daf3222986028e4f78787ce13a
7
- data.tar.gz: b2c6e89f3dd5d33273d1d109d05fe455c53ef33c0afde52586a1eedaa14e1af6e70d2d6fb29ae1ceb7b7cfa0cf9a6959c46eec09d38afd8a2e28b30634672670
6
+ metadata.gz: 3b4673328dbfd1a7c01e28db58397fefa2ff81ffea8b22ee5c7a2795314025ac81770d1dfe199c4300636acff23fa0c04840f6ccde882051e201d90cb42c61c9
7
+ data.tar.gz: 71699309ae8e2776c3b3a6c9b6363ecd1acfac31191f71a048f89ba996f4f813e9f39231ddc01a5c21f8f94ef48c51533b40eb80ae5c5c7e3d2fb0df489d7bef
@@ -1,3 +1,3 @@
1
1
  module GreenButton
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ce-greenbutton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ahmed.seddiq