amee 2.0.25 → 2.0.26

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -12,11 +12,12 @@ Documentation: http://docs.github.com/Floppy/amee-ruby
12
12
 
13
13
  == INSTALLATION
14
14
 
15
- 1) Enable gems from github, if you haven't already done so (rubygems >= 1.2):
16
- > sudo gem sources -a http://gems.github.com
15
+ 1) Enable gems from gemcutter, if you haven't already done so:
16
+ > sudo gem install gemcutter
17
+ > sudo gem tumble
17
18
 
18
19
  2) Install gem
19
- > sudo gem install Floppy-amee
20
+ > sudo gem install amee
20
21
 
21
22
  == IMPORTANT CHANGES in 2.0.25
22
23
 
@@ -59,7 +60,7 @@ This gem can also be used as a Rails plugin. You can either extract it into
59
60
  vendor/plugins, or use the new-style config.gem command in environment.rb. For
60
61
  example:
61
62
 
62
- config.gem "Floppy-amee", :lib => "amee", :source => "http://gems.github.com", :version => '>= 0.3.0'
63
+ config.gem "amee", :version => '>= 2.0.26'
63
64
 
64
65
  If you copy amee.example.yml from the gem source directory to amee.yml in your
65
66
  app's config directory, a persistent AMEE connection will be available from
@@ -103,4 +104,4 @@ ones are:
103
104
 
104
105
  3) total_amount_per_month functions have been replaced with total_amount. There are also
105
106
  total_amount_unit and total_amount_per_unit functions which give the units that the total
106
- amount is in.
107
+ amount is in.
@@ -7,11 +7,13 @@ module AMEE
7
7
  def initialize(data = {})
8
8
  @children = data ? data[:children] : []
9
9
  @items = data ? data[:items] : []
10
+ @pager = data ? data[:pager] : nil
10
11
  super
11
12
  end
12
13
 
13
14
  attr_reader :children
14
15
  attr_reader :items
16
+ attr_reader :pager
15
17
 
16
18
  def self.from_json(json)
17
19
  # Parse json
@@ -23,6 +25,7 @@ module AMEE
23
25
  data[:name] = doc['dataCategory']['name']
24
26
  data[:path] = doc['path']
25
27
  data[:children] = []
28
+ data[:pager] = AMEE::Pager.from_json(doc['children']['pager'])
26
29
  doc['children']['dataCategories'].each do |child|
27
30
  category_data = {}
28
31
  category_data[:name] = child['name']
@@ -55,6 +58,7 @@ module AMEE
55
58
  data[:modified] = DateTime.parse(REXML::XPath.first(doc, "/Resources/DataCategoryResource/DataCategory/@modified").to_s)
56
59
  data[:name] = REXML::XPath.first(doc, '/Resources/DataCategoryResource/DataCategory/?ame').text
57
60
  data[:path] = REXML::XPath.first(doc, '/Resources/DataCategoryResource//?ath').text || ""
61
+ data[:pager] = AMEE::Pager.from_xml(REXML::XPath.first(doc, '//Pager'))
58
62
  data[:children] = []
59
63
  REXML::XPath.each(doc, '/Resources/DataCategoryResource//Children/DataCategories/DataCategory') do |child|
60
64
  category_data = {}
data/lib/amee/pager.rb CHANGED
@@ -28,6 +28,7 @@ module AMEE
28
28
  attr_reader :items_found
29
29
 
30
30
  def self.from_xml(node)
31
+ return nil if node.nil? || node.elements.empty?
31
32
  return Pager.new({:start => node.elements["Start"].text.to_i,
32
33
  :from => node.elements["From"].text.to_i,
33
34
  :to => node.elements["To"].text.to_i,
@@ -42,6 +43,7 @@ module AMEE
42
43
  end
43
44
 
44
45
  def self.from_json(node)
46
+ return nil if node.nil? || node.empty?
45
47
  return Pager.new({:start => node["start"],
46
48
  :from => node["from"],
47
49
  :to => node["to"],
@@ -56,4 +58,4 @@ module AMEE
56
58
  end
57
59
 
58
60
  end
59
- end
61
+ end
@@ -11,6 +11,7 @@ module AMEE
11
11
  @total_amount_unit = data[:total_amount_unit]
12
12
  @start_date = data[:start_date]
13
13
  @end_date = data[:end_date]
14
+ @pager = data[:pager]
14
15
  super
15
16
  end
16
17
 
@@ -18,6 +19,7 @@ module AMEE
18
19
  attr_reader :items
19
20
  attr_reader :total_amount
20
21
  attr_reader :total_amount_unit
22
+ attr_reader :pager
21
23
 
22
24
  def start_date
23
25
  @start_date || profile_date
@@ -109,6 +111,7 @@ module AMEE
109
111
  data[:path] = doc['path']
110
112
  data[:total_amount] = doc['totalAmountPerMonth']
111
113
  data[:total_amount_unit] = "kg/month"
114
+ data[:pager] = AMEE::Pager.from_json(doc['children']['pager']) rescue nil
112
115
  data[:children] = []
113
116
  if doc['children'] && doc['children']['dataCategories']
114
117
  doc['children']['dataCategories'].each do |child|
@@ -139,6 +142,7 @@ module AMEE
139
142
  data[:path] = doc['path']
140
143
  data[:total_amount] = doc['totalAmount']['value'].to_f rescue nil
141
144
  data[:total_amount_unit] = doc['totalAmount']['unit'] rescue nil
145
+ data[:pager] = AMEE::Pager.from_json(doc['pager']) rescue nil
142
146
  data[:children] = []
143
147
  if doc['profileCategories']
144
148
  doc['profileCategories'].each do |child|
@@ -238,6 +242,7 @@ module AMEE
238
242
  data[:path] = "/#{data[:path]}" if data[:path].slice(0,1) != '/'
239
243
  data[:total_amount] = REXML::XPath.first(doc, '/Resources/ProfileCategoryResource/TotalAmountPerMonth').text.to_f rescue nil
240
244
  data[:total_amount_unit] = "kg/month"
245
+ data[:pager] = AMEE::Pager.from_xml(REXML::XPath.first(doc, '//Pager'))
241
246
  data[:children] = []
242
247
  REXML::XPath.each(doc, '/Resources/ProfileCategoryResource/Children/ProfileCategories/DataCategory | /Resources/ProfileCategoryResource/Children/DataCategories/DataCategory') do |child|
243
248
  category_data = {}
@@ -318,6 +323,7 @@ module AMEE
318
323
  data[:path] = REXML::XPath.first(doc, '/Resources/ProfileCategoryResource/Path').text || ""
319
324
  data[:total_amount] = REXML::XPath.first(doc, '/Resources/ProfileCategoryResource/TotalAmount').text.to_f rescue nil
320
325
  data[:total_amount_unit] = REXML::XPath.first(doc, '/Resources/ProfileCategoryResource/TotalAmount/@unit').to_s rescue nil
326
+ data[:pager] = AMEE::Pager.from_xml(REXML::XPath.first(doc, '//Pager'))
321
327
  data[:children] = []
322
328
  REXML::XPath.each(doc, '/Resources/ProfileCategoryResource/ProfileCategories/DataCategory') do |child|
323
329
  category_data = {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.25
4
+ version: 2.0.26
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-10-01 00:00:00 +01:00
12
+ date: 2009-10-08 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency