amon 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,7 +3,7 @@ Ruby Client for the AMEE AMON API
3
3
 
4
4
  This is a Ruby client library for the [AMEE](http://www.amee.com/) <abbr title="AMEE Monitoring Object Notation">AMON</abbr> <abbr title="Application Programming Interface">API</abbr>. _More details and links to be inserted once information about the API is publicly available_.
5
5
 
6
- This is version 0.4.3 and is built to support AMON V3: https://github.com/AMEE/amon
6
+ This is version 0.5.0 and is built to support AMON V3: https://github.com/AMEE/amon
7
7
 
8
8
  ## Installation ##
9
9
 
@@ -1,6 +1,8 @@
1
1
  module AMON
2
+
2
3
  # A measurement corresponding to a {Reading} of a {Device}
3
4
  class Measurement < DocumentPart
5
+
4
6
  # @return [String] The measurement's name
5
7
  field :type
6
8
  alias :name :type
@@ -9,17 +11,24 @@ module AMON
9
11
  field :value
10
12
 
11
13
  # @return [Time] The measurement's timestamp, if provided
12
- field :timestamp, :as => Time
14
+ field :timestamp, :as => Time
13
15
 
14
16
  # @return [Time] The measurement's start date, if provided
15
17
  field :start_date, :name => 'startDate', :as => Time
16
18
 
17
19
  # @return [Time] The measurement's end date, if provided
18
- field :end_date, :name => 'endDate', :as => Time
20
+ field :end_date, :name => 'endDate', :as => Time
19
21
 
20
22
  # @attr_reader [Device] device The device which took this measurement
21
23
  alias_method :device, :parent
22
24
 
25
+ # @return [Boolean] Is the measurement an aggregated (i.e. non-raw) value?
26
+ field :aggregated
27
+
28
+ # @return [Array] The "aggregation" array, including expectedPoints and
29
+ # aggregatedPoints.
30
+ field :aggregation
31
+
23
32
  # A measurement is instantaneous if it is given with a single timestamp. If, on the other hand,
24
33
  # start and end dates are provided, it is durational.
25
34
  # @return [Boolean]
@@ -52,5 +61,27 @@ module AMON
52
61
  start_date + (end_date - start_date) / 2
53
62
  end
54
63
  end
64
+
65
+ def aggregated_points
66
+ if aggregated
67
+ if aggregation.nil?
68
+ 0
69
+ else
70
+ aggregation['aggregatedPoints']
71
+ end
72
+ end
73
+ end
74
+
75
+ def expected_points
76
+ if aggregated
77
+ if aggregation.nil?
78
+ 0
79
+ else
80
+ aggregation['expectedPoints']
81
+ end
82
+ end
83
+ end
84
+
55
85
  end
56
- end
86
+
87
+ end
data/lib/amon/session.rb CHANGED
@@ -84,7 +84,9 @@ module AMON
84
84
  cache(:measurements, [device_id, start_date, end_date, raw]) do
85
85
  device = device(entity_id, device_id)
86
86
  measurements = get(
87
- "/entities/#{ URI.escape(entity_id) }/devices/#{ URI.escape(device.id) }/measurements?" +
87
+ "/entities/#{ URI.escape(entity_id) }/devices/#{ URI.escape(device.id) }/measurements" +
88
+ ";aggregation" +
89
+ "?" +
88
90
  "raw=" + raw.to_s + "&" +
89
91
  "startDate=" + start_date.utc.xmlschema + "&" +
90
92
  "endDate=" + end_date.utc.xmlschema
data/lib/amon/version.rb CHANGED
@@ -2,8 +2,8 @@ module AMON
2
2
  # Provides details about the version of the AMON library in use.
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 4
6
- TINY = 3
5
+ MINOR = 5
6
+ TINY = 0
7
7
 
8
8
  STRING = "#{MAJOR}.#{MINOR}.#{TINY}"
9
9
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 3
10
- version: 0.4.3
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - AMEE