xively-rb 0.2.09

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/.gitignore +13 -0
  2. data/.rbenv-version +1 -0
  3. data/.rspec +2 -0
  4. data/.rvmrc +1 -0
  5. data/.travis.yml +7 -0
  6. data/CHANGELOG.md +91 -0
  7. data/CONTRIBUTING.md +95 -0
  8. data/Gemfile +15 -0
  9. data/LICENSE.md +13 -0
  10. data/README.md +10 -0
  11. data/Rakefile +25 -0
  12. data/ci/build_hudson.sh +24 -0
  13. data/init.rb +2 -0
  14. data/lib/xively-rb.rb +44 -0
  15. data/lib/xively-rb/array_extensions.rb +6 -0
  16. data/lib/xively-rb/base.rb +52 -0
  17. data/lib/xively-rb/base/instance_methods.rb +28 -0
  18. data/lib/xively-rb/client.rb +43 -0
  19. data/lib/xively-rb/datapoint.rb +72 -0
  20. data/lib/xively-rb/datastream.rb +127 -0
  21. data/lib/xively-rb/exceptions.rb +5 -0
  22. data/lib/xively-rb/feed.rb +109 -0
  23. data/lib/xively-rb/hash_extensions.rb +16 -0
  24. data/lib/xively-rb/helpers.rb +41 -0
  25. data/lib/xively-rb/key.rb +99 -0
  26. data/lib/xively-rb/nil_content.rb +15 -0
  27. data/lib/xively-rb/object_extensions.rb +6 -0
  28. data/lib/xively-rb/parsers/csv/datastream_defaults.rb +50 -0
  29. data/lib/xively-rb/parsers/csv/feed_defaults.rb +97 -0
  30. data/lib/xively-rb/parsers/defaults.rb +15 -0
  31. data/lib/xively-rb/parsers/json/datapoint_defaults.rb +16 -0
  32. data/lib/xively-rb/parsers/json/datastream_defaults.rb +58 -0
  33. data/lib/xively-rb/parsers/json/feed_defaults.rb +114 -0
  34. data/lib/xively-rb/parsers/json/key_defaults.rb +20 -0
  35. data/lib/xively-rb/parsers/json/search_result_defaults.rb +24 -0
  36. data/lib/xively-rb/parsers/json/trigger_defaults.rb +16 -0
  37. data/lib/xively-rb/parsers/xml/datapoint_defaults.rb +27 -0
  38. data/lib/xively-rb/parsers/xml/datastream_defaults.rb +53 -0
  39. data/lib/xively-rb/parsers/xml/errors.rb +7 -0
  40. data/lib/xively-rb/parsers/xml/feed_defaults.rb +83 -0
  41. data/lib/xively-rb/parsers/xml/helpers.rb +116 -0
  42. data/lib/xively-rb/parsers/xml/key_defaults.rb +46 -0
  43. data/lib/xively-rb/parsers/xml/trigger_defaults.rb +28 -0
  44. data/lib/xively-rb/permission.rb +67 -0
  45. data/lib/xively-rb/resource.rb +43 -0
  46. data/lib/xively-rb/search_result.rb +68 -0
  47. data/lib/xively-rb/string_extensions.rb +6 -0
  48. data/lib/xively-rb/templates/csv/datapoint_defaults.rb +22 -0
  49. data/lib/xively-rb/templates/csv/datastream_defaults.rb +43 -0
  50. data/lib/xively-rb/templates/csv/feed_defaults.rb +47 -0
  51. data/lib/xively-rb/templates/defaults.rb +14 -0
  52. data/lib/xively-rb/templates/json/datapoint_defaults.rb +15 -0
  53. data/lib/xively-rb/templates/json/datastream_defaults.rb +61 -0
  54. data/lib/xively-rb/templates/json/feed_defaults.rb +90 -0
  55. data/lib/xively-rb/templates/json/key_defaults.rb +39 -0
  56. data/lib/xively-rb/templates/json/search_result_defaults.rb +42 -0
  57. data/lib/xively-rb/templates/json/trigger_defaults.rb +21 -0
  58. data/lib/xively-rb/templates/xml/datapoint_defaults.rb +25 -0
  59. data/lib/xively-rb/templates/xml/datastream_defaults.rb +66 -0
  60. data/lib/xively-rb/templates/xml/feed_defaults.rb +112 -0
  61. data/lib/xively-rb/templates/xml/search_result_defaults.rb +118 -0
  62. data/lib/xively-rb/templates/xml_headers.rb +17 -0
  63. data/lib/xively-rb/trigger.rb +66 -0
  64. data/lib/xively-rb/validations.rb +9 -0
  65. data/lib/xively-rb/version.rb +3 -0
  66. data/spec/fixtures/models.rb +81 -0
  67. data/spec/spec_helper.rb +29 -0
  68. data/spec/support/contain_datapoint_eeml_matcher.rb +16 -0
  69. data/spec/support/contain_datastream_eeml_matcher.rb +60 -0
  70. data/spec/support/contain_feed_eeml_matcher.rb +98 -0
  71. data/spec/support/datapoint_helper.rb +53 -0
  72. data/spec/support/datastream_helper.rb +324 -0
  73. data/spec/support/describe_eeml_matcher.rb +23 -0
  74. data/spec/support/feed_helper.rb +783 -0
  75. data/spec/support/fully_represent_datapoint_matcher.rb +30 -0
  76. data/spec/support/fully_represent_datastream_matcher.rb +96 -0
  77. data/spec/support/fully_represent_feed_matcher.rb +234 -0
  78. data/spec/support/fully_represent_key_matcher.rb +74 -0
  79. data/spec/support/fully_represent_search_result_matcher.rb +67 -0
  80. data/spec/support/fully_represent_trigger_matcher.rb +29 -0
  81. data/spec/support/key_helper.rb +74 -0
  82. data/spec/support/search_result_helper.rb +252 -0
  83. data/spec/support/trigger_helper.rb +51 -0
  84. data/spec/xively-rb/array_extensions_spec.rb +9 -0
  85. data/spec/xively-rb/base/instance_methods_spec.rb +109 -0
  86. data/spec/xively-rb/base_spec.rb +56 -0
  87. data/spec/xively-rb/client_spec.rb +51 -0
  88. data/spec/xively-rb/datapoint_spec.rb +187 -0
  89. data/spec/xively-rb/datastream_spec.rb +344 -0
  90. data/spec/xively-rb/feed_spec.rb +341 -0
  91. data/spec/xively-rb/hash_extensions_spec.rb +20 -0
  92. data/spec/xively-rb/helpers_spec.rb +56 -0
  93. data/spec/xively-rb/key_spec.rb +198 -0
  94. data/spec/xively-rb/parsers/csv/datastream_defaults_spec.rb +110 -0
  95. data/spec/xively-rb/parsers/csv/feed_defaults_spec.rb +234 -0
  96. data/spec/xively-rb/parsers/json/datapoint_defaults_spec.rb +21 -0
  97. data/spec/xively-rb/parsers/json/datastream_defaults_spec.rb +105 -0
  98. data/spec/xively-rb/parsers/json/feed_defaults_spec.rb +45 -0
  99. data/spec/xively-rb/parsers/json/key_defaults_spec.rb +14 -0
  100. data/spec/xively-rb/parsers/json/search_result_defaults_spec.rb +18 -0
  101. data/spec/xively-rb/parsers/json/trigger_defaults_spec.rb +22 -0
  102. data/spec/xively-rb/parsers/xml/datapoint_defaults_spec.rb +19 -0
  103. data/spec/xively-rb/parsers/xml/datastream_defaults_spec.rb +148 -0
  104. data/spec/xively-rb/parsers/xml/feed_defaults_spec.rb +254 -0
  105. data/spec/xively-rb/parsers/xml/key_defaults_spec.rb +22 -0
  106. data/spec/xively-rb/parsers/xml/trigger_defaults_spec.rb +22 -0
  107. data/spec/xively-rb/search_result_spec.rb +257 -0
  108. data/spec/xively-rb/string_extensions_spec.rb +12 -0
  109. data/spec/xively-rb/templates/csv/datapoint_defaults_spec.rb +41 -0
  110. data/spec/xively-rb/templates/csv/datastream_defaults_spec.rb +131 -0
  111. data/spec/xively-rb/templates/csv/feed_defaults_spec.rb +78 -0
  112. data/spec/xively-rb/templates/json/datapoint_defaults_spec.rb +14 -0
  113. data/spec/xively-rb/templates/json/datastream_defaults_spec.rb +170 -0
  114. data/spec/xively-rb/templates/json/feed_defaults_spec.rb +399 -0
  115. data/spec/xively-rb/templates/json/key_defaults_spec.rb +29 -0
  116. data/spec/xively-rb/templates/json/search_result_defaults_spec.rb +37 -0
  117. data/spec/xively-rb/templates/json/trigger_defaults_spec.rb +19 -0
  118. data/spec/xively-rb/templates/xml/datapoint_defaults_spec.rb +14 -0
  119. data/spec/xively-rb/templates/xml/datastream_defaults_spec.rb +113 -0
  120. data/spec/xively-rb/templates/xml/feed_defaults_spec.rb +131 -0
  121. data/spec/xively-rb/templates/xml/search_result_defaults_spec.rb +44 -0
  122. data/spec/xively-rb/trigger_spec.rb +157 -0
  123. data/xively-rb.gemspec +41 -0
  124. metadata +333 -0
@@ -0,0 +1,23 @@
1
+ RSpec::Matchers.define :describe_eeml_for_version do |eeml_version|
2
+ match do |xml|
3
+ attrs = xml.root
4
+ case eeml_version
5
+ when "0.5.1"
6
+ attrs["version"].should == eeml_version
7
+ attrs.namespace.href.should == "http://www.eeml.org/xsd/0.5.1"
8
+ attrs["xsi:schemaLocation"].should == "http://www.eeml.org/xsd/0.5.1 http://www.eeml.org/xsd/0.5.1/0.5.1.xsd"
9
+ when "5"
10
+ attrs["version"].should == eeml_version
11
+ attrs.namespace.href.should == "http://www.eeml.org/xsd/005"
12
+ attrs["xsi:schemaLocation"].should == "http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd"
13
+ else
14
+ false
15
+ end
16
+ end
17
+
18
+ failure_message_for_should do |xml|
19
+ "expected #{xml} to describe eeml version #{eeml_version}"
20
+ end
21
+ end
22
+
23
+
@@ -0,0 +1,783 @@
1
+ def feed_as_(format, options = {})
2
+ # Default data
3
+ # This data is based on http://api.xively.com/v2/feeds/504
4
+ case format.to_s
5
+ when 'hash'
6
+ data = {
7
+ "updated"=>Time.parse('2011-01-02'),
8
+ "created"=>Time.parse('2011-01-01'),
9
+ "title"=>"Xively Office Environment",
10
+ "private"=>false,
11
+ "id"=>504,
12
+ "icon"=>"http://xively.com/logo.png",
13
+ "website"=>"http://xively.com",
14
+ "tags" => "kittens , sofa, aardvark",
15
+ "description"=>"Sensors in xively.com's headquarters.",
16
+ "feed" => "http://test.host/testfeed.html?random=890299&rand2=91",
17
+ "auto_feed_url" => "http://test.host2/testfeed.xml?q=something",
18
+ "owner_login" => "skeletor",
19
+ "email"=>"abc@example.com",
20
+ "status"=>"live",
21
+ "creator"=>"http://xively.com/users/skeletor",
22
+ "product_id" => "product_id",
23
+ "device_serial" => "device_serial",
24
+ 'location_domain' => 'physical',
25
+ 'location_lon' => -0.0807666778564453,
26
+ 'location_disposition' => 'fixed',
27
+ 'location_ele' => '23.0',
28
+ 'location_exposure' => 'indoor',
29
+ 'location_lat' => 51.5235375648154,
30
+ 'location_name' => 'office',
31
+ "datastreams" => [
32
+ {
33
+ "updated" => Time.parse('2011-01-02'),
34
+ "max_value"=>658.0,
35
+ "unit_type"=>"",
36
+ "min_value"=>0.0,
37
+ "unit_label"=>"",
38
+ "current_value"=>"14",
39
+ "id"=>"0",
40
+ "tags"=>"humidity,Temperature, freakin lasers",
41
+ "datapoints" => [{
42
+ "value" => "1",
43
+ "at" => Time.parse("2011-03-02T15:59:56.895922Z")
44
+ },
45
+ {
46
+ "value" => "1",
47
+ "at" => Time.parse("2011-03-02T16:00:07.188648Z")
48
+ },
49
+ {
50
+ "value" => "2",
51
+ "at" => Time.parse("2011-03-02T16:00:18.416500Z")
52
+ }],
53
+ "unit_symbol"=>""},
54
+ {
55
+ "updated" => Time.parse('2011-01-02'),
56
+ "max_value"=>980.0,
57
+ "unit_type"=>"",
58
+ "min_value"=>0.0,
59
+ "unit_label"=>"label",
60
+ "current_value"=>"813",
61
+ "id"=>"1",
62
+ "tags"=>"light level",
63
+ "unit_symbol"=>""},
64
+ {
65
+ "updated" => Time.parse('2011-01-02'),
66
+ "max_value"=>774.0,
67
+ "unit_type"=>"some type",
68
+ "min_value"=>158.0,
69
+ "unit_label"=>"some measure",
70
+ "current_value"=>"318",
71
+ "id"=>"2",
72
+ "tags"=>"Temperature",
73
+ "unit_symbol"=>"some % symbol"},
74
+ {
75
+ "updated" => Time.parse('2011-01-02'),
76
+ "max_value"=>0.0,
77
+ "unit_type"=>"",
78
+ "min_value"=>0.0,
79
+ "unit_label"=>"",
80
+ "current_value"=>"0",
81
+ "id"=>"3",
82
+ "tags"=>"door 1",
83
+ "unit_symbol"=>"symbol"},
84
+ {
85
+ "updated" => Time.parse('2011-01-02'),
86
+ "max_value"=>0.0,
87
+ "unit_type"=>"",
88
+ "min_value"=>0.0,
89
+ "unit_label"=>"",
90
+ "current_value"=>"0",
91
+ "id"=>"4",
92
+ "tags"=>"door 2",
93
+ "unit_symbol"=>""},
94
+ {
95
+ "updated" => Time.parse('2011-01-02'),
96
+ "max_value"=>40.0,
97
+ "unit_type"=>"",
98
+ "min_value"=>0.0,
99
+ "unit_label"=>"",
100
+ "current_value"=>"40",
101
+ "id"=>"5",
102
+ "unit_symbol"=>""},
103
+ {
104
+ "updated" => Time.parse('2011-01-02'),
105
+ "max_value"=>32767.0,
106
+ "unit_type"=>"",
107
+ "min_value"=>-32768.0,
108
+ "unit_label"=>"",
109
+ "current_value"=>"15545",
110
+ "id"=>"6",
111
+ "tags"=>"successes",
112
+ "unit_symbol"=>""}]
113
+ }
114
+ when 'json'
115
+ data = feed_as_json(options[:version] || "1.0.0")
116
+ when 'xml'
117
+ data = feed_as_xml(options[:version] || "0.5.1", options[:except_node], options[:omit_version])
118
+ when 'csv'
119
+ data = feed_as_csv(options[:version] || "v2")
120
+ end
121
+
122
+ # Add extra options we passed
123
+ if options[:with]
124
+ options[:with].each do |field, value|
125
+ data[field.to_s] = value
126
+ end
127
+ end
128
+
129
+ # Remove options we don't need
130
+ if options[:except]
131
+ options[:except].each do |field,_|
132
+ data.delete(field.to_s)
133
+ end
134
+ end
135
+
136
+ # Return the feed in the requested format
137
+ case format.to_s
138
+ when 'hash'
139
+ data
140
+ when 'json'
141
+ MultiJson.dump(data)
142
+ when 'xml'
143
+ data
144
+ when 'csv'
145
+ data
146
+ else
147
+ raise "#{format} undefined"
148
+ end
149
+ end
150
+
151
+ def feed_as_csv(version)
152
+ case version.to_s
153
+ when 'v1'
154
+ '15,912,327,0,0,0,-30361'
155
+ when 'v2'
156
+ %Q{
157
+ 0,2011-06-13T12:30:04.714629Z,15
158
+ 1,2011-06-13T12:30:04.714629Z,905
159
+ 2,2011-06-13T12:30:04.714629Z,326
160
+ 3,2011-06-13T12:30:04.714629Z,0
161
+ 4,2011-06-13T12:30:04.714629Z,0
162
+ 5,2011-06-13T12:30:04.714629Z,0
163
+ 6,2011-06-13T12:30:04.714629Z,-30362
164
+ }
165
+ when 'v2_notimestamp'
166
+ %Q{
167
+ 0,15
168
+ 1,905
169
+ 2,326
170
+ 3,0
171
+ 4,0
172
+ 5,0
173
+ 6,-30362
174
+ }
175
+ when 'unknown'
176
+ '34,98'
177
+ end
178
+ end
179
+
180
+ def feed_as_json(version)
181
+ case version
182
+ when "1.0.0"
183
+ {
184
+ 'title' => 'Xively Office Environment',
185
+ 'status' => 'live',
186
+ 'updated' => '2011-02-16T16:21:01.834174Z',
187
+ 'tags' => ['hq', 'office'],
188
+ 'description' => 'Sensors in xively.com\'s headquarters.',
189
+ 'website' => 'http://www.xively.com/',
190
+ 'private' => 'false',
191
+ 'creator' => 'http://xively.com/users/skeletor',
192
+ 'version' => '1.0.0',
193
+ 'user' => {
194
+ 'login' => 'skeletor'
195
+ },
196
+ 'id' => 504,
197
+ 'location' =>
198
+ { 'domain' => 'physical',
199
+ 'lon' => -0.0807666778564453,
200
+ 'disposition' => 'fixed',
201
+ 'ele' => '23.0',
202
+ 'exposure' => 'indoor',
203
+ 'lat' => 51.5235375648154,
204
+ 'name' => 'office'
205
+ },
206
+ 'feed' => 'http://api.xively.com/v2/feeds/504.json',
207
+ "auto_feed_url" => "http://test.host2/testfeed.xml?q=something",
208
+ 'datastreams' =>
209
+ [
210
+ {'min_value' => '0.0',
211
+ 'at' => '2011-02-16T16:21:01.834174Z',
212
+ 'tags' => ['humidity'],
213
+ "unit" => {
214
+ "symbol" => "cm",
215
+ "label" => "cms",
216
+ "type" => "metric"
217
+
218
+ },
219
+
220
+ 'current_value' => '14',
221
+ 'max_value' => '658.0',
222
+ 'id' => '0'
223
+ },
224
+ {'min_value' => '0.0',
225
+ 'at' => '2011-02-16T16:21:01.834174Z',
226
+ 'tags' => ['light level'],
227
+ 'current_value' => '717',
228
+ 'max_value' => '980.0',
229
+ 'id' => '1'
230
+ },
231
+ {'min_value' => '158.0',
232
+ 'at' => '2011-02-16T16:21:01.834174Z',
233
+ 'tags' => ['Temperature'],
234
+ 'current_value' => '316',
235
+ 'max_value' => '774.0',
236
+ 'id' => '2',
237
+ "datapoints" => [{
238
+ "value" => "1",
239
+ "at" => "2011-03-02T15:59:56.895922Z"
240
+ },
241
+ {
242
+ "value" => "1",
243
+ "at" => "2011-03-02T16:00:07.188648Z"
244
+ },
245
+ {
246
+ "value" => "2",
247
+ "at" => "2011-03-02T16:00:18.416500Z"
248
+ }]
249
+ },
250
+ {'min_value' => '0.0',
251
+ 'at' => '2011-02-16T16:21:01.834174Z',
252
+ 'tags' => ['door 1'],
253
+ 'current_value' => '0',
254
+ 'max_value' => '0.0',
255
+ 'id' => '3'
256
+ },
257
+ {'min_value' => '0.0',
258
+ 'at' => '2011-02-16T16:21:01.834174Z',
259
+ 'tags' => ['door 2'],
260
+ 'current_value' => '0',
261
+ 'max_value' => '0.0',
262
+ 'id' => '4'
263
+ },
264
+ {'min_value' => '0.0',
265
+ 'at' => '2011-02-16T16:21:01.834174Z',
266
+ 'tags' => ['failures'],
267
+ 'current_value' => '40',
268
+ 'max_value' => '40.0',
269
+ 'id' => '5'
270
+ },
271
+ {'min_value' => '-32768.0',
272
+ 'at' => '2011-02-16T16:21:01.834174Z',
273
+ 'tags' => ['successes'],
274
+ 'current_value' => '2638',
275
+ 'max_value' => '32767.0',
276
+ 'id' => '6'
277
+ }
278
+ ]
279
+ }
280
+ when "0.6-alpha", "0.6"
281
+ {
282
+ "datastreams" => [{
283
+ "tags" => ["humidity"],
284
+ "values" => [{
285
+ "min_value" => "0.0",
286
+ "recorded_at" => "2011-02-22T14:28:50Z",
287
+ "value" => "129",
288
+ "max_value" => "658.0",
289
+ }],
290
+ "id" => "0",
291
+ "unit" => {
292
+ "symbol" => "zen",
293
+ "type" => "unity",
294
+ "label" => "you can't pidgeon hole me"
295
+ }
296
+
297
+ },
298
+ {
299
+ "tags" => ["light level"],
300
+ "values" => [{
301
+ "min_value" => "0.0",
302
+ "recorded_at" => "2011-02-22T14:28:50Z",
303
+ "value" => "683",
304
+ "max_value" => "980.0"
305
+ }],
306
+ "id" => "1"
307
+ },
308
+ {
309
+ "tags" => ["Temperature"],
310
+ "values" => [{
311
+ "min_value" => "158.0",
312
+ "recorded_at" => "2011-02-22T14:28:50Z",
313
+ "value" => "314",
314
+ "max_value" => "774.0"
315
+ }],
316
+ "id" => "2"
317
+ },
318
+ {
319
+ "tags" => ["door 1"],
320
+ "values" => [{
321
+ "min_value" => "0.0",
322
+ "recorded_at" => "2011-02-22T14:28:50Z",
323
+ "value" => "0",
324
+ "max_value" => "0.0"
325
+ }],
326
+ "id" => "3"
327
+ },
328
+ {
329
+ "tags" => ["door 2"],
330
+ "values" => [{
331
+ "min_value" => "0.0",
332
+ "recorded_at" => "2011-02-22T14:28:50Z",
333
+ "value" => "0",
334
+ "max_value" => "0.0"
335
+ }],
336
+ "id" => "4"
337
+ },
338
+ {
339
+ "tags" => ["failures"],
340
+ "values" => [{
341
+ "min_value" => "0.0",
342
+ "recorded_at" => "2011-02-22T14:28:50Z",
343
+ "value" => "40",
344
+ "max_value" => "40.0"
345
+ }],
346
+ "id" => "5"
347
+ },
348
+ {
349
+ "tags" => ["successes"],
350
+ "values" => [{
351
+ "min_value" => "-32768.0",
352
+ "recorded_at" => "2011-02-22T14:28:50Z",
353
+ "value" => "31680",
354
+ "max_value" => "32767.0"
355
+ }],
356
+ "id" => "6"
357
+ }],
358
+ "status" => "live",
359
+ "updated" => "2011-02-22T14:28:50.590716Z",
360
+ "description" => "Sensors in xively.com's headquarters.",
361
+ "title" => "Xively Office environment",
362
+ "website" => "http://www.xively.com/",
363
+ "version" => "0.6-alpha",
364
+ "id" => 504,
365
+ "location" => {
366
+ "domain" => "physical",
367
+ "lon" => -0.0807666778564453,
368
+ "disposition" => "fixed",
369
+ "ele" => "23.0",
370
+ "exposure" => "indoor",
371
+ "lat" => 51.5235375648154,
372
+ "name" => "office"
373
+ },
374
+ "feed" => "http://api.xively.com/v2/feeds/504.json"
375
+ }
376
+ else
377
+ raise "No such JSON version"
378
+ end
379
+ end
380
+
381
+ def feed_as_xml(version, except_node = nil, omit_version = false)
382
+
383
+ case version
384
+ when "0.5.1"
385
+ if except_node == :location
386
+ xml = <<XML
387
+ <?xml version="1.0" encoding="UTF-8"?>
388
+ <eeml xmlns="http://www.eeml.org/xsd/0.5.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" #{omit_version ? '' : 'version="0.5.1"'} xsi:schemaLocation="http://www.eeml.org/xsd/0.5.1 http://www.eeml.org/xsd/0.5.1/0.5.1.xsd">
389
+ <environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
390
+ <title>Xively Office environment</title>
391
+ <feed>http://test.host/v2/feeds/2357.xml</feed>
392
+ <auto_feed_url>http://test.host2/testfeed.xml?q=something</auto_feed_url>
393
+ <status>frozen</status>
394
+ <description>meh</description>
395
+ <website>http://alpha.com</website>
396
+ <email>fred@example.com</email>
397
+ <private>true</private>
398
+ <tag>jag</tag>
399
+ <tag>lag</tag>
400
+ <tag>mag</tag>
401
+ <tag>tag</tag>
402
+ <user>
403
+ <login>fred</login>
404
+ </user>
405
+ <data id="0">
406
+ <tag>freakin lasers</tag>
407
+ <tag>humidity</tag>
408
+ <tag>Temperature</tag>
409
+ <current_value at="2011-02-16T16:21:01.834174Z">14</current_value>
410
+ <max_value>658</max_value>
411
+ <min_value>54</min_value>
412
+ <unit type="derivedSI" symbol="A">Alpha</unit>
413
+ <datapoints>
414
+ <value at="2011-03-02T15:59:56.895922Z">1</value>
415
+ <value at="2011-03-02T16:00:07.188648Z">1</value>
416
+ <value at="2011-03-02T16:00:18.416500Z">2</value>
417
+ </datapoints>
418
+ </data>
419
+ <data id="1">
420
+ <current_value at="2011-02-16T16:21:01.834174Z">14444</current_value>
421
+ <unit>Alpha</unit>
422
+ </data>
423
+ <data id="two">
424
+ <max_value>1004</max_value>
425
+ <current_value at="2011-02-16T16:21:01.834174Z">14344</current_value>
426
+ <unit type="derivedSI">Alpha</unit>
427
+ <datapoints>
428
+ <value at="2011-03-02T16:00:18.416500Z">2</value>
429
+ </datapoints>
430
+ </data>
431
+ </environment>
432
+ </eeml>
433
+ XML
434
+ elsif except_node == :unit
435
+ xml = <<XML
436
+ <?xml version="1.0" encoding="UTF-8"?>
437
+ <eeml xmlns="http://www.eeml.org/xsd/0.5.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" #{omit_version ? '' : 'version="0.5.1"'} xsi:schemaLocation="http://www.eeml.org/xsd/0.5.1 http://www.eeml.org/xsd/0.5.1/0.5.1.xsd">
438
+ <environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
439
+ <title>Xively Office environment</title>
440
+ <feed>http://test.host/v2/feeds/2357.xml</feed>
441
+ <status>frozen</status>
442
+ <description>meh</description>
443
+ <website>http://alpha.com</website>
444
+ <email>fred@example.com</email>
445
+ <private>true</private>
446
+ <tag>jag</tag>
447
+ <tag>lag</tag>
448
+ <tag>mag</tag>
449
+ <tag>tag</tag>
450
+ <location domain="physical" exposure="indoor" disposition="fixed">
451
+ <name>house</name>
452
+ <lat>53.3308729830171</lat>
453
+ <lon>111.796875</lon>
454
+ <ele>2000</ele>
455
+ </location>
456
+ <data id="0">
457
+ <tag>freakin lasers</tag>
458
+ <tag>humidity</tag>
459
+ <tag>Temperature</tag>
460
+ <current_value at="2011-02-16T16:21:01.834174Z">14</current_value>
461
+ <max_value>658</max_value>
462
+ <min_value>54</min_value>
463
+ <datapoints>
464
+ <value at="2011-03-02T15:59:56.895922Z">1</value>
465
+ <value at="2011-03-02T16:00:07.188648Z">1</value>
466
+ <value at="2011-03-02T16:00:18.416500Z">2</value>
467
+ </datapoints>
468
+ </data>
469
+ <data id="1">
470
+ <current_value at="2011-02-16T16:21:01.834174Z">14444</current_value>
471
+ </data>
472
+ <data id="two">
473
+ <max_value>1004</max_value>
474
+ <current_value at="2011-02-16T16:21:01.834174Z">14344</current_value>
475
+ <datapoints>
476
+ <value at="2011-03-02T16:00:18.416500Z">2</value>
477
+ </datapoints>
478
+ </data>
479
+ </environment>
480
+ </eeml>
481
+ XML
482
+ elsif except_node == :tag
483
+ xml = <<XML
484
+ <?xml version="1.0" encoding="UTF-8"?>
485
+ <eeml xmlns="http://www.eeml.org/xsd/0.5.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" #{omit_version ? '' : 'version="0.5.1"'} xsi:schemaLocation="http://www.eeml.org/xsd/0.5.1 http://www.eeml.org/xsd/0.5.1/0.5.1.xsd">
486
+ <environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
487
+ <title>Xively Office environment</title>
488
+ <feed>http://test.host/v2/feeds/2357.xml</feed>
489
+ <status>frozen</status>
490
+ <description>meh</description>
491
+ <website>http://alpha.com</website>
492
+ <email>fred@example.com</email>
493
+ <private>true</private>
494
+ <location domain="physical" exposure="indoor" disposition="fixed">
495
+ <name>house</name>
496
+ <lat>53.3308729830171</lat>
497
+ <lon>111.796875</lon>
498
+ <ele>2000</ele>
499
+ </location>
500
+ <data id="0">
501
+ <current_value at="2011-02-16T16:21:01.834174Z">14</current_value>
502
+ <max_value>658</max_value>
503
+ <min_value>54</min_value>
504
+ <unit type="derivedSI" symbol="A">Alpha</unit>
505
+ <datapoints>
506
+ <value at="2011-03-02T15:59:56.895922Z">1</value>
507
+ <value at="2011-03-02T16:00:07.188648Z">1</value>
508
+ <value at="2011-03-02T16:00:18.416500Z">2</value>
509
+ </datapoints>
510
+ </data>
511
+ <data id="1">
512
+ <current_value at="2011-02-16T16:21:01.834174Z">14444</current_value>
513
+ <unit>Alpha</unit>
514
+ </data>
515
+ <data id="two">
516
+ <max_value>1004</max_value>
517
+ <current_value at="2011-02-16T16:21:01.834174Z">14344</current_value>
518
+ <unit type="derivedSI">Alpha</unit>
519
+ <datapoints>
520
+ <value at="2011-03-02T16:00:18.416500Z">2</value>
521
+ </datapoints>
522
+ </data>
523
+ </environment>
524
+ </eeml>
525
+ XML
526
+
527
+ else
528
+ xml = <<XML
529
+ <?xml version="1.0" encoding="UTF-8"?>
530
+ <eeml xmlns="http://www.eeml.org/xsd/0.5.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" #{omit_version ? '' : 'version="0.5.1"'} xsi:schemaLocation="http://www.eeml.org/xsd/0.5.1 http://www.eeml.org/xsd/0.5.1/0.5.1.xsd">
531
+ <environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
532
+ <title>Xively Office environment</title>
533
+ <feed>http://test.host/v2/feeds/2357.xml</feed>
534
+ <status>frozen</status>
535
+ <description>meh</description>
536
+ <website>http://alpha.com</website>
537
+ <email>fred@example.com</email>
538
+ <private>true</private>
539
+ <tag>jag</tag>
540
+ <tag>lag</tag>
541
+ <tag>mag</tag>
542
+ <tag>tag</tag>
543
+ <location domain="physical" exposure="indoor" disposition="fixed">
544
+ <name>house</name>
545
+ <lat>53.3308729830171</lat>
546
+ <lon>111.796875</lon>
547
+ <ele>2000</ele>
548
+ </location>
549
+ <data id="0">
550
+ <tag>freakin lasers</tag>
551
+ <tag>humidity</tag>
552
+ <tag>Temperature</tag>
553
+ <current_value at="2011-02-16T16:21:01.834174Z">14</current_value>
554
+ <max_value>658</max_value>
555
+ <min_value>54</min_value>
556
+ <unit type="derivedSI" symbol="A">Alpha</unit>
557
+ <datapoints>
558
+ <value at="2011-03-02T15:59:56.895922Z">1</value>
559
+ <value at="2011-03-02T16:00:07.188648Z">1</value>
560
+ <value at="2011-03-02T16:00:18.416500Z">2</value>
561
+ </datapoints>
562
+ </data>
563
+ <data id="1">
564
+ <current_value at="2011-02-16T16:21:01.834174Z">14444</current_value>
565
+ <unit>Alpha</unit>
566
+ </data>
567
+ <data id="two">
568
+ <max_value>1004</max_value>
569
+ <current_value at="2011-02-16T16:21:01.834174Z">14344</current_value>
570
+ <unit type="derivedSI">Alpha</unit>
571
+ <datapoints>
572
+ <value at="2011-03-02T16:00:18.416500Z">2</value>
573
+ </datapoints>
574
+ </data>
575
+ </environment>
576
+ </eeml>
577
+ XML
578
+ end
579
+ when "5"
580
+ if except_node == :location
581
+ xml = <<XML
582
+ <?xml version="1.0" encoding="UTF-8"?>
583
+ <eeml xmlns="http://www.eeml.org/xsd/005" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" #{omit_version ? '' : 'version="5"'} xsi:schemaLocation="http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd">
584
+ <environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
585
+ <title>Xively Office environment</title>
586
+ <feed>http://test.host/v2/feeds/2357.xml</feed>
587
+ <status>frozen</status>
588
+ <description>meh</description>
589
+ <website>http://alpha.com</website>
590
+ <email>fred@example.com</email>
591
+ <data id="0">
592
+ <tag>freakin lasers</tag>
593
+ <tag>humidity</tag>
594
+ <tag>Temperature</tag>
595
+ <value maxValue="658.0" minValue="658">14</value>
596
+ <unit type="derivedSI" symbol="A">Alpha</unit>
597
+ </data>
598
+ <data id="1">
599
+ <value>14</value>
600
+ <unit>Alpha</unit>
601
+ </data>
602
+ <data id="two">
603
+ <value maxValue="658.0">1004</value>
604
+ <unit type="derivedSI">Alpha</unit>
605
+ </data>
606
+ </environment>
607
+ </eeml>
608
+ XML
609
+ elsif except_node == :unit
610
+ xml = <<XML
611
+ <?xml version="1.0" encoding="UTF-8"?>
612
+ <eeml xmlns="http://www.eeml.org/xsd/005" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" #{omit_version ? '' : 'version="5"'} xsi:schemaLocation="http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd">
613
+ <environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
614
+ <title>Xively Office environment</title>
615
+ <feed>http://test.host/v2/feeds/2357.xml</feed>
616
+ <status>frozen</status>
617
+ <description>meh</description>
618
+ <website>http://alpha.com</website>
619
+ <email>fred@example.com</email>
620
+ <location domain="physical" exposure="indoor" disposition="fixed">
621
+ <name>house</name>
622
+ <lat>53.3308729830171</lat>
623
+ <lon>111.796875</lon>
624
+ <ele>2000</ele>
625
+ </location>
626
+ <data id="0">
627
+ <tag>freakin lasers</tag>
628
+ <tag>humidity</tag>
629
+ <tag>Temperature</tag>
630
+ <value maxValue="658.0" minValue="658">14</value>
631
+ </data>
632
+ <data id="1">
633
+ <value>14</value>
634
+ </data>
635
+ <data id="two">
636
+ <value maxValue="658.0">1004</value>
637
+ </data>
638
+ </environment>
639
+ </eeml>
640
+ XML
641
+ elsif except_node == :unit_attributes
642
+ xml = <<XML
643
+ <?xml version="1.0" encoding="UTF-8"?>
644
+ <eeml xmlns="http://www.eeml.org/xsd/005" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" #{omit_version ? '' : 'version="5"'} xsi:schemaLocation="http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd">
645
+ <environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
646
+ <title>Xively Office environment</title>
647
+ <feed>http://test.host/v2/feeds/2357.xml</feed>
648
+ <status>frozen</status>
649
+ <description>meh</description>
650
+ <website>http://alpha.com</website>
651
+ <email>fred@example.com</email>
652
+ <location domain="physical" exposure="indoor" disposition="fixed">
653
+ <name>house</name>
654
+ <lat>53.3308729830171</lat>
655
+ <lon>111.796875</lon>
656
+ <ele>2000</ele>
657
+ </location>
658
+ <data id="0">
659
+ <tag>freakin lasers</tag>
660
+ <tag>humidity</tag>
661
+ <tag>Temperature</tag>
662
+ <value maxValue="658.0" minValue="658">14</value>
663
+ <unit>Alpha</unit>
664
+ </data>
665
+ <data id="1">
666
+ <value>14</value>
667
+ <unit>Alpha</unit>
668
+ </data>
669
+ <data id="two">
670
+ <value maxValue="658.0">1004</value>
671
+ <unit>Alpha</unit>
672
+ </data>
673
+ </environment>
674
+ </eeml>
675
+ XML
676
+ elsif except_node == :value_attributes
677
+ xml = <<XML
678
+ <?xml version="1.0" encoding="UTF-8"?>
679
+ <eeml xmlns="http://www.eeml.org/xsd/005" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" #{omit_version ? '' : 'version="5"'} xsi:schemaLocation="http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd">
680
+ <environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
681
+ <title>Xively Office environment</title>
682
+ <feed>http://test.host/v2/feeds/2357.xml</feed>
683
+ <status>frozen</status>
684
+ <description>meh</description>
685
+ <website>http://alpha.com</website>
686
+ <email>fred@example.com</email>
687
+ <location domain="physical" exposure="indoor" disposition="fixed">
688
+ <name>house</name>
689
+ <lat>53.3308729830171</lat>
690
+ <lon>111.796875</lon>
691
+ <ele>2000</ele>
692
+ </location>
693
+ <data id="0">
694
+ <tag>freakin lasers</tag>
695
+ <tag>humidity</tag>
696
+ <tag>Temperature</tag>
697
+ <value>14</value>
698
+ <unit type="derivedSI" symbol="A">Alpha</unit>
699
+ </data>
700
+ <data id="1">
701
+ <value>14</value>
702
+ <unit>Alpha</unit>
703
+ </data>
704
+ <data id="two">
705
+ <value>1004</value>
706
+ <unit type="derivedSI">Alpha</unit>
707
+ </data>
708
+ </environment>
709
+ </eeml>
710
+ XML
711
+ elsif except_node == :tag
712
+ xml = <<XML
713
+ <?xml version="1.0" encoding="UTF-8"?>
714
+ <eeml xmlns="http://www.eeml.org/xsd/005" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" #{omit_version ? '' : 'version="5"'} xsi:schemaLocation="http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd">
715
+ <environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
716
+ <title>Xively Office environment</title>
717
+ <feed>http://test.host/v2/feeds/2357.xml</feed>
718
+ <status>frozen</status>
719
+ <description>meh</description>
720
+ <website>http://alpha.com</website>
721
+ <email>fred@example.com</email>
722
+ <location domain="physical" exposure="indoor" disposition="fixed">
723
+ <name>house</name>
724
+ <lat>53.3308729830171</lat>
725
+ <lon>111.796875</lon>
726
+ <ele>2000</ele>
727
+ </location>
728
+ <data id="0">
729
+ <value maxValue="658.0" minValue="658">14</value>
730
+ <unit type="derivedSI" symbol="A">Alpha</unit>
731
+ </data>
732
+ <data id="1">
733
+ <value>14</value>
734
+ <unit>Alpha</unit>
735
+ </data>
736
+ <data id="two">
737
+ <value maxValue="658.0">1004</value>
738
+ <unit type="derivedSI">Alpha</unit>
739
+ </data>
740
+ </environment>
741
+ </eeml>
742
+ XML
743
+ else
744
+ xml = <<XML
745
+ <?xml version="1.0" encoding="UTF-8"?>
746
+ <eeml xmlns="http://www.eeml.org/xsd/005" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" #{omit_version ? '' : 'version="5"'} xsi:schemaLocation="http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd">
747
+ <environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
748
+ <title>Xively Office environment</title>
749
+ <feed>http://test.host/v2/feeds/2357.xml</feed>
750
+ <status>frozen</status>
751
+ <description>meh</description>
752
+ <website>http://alpha.com</website>
753
+ <email>fred@example.com</email>
754
+ <location domain="physical" exposure="indoor" disposition="fixed">
755
+ <name>house</name>
756
+ <lat>53.3308729830171</lat>
757
+ <lon>111.796875</lon>
758
+ <ele>2000</ele>
759
+ </location>
760
+ <data id="0">
761
+ <tag>freakin lasers</tag>
762
+ <tag>humidity</tag>
763
+ <tag>Temperature</tag>
764
+ <value maxValue="658.0" minValue="658">14</value>
765
+ <unit type="derivedSI" symbol="A">Alpha</unit>
766
+ </data>
767
+ <data id="1">
768
+ <value>14</value>
769
+ <unit>Alpha</unit>
770
+ </data>
771
+ <data id="two">
772
+ <value maxValue="658.0">1004</value>
773
+ <unit type="derivedSI">Alpha</unit>
774
+ </data>
775
+ </environment>
776
+ </eeml>
777
+ XML
778
+ end
779
+ else
780
+ raise "Datastream as XML #{version} not implemented"
781
+ end
782
+
783
+ end