From 6ab62bea628255800b1bf63b5d1b1c35e96ad969 Mon Sep 17 00:00:00 2001 From: NansWattics Date: Wed, 30 Aug 2017 10:07:16 +0100 Subject: [PATCH 1/3] Add the method to load xml from string --- lib/greenbutton.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/greenbutton.rb b/lib/greenbutton.rb index 2ea8254..4ac4ffe 100644 --- a/lib/greenbutton.rb +++ b/lib/greenbutton.rb @@ -18,7 +18,12 @@ def self.load_xml_from_file(path) xml_file.remove_namespaces! Parser.new(xml_file) end - + + def self.load_xml_from_string(string) + xml_file = Nokogiri::XML.parse(string) + xml_file.remove_namespaces! + Parser.new(xml_file) + end class Parser attr_accessor :doc, :usage_points From 3ce983b709575476b3948fe93e267d2868adf836 Mon Sep 17 00:00:00 2001 From: NansWattics Date: Wed, 30 Aug 2017 10:10:00 +0100 Subject: [PATCH 2/3] Update readme.md with the documentation for load_xml_from_string --- Readme.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Readme.md b/Readme.md index aef829e..32156cc 100644 --- a/Readme.md +++ b/Readme.md @@ -39,6 +39,9 @@ gb = GreenButton.load_xml_from_file('PATH/TO/FILE.XML') # To load from URL: gb = GreenButton.load_xml_from_web('https://services.greenbuttondata.org/DataCustodian/espi/1_1/resource/Batch/RetailCustomer/3/UsagePoint') + +# To load from string: +gb = GreenButton.load_xml_from_string(xml_string) ``` This code will load the Green Button XML from the given file or URL and parse it into a series of Ruby objects representing the data contained in the file. From d50f3ba3a7b126e328f217a3f925fe0e1dca8513 Mon Sep 17 00:00:00 2001 From: NansWattics Date: Thu, 19 Oct 2017 16:15:29 +0100 Subject: [PATCH 3/3] Remove Pry --- lib/greenbutton/gb_classes.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/greenbutton/gb_classes.rb b/lib/greenbutton/gb_classes.rb index edf10c4..b4c6d65 100644 --- a/lib/greenbutton/gb_classes.rb +++ b/lib/greenbutton/gb_classes.rb @@ -1,7 +1,6 @@ module GreenButtonClasses require_relative 'helpers.rb' require 'nokogiri' - require 'pry' Rule = Helper::Rule RULES = {