lib/ce-greenbutton.rb in ce-greenbutton-0.1.4 vs lib/ce-greenbutton.rb in ce-greenbutton-0.1.5
- old
+ new
@@ -100,11 +100,11 @@
end
resource_url += (resource_url.index('?').nil?? '?':'&')+ params.join('&') if
params.length > 0
data = open(resource_url,
'Authorization' => "Bearer #{access_token}")
- parse_data(access_token, data) #Return
+ parse_data(data) #Return
end
# Public: Downloads and parses the GreenButton data, hosted in a FTP server.
# The FTP host, user, password and path is configured through the config
# method.
@@ -130,17 +130,16 @@
parse_data(open(ftp_url))
end
# Parses the given greenbutton data to the corresponding ruby objects.
#
- # user_id - identifies the owner of the data.
# data - The source GreenButton xml data, can be string, or any stream returning
# from a call to open(uri)
#
# Returns the parsed array of gb_data_description
private
- def self.parse_data(user_id = nil, data)
+ def self.parse_data(data)
# get ApplicationInformation
app_info = GreenButton::Parser::GbApplicationInformation.
parse(open(@application_information_url,
'Authorization' => "Bearer #{@reg_access_token}"))
@@ -155,10 +154,10 @@
unsupported_kinds << usage_point.kind
else
gb_data_description = @interpreters[usage_point.kind]
.get_gb_data_description(entry, feed)
gb_data_description.custodian = app_info.data_custodian_id
- gb_data_description.user_id = user_id unless user_id.nil?
+ gb_data_description.user_id = /.*\/(\d+)\/UsagePoint\/\d+/.match(entry.self)[1]
gb << gb_data_description
end
end
end