Floppy-amee 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,22 +53,22 @@ module AMEE
53
53
  data[:uid] = REXML::XPath.first(doc, "/Resources/DataCategoryResource/DataCategory/@uid").to_s
54
54
  data[:created] = DateTime.parse(REXML::XPath.first(doc, "/Resources/DataCategoryResource/DataCategory/@created").to_s)
55
55
  data[:modified] = DateTime.parse(REXML::XPath.first(doc, "/Resources/DataCategoryResource/DataCategory/@modified").to_s)
56
- data[:name] = REXML::XPath.first(doc, '/Resources/DataCategoryResource/DataCategory/Name').text
57
- data[:path] = REXML::XPath.first(doc, '/Resources/DataCategoryResource/Path').text || ""
56
+ data[:name] = REXML::XPath.first(doc, '/Resources/DataCategoryResource/DataCategory/?ame').text
57
+ data[:path] = REXML::XPath.first(doc, '/Resources/DataCategoryResource//?ath').text || ""
58
58
  data[:children] = []
59
- REXML::XPath.each(doc, '/Resources/DataCategoryResource/Children/DataCategories/DataCategory') do |child|
59
+ REXML::XPath.each(doc, '/Resources/DataCategoryResource//Children/DataCategories/DataCategory') do |child|
60
60
  category_data = {}
61
- category_data[:name] = child.elements['Name'].text
62
- category_data[:path] = child.elements['Path'].text
61
+ category_data[:name] = (child.elements['Name'] || child.elements['name']).text
62
+ category_data[:path] = (child.elements['Path'] || child.elements['path']).text
63
63
  category_data[:uid] = child.attributes['uid'].to_s
64
64
  data[:children] << category_data
65
65
  end
66
66
  data[:items] = []
67
- REXML::XPath.each(doc, '/Resources/DataCategoryResource/Children/DataItems/DataItem') do |item|
67
+ REXML::XPath.each(doc, '/Resources/DataCategoryResource//Children/DataItems/DataItem') do |item|
68
68
  item_data = {}
69
- item_data[:label] = item.elements['label'].text
70
- item_data[:path] = item.elements['path'].text
71
69
  item_data[:uid] = item.attributes['uid'].to_s
70
+ item_data[:label] = item.elements['label'].text
71
+ item_data[:path] = item.elements['path'] ? item.elements['path'].text : item_data[:uid]
72
72
  data[:items] << item_data
73
73
  end
74
74
  # Create object
@@ -59,15 +59,17 @@ module AMEE
59
59
  # Parse XML
60
60
  doc = REXML::Document.new(xml)
61
61
  data = {}
62
- data[:choice_name] = REXML::XPath.first(doc, "/Resources/DrillDownResource/Choices/Name").text
62
+ data[:choice_name] = REXML::XPath.first(doc, "/Resources/DrillDownResource/Choices/?ame").text
63
63
  choices = []
64
- REXML::XPath.each(doc, "/Resources/DrillDownResource/Choices/Choices/Choice") do |c|
65
- choices << c.elements['Value'].text
64
+ REXML::XPath.each(doc, "/Resources/DrillDownResource/Choices//Choice") do |c|
65
+ choices << (c.elements['Value'] || c.elements['value']).text
66
66
  end
67
67
  data[:choices] = choices
68
68
  selections = {}
69
69
  REXML::XPath.each(doc, "/Resources/DrillDownResource/Selections/Choice") do |c|
70
- selections[c.elements['Name'].text] = c.elements['Value'].text
70
+ name = (c.elements['Name'] || c.elements['name']).text
71
+ value = (c.elements['Value'] || c.elements['value']).text
72
+ selections[name] = value
71
73
  end
72
74
  data[:selections] = selections
73
75
  # Create object
@@ -198,15 +198,16 @@ module AMEE
198
198
  data = {}
199
199
  data[:profile_uid] = REXML::XPath.first(doc, "/Resources/ProfileCategoryResource/Profile/@uid").to_s
200
200
  data[:profile_date] = DateTime.strptime(REXML::XPath.first(doc, "/Resources/ProfileCategoryResource/ProfileDate").text, "%Y%m")
201
- data[:name] = REXML::XPath.first(doc, '/Resources/ProfileCategoryResource/DataCategory/Name').text
202
- data[:path] = REXML::XPath.first(doc, '/Resources/ProfileCategoryResource/Path').text || ""
201
+ data[:name] = REXML::XPath.first(doc, '/Resources/ProfileCategoryResource/DataCategory/?ame').text
202
+ data[:path] = REXML::XPath.first(doc, '/Resources/ProfileCategoryResource/Path | /Resources/ProfileCategoryResource/DataCategory/path').text || ""
203
+ data[:path] = "/#{data[:path]}" if data[:path].slice(0,1) != '/'
203
204
  data[:total_amount] = REXML::XPath.first(doc, '/Resources/ProfileCategoryResource/TotalAmountPerMonth').text.to_f rescue nil
204
205
  data[:total_amount_unit] = "kg/month"
205
206
  data[:children] = []
206
- REXML::XPath.each(doc, '/Resources/ProfileCategoryResource/Children/ProfileCategories/DataCategory') do |child|
207
+ REXML::XPath.each(doc, '/Resources/ProfileCategoryResource/Children/ProfileCategories/DataCategory | /Resources/ProfileCategoryResource/Children/DataCategories/DataCategory') do |child|
207
208
  category_data = {}
208
- category_data[:name] = child.elements['Name'].text
209
- category_data[:path] = child.elements['Path'].text
209
+ category_data[:name] = (child.elements['Name'] || child.elements['name']).text
210
+ category_data[:path] = (child.elements['Path'] || child.elements['path']).text
210
211
  category_data[:uid] = child.attributes['uid'].to_s
211
212
  data[:children] << category_data
212
213
  end
data/lib/amee/version.rb CHANGED
@@ -3,7 +3,7 @@ module AMEE
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 2
5
5
  MINOR = 0
6
- TINY = 1
6
+ TINY = 2
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Floppy-amee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-19 00:00:00 -08:00
12
+ date: 2009-02-20 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15