cosm-rb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/.rbenv-version +1 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +91 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +195 -0
- data/Rakefile +35 -0
- data/ci/build_hudson.sh +24 -0
- data/cosm-rb.gemspec +40 -0
- data/init.rb +2 -0
- data/lib/cosm-rb/array_extensions.rb +6 -0
- data/lib/cosm-rb/base/instance_methods.rb +28 -0
- data/lib/cosm-rb/base.rb +52 -0
- data/lib/cosm-rb/client.rb +7 -0
- data/lib/cosm-rb/datapoint.rb +71 -0
- data/lib/cosm-rb/datastream.rb +136 -0
- data/lib/cosm-rb/feed.rb +108 -0
- data/lib/cosm-rb/hash_extensions.rb +16 -0
- data/lib/cosm-rb/helpers.rb +42 -0
- data/lib/cosm-rb/key.rb +98 -0
- data/lib/cosm-rb/nil_content.rb +15 -0
- data/lib/cosm-rb/object_extensions.rb +6 -0
- data/lib/cosm-rb/parsers/csv/datastream_defaults.rb +12 -0
- data/lib/cosm-rb/parsers/csv/feed_defaults.rb +38 -0
- data/lib/cosm-rb/parsers/defaults.rb +13 -0
- data/lib/cosm-rb/parsers/json/datapoint_defaults.rb +12 -0
- data/lib/cosm-rb/parsers/json/datastream_defaults.rb +53 -0
- data/lib/cosm-rb/parsers/json/feed_defaults.rb +103 -0
- data/lib/cosm-rb/parsers/json/key_defaults.rb +15 -0
- data/lib/cosm-rb/parsers/json/search_result_defaults.rb +18 -0
- data/lib/cosm-rb/parsers/json/trigger_defaults.rb +12 -0
- data/lib/cosm-rb/parsers/xml/datapoint_defaults.rb +20 -0
- data/lib/cosm-rb/parsers/xml/datastream_defaults.rb +77 -0
- data/lib/cosm-rb/parsers/xml/feed_defaults.rb +127 -0
- data/lib/cosm-rb/parsers/xml/key_defaults.rb +40 -0
- data/lib/cosm-rb/parsers/xml/trigger_defaults.rb +22 -0
- data/lib/cosm-rb/permission.rb +67 -0
- data/lib/cosm-rb/resource.rb +43 -0
- data/lib/cosm-rb/search_result.rb +63 -0
- data/lib/cosm-rb/string_extensions.rb +6 -0
- data/lib/cosm-rb/template.rb +32 -0
- data/lib/cosm-rb/templates/csv/datapoint_defaults.rb +22 -0
- data/lib/cosm-rb/templates/csv/datastream_defaults.rb +43 -0
- data/lib/cosm-rb/templates/csv/feed_defaults.rb +47 -0
- data/lib/cosm-rb/templates/defaults.rb +14 -0
- data/lib/cosm-rb/templates/json/datapoint_defaults.rb +15 -0
- data/lib/cosm-rb/templates/json/datastream_defaults.rb +66 -0
- data/lib/cosm-rb/templates/json/feed_defaults.rb +134 -0
- data/lib/cosm-rb/templates/json/key_defaults.rb +41 -0
- data/lib/cosm-rb/templates/json/search_result_defaults.rb +47 -0
- data/lib/cosm-rb/templates/json/trigger_defaults.rb +21 -0
- data/lib/cosm-rb/templates/xml/datapoint_defaults.rb +25 -0
- data/lib/cosm-rb/templates/xml/datastream_defaults.rb +66 -0
- data/lib/cosm-rb/templates/xml/feed_defaults.rb +110 -0
- data/lib/cosm-rb/templates/xml/search_result_defaults.rb +116 -0
- data/lib/cosm-rb/templates/xml_headers.rb +17 -0
- data/lib/cosm-rb/trigger.rb +65 -0
- data/lib/cosm-rb/validations.rb +9 -0
- data/lib/cosm-rb/version.rb +3 -0
- data/lib/cosm-rb.rb +29 -0
- data/spec/cosm-rb/array_extensions_spec.rb +9 -0
- data/spec/cosm-rb/base/instance_methods_spec.rb +109 -0
- data/spec/cosm-rb/base_spec.rb +56 -0
- data/spec/cosm-rb/client_spec.rb +7 -0
- data/spec/cosm-rb/datapoint_spec.rb +169 -0
- data/spec/cosm-rb/datastream_spec.rb +301 -0
- data/spec/cosm-rb/feed_spec.rb +298 -0
- data/spec/cosm-rb/hash_extensions_spec.rb +20 -0
- data/spec/cosm-rb/helpers_spec.rb +56 -0
- data/spec/cosm-rb/key_spec.rb +178 -0
- data/spec/cosm-rb/parsers/csv/datastream_defaults_spec.rb +12 -0
- data/spec/cosm-rb/parsers/csv/feed_defaults_spec.rb +35 -0
- data/spec/cosm-rb/parsers/json/datapoint_defaults_spec.rb +15 -0
- data/spec/cosm-rb/parsers/json/datastream_defaults_spec.rb +82 -0
- data/spec/cosm-rb/parsers/json/feed_defaults_spec.rb +18 -0
- data/spec/cosm-rb/parsers/json/key_defaults_spec.rb +8 -0
- data/spec/cosm-rb/parsers/json/search_result_defaults_spec.rb +12 -0
- data/spec/cosm-rb/parsers/json/trigger_defaults_spec.rb +16 -0
- data/spec/cosm-rb/parsers/xml/datapoint_defaults_spec.rb +19 -0
- data/spec/cosm-rb/parsers/xml/datastream_defaults_spec.rb +63 -0
- data/spec/cosm-rb/parsers/xml/feed_defaults_spec.rb +65 -0
- data/spec/cosm-rb/parsers/xml/key_defaults_spec.rb +16 -0
- data/spec/cosm-rb/parsers/xml/trigger_defaults_spec.rb +16 -0
- data/spec/cosm-rb/search_result_spec.rb +258 -0
- data/spec/cosm-rb/string_extensions_spec.rb +12 -0
- data/spec/cosm-rb/template_spec.rb +74 -0
- data/spec/cosm-rb/templates/csv/datapoint_defaults_spec.rb +41 -0
- data/spec/cosm-rb/templates/csv/datastream_defaults_spec.rb +131 -0
- data/spec/cosm-rb/templates/csv/feed_defaults_spec.rb +78 -0
- data/spec/cosm-rb/templates/json/datapoint_defaults_spec.rb +14 -0
- data/spec/cosm-rb/templates/json/datastream_defaults_spec.rb +170 -0
- data/spec/cosm-rb/templates/json/feed_defaults_spec.rb +397 -0
- data/spec/cosm-rb/templates/json/key_defaults_spec.rb +29 -0
- data/spec/cosm-rb/templates/json/search_result_defaults_spec.rb +37 -0
- data/spec/cosm-rb/templates/json/trigger_defaults_spec.rb +19 -0
- data/spec/cosm-rb/templates/xml/datapoint_defaults_spec.rb +14 -0
- data/spec/cosm-rb/templates/xml/datastream_defaults_spec.rb +113 -0
- data/spec/cosm-rb/templates/xml/feed_defaults_spec.rb +131 -0
- data/spec/cosm-rb/templates/xml/search_result_defaults_spec.rb +44 -0
- data/spec/cosm-rb/trigger_spec.rb +117 -0
- data/spec/fixtures/models.rb +81 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/contain_datapoint_eeml_matcher.rb +16 -0
- data/spec/support/contain_datastream_eeml_matcher.rb +60 -0
- data/spec/support/contain_feed_eeml_matcher.rb +96 -0
- data/spec/support/datapoint_helper.rb +53 -0
- data/spec/support/datastream_helper.rb +300 -0
- data/spec/support/describe_eeml_matcher.rb +23 -0
- data/spec/support/feed_helper.rb +771 -0
- data/spec/support/fully_represent_datapoint_matcher.rb +30 -0
- data/spec/support/fully_represent_datastream_matcher.rb +92 -0
- data/spec/support/fully_represent_feed_matcher.rb +226 -0
- data/spec/support/fully_represent_key_matcher.rb +74 -0
- data/spec/support/fully_represent_search_result_matcher.rb +67 -0
- data/spec/support/fully_represent_trigger_matcher.rb +29 -0
- data/spec/support/key_helper.rb +74 -0
- data/spec/support/search_result_helper.rb +252 -0
- data/spec/support/trigger_helper.rb +51 -0
- metadata +363 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
def datapoint_as_(format, options = {})
|
2
|
+
case format.to_s
|
3
|
+
when 'hash'
|
4
|
+
data = {
|
5
|
+
"at" => Time.parse('2011-01-02'),
|
6
|
+
"value" => "2000"
|
7
|
+
}
|
8
|
+
when 'json'
|
9
|
+
data = {
|
10
|
+
'at' => '2011-02-16T16:21:01.834174Z',
|
11
|
+
'value' => "2000"
|
12
|
+
}
|
13
|
+
when 'xml'
|
14
|
+
data = <<-XML
|
15
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
16
|
+
<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">
|
17
|
+
<environment>
|
18
|
+
<data>
|
19
|
+
<datapoints>
|
20
|
+
<value at="2011-03-02T15:59:56.895922Z">2000</value>
|
21
|
+
</datapoints>
|
22
|
+
</data>
|
23
|
+
</environment>
|
24
|
+
</eeml>
|
25
|
+
XML
|
26
|
+
end
|
27
|
+
|
28
|
+
# Add extra options we passed
|
29
|
+
if options[:with]
|
30
|
+
options[:with].each do |field, value|
|
31
|
+
data[field.to_s] = value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Remove options we don't need
|
36
|
+
if options[:except]
|
37
|
+
options[:except].each do |field,_|
|
38
|
+
data.delete(field.to_s)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Return the feed in the requested format
|
43
|
+
case format.to_s
|
44
|
+
when 'hash'
|
45
|
+
data
|
46
|
+
when 'json'
|
47
|
+
data.to_json
|
48
|
+
when 'xml'
|
49
|
+
data
|
50
|
+
else
|
51
|
+
raise "#{format} undefined"
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,300 @@
|
|
1
|
+
def datastream_as_(format, options = {})
|
2
|
+
case format.to_s
|
3
|
+
when 'hash'
|
4
|
+
data = {
|
5
|
+
"updated" => Time.parse('2011-01-02'),
|
6
|
+
"max_value"=>658.0,
|
7
|
+
"unit_type"=>"derived SI",
|
8
|
+
"min_value"=>0.0,
|
9
|
+
"unit_label"=>"percentage",
|
10
|
+
"current_value"=>"14",
|
11
|
+
"id"=>"0",
|
12
|
+
"tags"=>"humidity,Temperature ,freakin lasers",
|
13
|
+
"unit_symbol"=>"%",
|
14
|
+
"feed_id" => "24568",
|
15
|
+
"feed_creator" => "Dennis",
|
16
|
+
"datapoints" => [{
|
17
|
+
"value" => "1",
|
18
|
+
"at" => Time.parse("2011-03-02T15:59:56.895922Z")
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"value" => "1",
|
22
|
+
"at" => Time.parse("2011-03-02T16:00:07.188648Z")
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"value" => "2",
|
26
|
+
"at" => Time.parse("2011-03-02T16:00:18.416500Z")
|
27
|
+
}]
|
28
|
+
}
|
29
|
+
when 'json'
|
30
|
+
data = datastream_as_json(options[:version] || "1.0.0")
|
31
|
+
when 'xml'
|
32
|
+
data = datastream_as_xml(options[:version] || "0.5.1", options[:except_node])
|
33
|
+
when 'csv'
|
34
|
+
data = '14'
|
35
|
+
end
|
36
|
+
|
37
|
+
# Add extra options we passed
|
38
|
+
if options[:with]
|
39
|
+
options[:with].each do |field, value|
|
40
|
+
data[field.to_s] = value
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Remove options we don't need
|
45
|
+
if options[:except]
|
46
|
+
options[:except].each do |field,_|
|
47
|
+
data.delete(field.to_s)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Return the feed in the requested format
|
52
|
+
case format.to_s
|
53
|
+
when 'hash'
|
54
|
+
data
|
55
|
+
when 'json'
|
56
|
+
data.to_json
|
57
|
+
when 'xml'
|
58
|
+
data
|
59
|
+
when 'csv'
|
60
|
+
data
|
61
|
+
else
|
62
|
+
raise "#{format} undefined"
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def datastream_as_json(version)
|
68
|
+
case version
|
69
|
+
when "1.0.0"
|
70
|
+
{
|
71
|
+
'min_value' => '0.0',
|
72
|
+
'at' => '2011-02-16T16:21:01.834174Z',
|
73
|
+
'tags' => ['humidity', 'Temperature', 'freakin lasers'],
|
74
|
+
'current_value' => '14',
|
75
|
+
'max_value' => '658.0',
|
76
|
+
'datapoints_function' => 'average',
|
77
|
+
"datapoints" => [{
|
78
|
+
"value" => "1",
|
79
|
+
"at" => "2011-03-02T15:59:56.895922Z"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"value" => "1",
|
83
|
+
"at" => "2011-03-02T16:00:07.188648Z"
|
84
|
+
},
|
85
|
+
{
|
86
|
+
"value" => "2",
|
87
|
+
"at" => "2011-03-02T16:00:18.416500Z"
|
88
|
+
}],
|
89
|
+
'id' => '0',
|
90
|
+
"unit" => {
|
91
|
+
"type" => "derived SI",
|
92
|
+
"symbol" => "%",
|
93
|
+
"label" => "percentage"
|
94
|
+
},
|
95
|
+
'version' => '1.0.0'
|
96
|
+
}
|
97
|
+
when "0.6-alpha"
|
98
|
+
{
|
99
|
+
"tags" => ["humidity"],
|
100
|
+
"values" => [{
|
101
|
+
"min_value" => "0.0",
|
102
|
+
"recorded_at" => "2011-02-22T14:28:50Z",
|
103
|
+
"value" => "129",
|
104
|
+
"max_value" => "658.0"
|
105
|
+
}],
|
106
|
+
"id" => "0",
|
107
|
+
"unit" => {
|
108
|
+
"type" => "derived SI",
|
109
|
+
"symbol" => "%",
|
110
|
+
"label" => "percentage"
|
111
|
+
},
|
112
|
+
'version' => '0.6-alpha'
|
113
|
+
}
|
114
|
+
else
|
115
|
+
raise "Datastream as JSON #{version} not implemented"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def datastream_as_xml(version, except_node = nil)
|
120
|
+
case version
|
121
|
+
when "0.5.1"
|
122
|
+
if except_node == :tag
|
123
|
+
xml = <<XML
|
124
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
125
|
+
<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">
|
126
|
+
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://appdev.loc:3000/users/occaecati">
|
127
|
+
<data id="0">
|
128
|
+
<current_value at="2011-02-16T16:21:01.834174Z">14</current_value>
|
129
|
+
<max_value>658.0</max_value>
|
130
|
+
<min_value>0.0</min_value>
|
131
|
+
<unit type="derivedSI" symbol="A">Alpha</unit>
|
132
|
+
</data>
|
133
|
+
</environment>
|
134
|
+
</eeml>
|
135
|
+
XML
|
136
|
+
elsif except_node == :unit
|
137
|
+
xml = <<XML
|
138
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
139
|
+
<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">
|
140
|
+
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://appdev.loc:3000/users/occaecati">
|
141
|
+
<data id="0">
|
142
|
+
<tag>freakin lasers</tag>
|
143
|
+
<tag>humidity</tag>
|
144
|
+
<tag>Temperature</tag>
|
145
|
+
<current_value at="2011-02-16T16:21:01.834174Z">14</current_value>
|
146
|
+
<max_value>658.0</max_value>
|
147
|
+
<min_value>0.0</min_value>
|
148
|
+
</data>
|
149
|
+
</environment>
|
150
|
+
</eeml>
|
151
|
+
XML
|
152
|
+
elsif except_node == :unit_attributes
|
153
|
+
xml = <<XML
|
154
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
155
|
+
<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">
|
156
|
+
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://appdev.loc:3000/users/occaecati">
|
157
|
+
<data id="0">
|
158
|
+
<tag>freakin lasers</tag>
|
159
|
+
<tag>humidity</tag>
|
160
|
+
<tag>Temperature</tag>
|
161
|
+
<current_value at="2011-02-16T16:21:01.834174Z">14</current_value>
|
162
|
+
<max_value>658.0</max_value>
|
163
|
+
<min_value>0.0</min_value>
|
164
|
+
<unit>Alpha</unit>
|
165
|
+
</data>
|
166
|
+
</environment>
|
167
|
+
</eeml>
|
168
|
+
XML
|
169
|
+
elsif except_node == :timestamps
|
170
|
+
xml = <<XML
|
171
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
172
|
+
<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">
|
173
|
+
<environment id="504" creator="http://appdev.loc:3000/users/occaecati">
|
174
|
+
<data id="0">
|
175
|
+
<tag>freakin lasers</tag>
|
176
|
+
<tag>humidity</tag>
|
177
|
+
<tag>Temperature</tag>
|
178
|
+
<current_value>14</current_value>
|
179
|
+
<max_value>658.0</max_value>
|
180
|
+
<min_value>0.0</min_value>
|
181
|
+
<unit type="derivedSI" symbol="A">Alpha</unit>
|
182
|
+
</data>
|
183
|
+
</environment>
|
184
|
+
</eeml>
|
185
|
+
XML
|
186
|
+
else
|
187
|
+
xml = <<XML
|
188
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
189
|
+
<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">
|
190
|
+
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://appdev.loc:3000/users/occaecati">
|
191
|
+
<data id="0">
|
192
|
+
<tag>freakin lasers</tag>
|
193
|
+
<tag>humidity</tag>
|
194
|
+
<tag>Temperature</tag>
|
195
|
+
<current_value at="2011-02-16T16:21:01.834174Z">14</current_value>
|
196
|
+
<max_value>658.0</max_value>
|
197
|
+
<min_value>0.0</min_value>
|
198
|
+
<unit type="derivedSI" symbol="A">Alpha</unit>
|
199
|
+
<datapoints>
|
200
|
+
<value at="2011-03-02T15:59:56.895922Z">1</value>
|
201
|
+
<value at="2011-03-02T16:00:07.188648Z">1</value>
|
202
|
+
<value at="2011-03-02T16:00:18.416500Z">2</value>
|
203
|
+
</datapoints>
|
204
|
+
</data>
|
205
|
+
</environment>
|
206
|
+
</eeml>
|
207
|
+
XML
|
208
|
+
end
|
209
|
+
when "5"
|
210
|
+
if except_node == :tag
|
211
|
+
xml = <<XML
|
212
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
213
|
+
<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">
|
214
|
+
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://appdev.loc:3000/users/occaecati">
|
215
|
+
<data id="0">
|
216
|
+
<value maxValue="658.0" minValue="658">14</value>
|
217
|
+
<unit type="derivedSI" symbol="A">Alpha</unit>
|
218
|
+
</data>
|
219
|
+
</environment>
|
220
|
+
</eeml>
|
221
|
+
XML
|
222
|
+
elsif except_node == :unit
|
223
|
+
xml = <<XML
|
224
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
225
|
+
<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">
|
226
|
+
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://appdev.loc:3000/users/occaecati">
|
227
|
+
<data id="0">
|
228
|
+
<tag>freakin lasers</tag>
|
229
|
+
<tag>humidity</tag>
|
230
|
+
<tag>Temperature</tag>
|
231
|
+
<value maxValue="658.0" minValue="658">14</value>
|
232
|
+
</data>
|
233
|
+
</environment>
|
234
|
+
</eeml>
|
235
|
+
XML
|
236
|
+
elsif except_node == :unit_attributes
|
237
|
+
xml = <<XML
|
238
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
239
|
+
<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">
|
240
|
+
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://appdev.loc:3000/users/occaecati">
|
241
|
+
<data id="0">
|
242
|
+
<tag>freakin lasers</tag>
|
243
|
+
<tag>humidity</tag>
|
244
|
+
<tag>Temperature</tag>
|
245
|
+
<value maxValue="658.0" minValue="658">14</value>
|
246
|
+
<unit>Alpha</unit>
|
247
|
+
</data>
|
248
|
+
</environment>
|
249
|
+
</eeml>
|
250
|
+
XML
|
251
|
+
elsif except_node == :value_attributes
|
252
|
+
xml = <<XML
|
253
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
254
|
+
<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">
|
255
|
+
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://appdev.loc:3000/users/occaecati">
|
256
|
+
<data id="0">
|
257
|
+
<tag>freakin lasers</tag>
|
258
|
+
<tag>humidity</tag>
|
259
|
+
<tag>Temperature</tag>
|
260
|
+
<value>14</value>
|
261
|
+
<unit type="derivedSI" symbol="A">Alpha</unit>
|
262
|
+
</data>
|
263
|
+
</environment>
|
264
|
+
</eeml>
|
265
|
+
XML
|
266
|
+
elsif except_node == :timestamps
|
267
|
+
xml = <<XML
|
268
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
269
|
+
<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">
|
270
|
+
<environment id="504" creator="http://appdev.loc:3000/users/occaecati">
|
271
|
+
<data id="0">
|
272
|
+
<tag>freakin lasers</tag>
|
273
|
+
<tag>humidity</tag>
|
274
|
+
<tag>Temperature</tag>
|
275
|
+
<value maxValue="658.0" minValue="658">14</value>
|
276
|
+
<unit type="derivedSI" symbol="A">Alpha</unit>
|
277
|
+
</data>
|
278
|
+
</environment>
|
279
|
+
</eeml>
|
280
|
+
XML
|
281
|
+
else
|
282
|
+
xml = <<XML
|
283
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
284
|
+
<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">
|
285
|
+
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://appdev.loc:3000/users/occaecati">
|
286
|
+
<data id="0">
|
287
|
+
<tag>freakin lasers</tag>
|
288
|
+
<tag>humidity</tag>
|
289
|
+
<tag>Temperature</tag>
|
290
|
+
<value maxValue="658.0" minValue="658">14</value>
|
291
|
+
<unit type="derivedSI" symbol="A">Alpha</unit>
|
292
|
+
</data>
|
293
|
+
</environment>
|
294
|
+
</eeml>
|
295
|
+
XML
|
296
|
+
end
|
297
|
+
else
|
298
|
+
raise "Datastream as XML #{version} not implemented"
|
299
|
+
end
|
300
|
+
end
|
@@ -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["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["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
|
+
|