Floppy-amee 0.4.4 → 0.4.5

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.
@@ -144,7 +144,12 @@ module AMEE
144
144
  def child(child_path)
145
145
  AMEE::Profile::Category.get(connection, "#{full_path}/#{child_path}")
146
146
  end
147
-
147
+
148
+ def item(dataItemLabel)
149
+ item = items.find{ |x| x[:dataItemLabel] == dataItemLabel}
150
+ item ? AMEE::Profile::Item.get(connection, "#{full_path}/#{item[:path]}") : nil
151
+ end
152
+
148
153
  end
149
154
  end
150
155
  end
@@ -29,7 +29,6 @@ module AMEE
29
29
  data[:values] = []
30
30
  doc['profileItem']['itemValues'].each do |item|
31
31
  value_data = {}
32
- value_data[:values] = {}
33
32
  item.each_pair do |key,value|
34
33
  case key
35
34
  when 'name', 'path', 'uid', 'value'
@@ -58,15 +57,12 @@ module AMEE
58
57
  data[:values] = []
59
58
  REXML::XPath.each(doc, '/Resources/ProfileItemResource/ProfileItem/ItemValues/ItemValue') do |item|
60
59
  value_data = {}
61
- value_data[:values] = {}
62
60
  item.elements.each do |element|
63
61
  key = element.name
64
62
  value = element.text
65
63
  case key
66
- when 'Name', 'Path'
64
+ when 'Name', 'Path', 'Value'
67
65
  value_data[key.downcase.to_sym] = value
68
- when 'Value'
69
- value_data[:value] = value
70
66
  end
71
67
  end
72
68
  value_data[:uid] = item.attributes['uid'].to_s
@@ -78,22 +74,6 @@ module AMEE
78
74
  raise AMEE::BadData.new("Couldn't load ProfileItem from XML data. Check that your URL is correct.")
79
75
  end
80
76
 
81
- def self.get_history(connection, path, num_months, end_date = Date.today)
82
- month = end_date.month
83
- year = end_date.year
84
- history = []
85
- num_months.times do
86
- date = Date.new(year, month)
87
- history << self.get(connection, path, date)
88
- month -= 1
89
- if (month == 0)
90
- year -= 1
91
- month = 12
92
- end
93
- end
94
- return history.reverse
95
- end
96
-
97
77
  def self.get(connection, path, for_date = Date.today)
98
78
  # Load data from path
99
79
  response = connection.get(path, :profileDate => for_date.strftime("%Y%m"))
@@ -107,8 +87,8 @@ module AMEE
107
87
  cat.connection = connection
108
88
  # Done
109
89
  return cat
110
- #rescue
111
- # raise AMEE::BadData.new("Couldn't load ProfileItem. Check that your URL is correct.")
90
+ rescue
91
+ raise AMEE::BadData.new("Couldn't load ProfileItem. Check that your URL is correct.")
112
92
  end
113
93
 
114
94
  def self.create(profile, data_item_uid, options = {})
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: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith