cosm-rb 0.0.1

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