eeml 0.0.18 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +18 -0
- data/Rakefile +1 -1
- data/lib/eeml/environment.rb +2 -0
- data/lib/eeml/json_environment_parser_v100.rb +2 -0
- data/lib/eeml/json_output.rb +2 -1
- data/lib/eeml/libxml_eeml_output_v051.rb +6 -0
- data/lib/eeml/libxml_eeml_parser_v005.rb +1 -1
- data/lib/eeml/libxml_eeml_parser_v051.rb +5 -1
- data/lib/eeml.rb +1 -1
- data/schemas/eeml/0.5.1.xsd +159 -0
- data/schemas/eeml/005.xsd +1 -1
- data/test/data/doc_1_non_private.json +31 -0
- data/test/data/doc_1_non_private.xml +33 -0
- data/test/data/doc_1_v6_non_private.json +31 -0
- data/test/data/environment_tags.json +41 -0
- data/test/data/environment_tags.xml +14 -0
- data/test/test_environment.rb +35 -0
- metadata +12 -5
data/CHANGELOG
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
commit 4c88cb1fe13661dbba20fca4877491c54a265a2a
|
2
|
+
Author: Paul Bellamy <paul@connectedenvironments.com>
|
3
|
+
Date: Fri Aug 20 19:12:34 2010 +0100
|
4
|
+
|
5
|
+
Version 0.0.20
|
6
|
+
|
7
|
+
Added environment level tagging to xml v0.5.1 and json v1.0.0
|
8
|
+
|
9
|
+
commit 927d8b9ec12bdf277953f591301d01dc4bcfe9d9
|
10
|
+
Author: Paul Bellamy <paul@connectedenvironments.com>
|
11
|
+
Date: Wed Aug 18 11:41:12 2010 +0100
|
12
|
+
|
13
|
+
Version 0.0.19
|
14
|
+
|
15
|
+
Fix for parsing private boolean values
|
16
|
+
|
17
|
+
Was just returning a string (always true), so now compares with == "true"
|
18
|
+
|
1
19
|
commit 9835edb290ef16b274d9ab59e3c6adca2ce97fcf
|
2
20
|
Author: Levent Ali <lebreeze@gmail.com>
|
3
21
|
Date: Wed Jul 7 18:48:34 2010 +0100
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ begin
|
|
10
10
|
gem.summary = "Simple little library for programmatically manipulating EEML documents."
|
11
11
|
gem.description = "Simple little library for programmatically manipulating EEML documents, in particular this library is designed to work with the Pachube web service."
|
12
12
|
gem.email = "sam.mulube@gmail.com"
|
13
|
-
gem.authors = ["Neill Bogie", "Sam Mulube", "Levent Ali"]
|
13
|
+
gem.authors = ["Neill Bogie", "Sam Mulube", "Levent Ali", "Paul Bellamy"]
|
14
14
|
gem.version = Eeml::VERSION
|
15
15
|
gem.add_dependency("libxml-ruby", ">=1.1.3")
|
16
16
|
gem.add_dependency("json", ">=1.4.3")
|
data/lib/eeml/environment.rb
CHANGED
@@ -100,6 +100,7 @@ module Eeml
|
|
100
100
|
attr_accessor :title, :description, :feed_url, :website, :email, :icon, :status
|
101
101
|
attr_accessor :location
|
102
102
|
attr_accessor :datastreams
|
103
|
+
attr_accessor :tags
|
103
104
|
attr_writer :private
|
104
105
|
|
105
106
|
# Create a new Environment object by passing parameters in a hash (just like creating an ActiveRecord object)
|
@@ -115,6 +116,7 @@ module Eeml
|
|
115
116
|
@email = options[:email]
|
116
117
|
@icon = options[:icon]
|
117
118
|
@private = options[:private]
|
119
|
+
@tags = []
|
118
120
|
end
|
119
121
|
|
120
122
|
def add_datastream(datastream)
|
@@ -16,6 +16,8 @@ module Eeml
|
|
16
16
|
|
17
17
|
env.updated = Time.gm(*ParseDate.parsedate(env_hash['updated'])) unless env_hash['updated'].nil?
|
18
18
|
|
19
|
+
env.tags = env_hash['tags'] unless env_hash['tags'].nil?
|
20
|
+
|
19
21
|
env.location = buildLocation(env_hash)
|
20
22
|
|
21
23
|
env.datastreams = buildDatastreams(env_hash)
|
data/lib/eeml/json_output.rb
CHANGED
@@ -16,7 +16,8 @@ module Eeml
|
|
16
16
|
:website => environment.website,
|
17
17
|
:email => environment.email,
|
18
18
|
:icon => environment.icon,
|
19
|
-
:version => EEML['0.5.0'][:version]
|
19
|
+
:version => EEML['0.5.0'][:version],
|
20
|
+
:tags => environment.tags }
|
20
21
|
|
21
22
|
environment_hash[:updated] = environment.updated.utc.iso8601 unless environment.updated.nil? #TODO: was retrieved_at
|
22
23
|
|
@@ -59,6 +59,12 @@ module Eeml
|
|
59
59
|
email_node << environment.email
|
60
60
|
end
|
61
61
|
|
62
|
+
environment.tags.each do |tag|
|
63
|
+
tag_node = XML::Node.new('tag')
|
64
|
+
tag_node << tag
|
65
|
+
datastream_node << tag_node
|
66
|
+
end
|
67
|
+
|
62
68
|
unless environment.location.nil?
|
63
69
|
environment_node << location_node = XML::Node.new('location')
|
64
70
|
location_node['domain'] = environment.location.domain
|
@@ -79,7 +79,7 @@ module Eeml
|
|
79
79
|
env.status = optional_content(env_node, 'x:status', 'status', "x:#{@@eeml_version[:href]}")
|
80
80
|
env.email = optional_content(env_node, 'x:email', 'email', "x:#{@@eeml_version[:href]}")
|
81
81
|
env.icon = optional_content(env_node, 'x:icon', 'icon', "x:#{@@eeml_version[:href]}")
|
82
|
-
env.private = optional_content(env_node, 'x:private', 'private', "x:#{@@eeml_version[:href]}")
|
82
|
+
env.private = (optional_content(env_node, 'x:private', 'private', "x:#{@@eeml_version[:href]}") == "true")
|
83
83
|
|
84
84
|
#find_first_node_or_fail(env_node, 'x:location', 'location')
|
85
85
|
loc_node = env_node.find_first('x:location', "x:#{@@eeml_version[:href]}")
|
@@ -79,12 +79,16 @@ module Eeml
|
|
79
79
|
env.status = optional_content(env_node, 'x:status', 'status', "x:#{@@eeml_version[:href]}")
|
80
80
|
env.email = optional_content(env_node, 'x:email', 'email', "x:#{@@eeml_version[:href]}")
|
81
81
|
env.icon = optional_content(env_node, 'x:icon', 'icon', "x:#{@@eeml_version[:href]}")
|
82
|
-
env.private = optional_content(env_node, 'x:private', 'private', "x:#{@@eeml_version[:href]}")
|
82
|
+
env.private = (optional_content(env_node, 'x:private', 'private', "x:#{@@eeml_version[:href]}") == "true")
|
83
83
|
|
84
84
|
#find_first_node_or_fail(env_node, 'x:location', 'location')
|
85
85
|
loc_node = env_node.find_first('x:location', "x:#{@@eeml_version[:href]}")
|
86
86
|
env.location = extractLocation(loc_node) if loc_node
|
87
87
|
|
88
|
+
env_node.find('x:tag', "x:#{@@eeml_version[:href]}").each do |tag_node|
|
89
|
+
env.tags << tag_node.content.strip
|
90
|
+
end
|
91
|
+
|
88
92
|
datastream_nodes = env_node.find('x:data', "x:#{@@eeml_version[:href]}")
|
89
93
|
# raise NoDataStreams.new, "no datastreams found" if datastream_nodes.empty?
|
90
94
|
env.datastreams = extractDataStreams(datastream_nodes) unless datastream_nodes.empty?
|
data/lib/eeml.rb
CHANGED
@@ -0,0 +1,159 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<xsd:schema xmlns="http://www.eeml.org/xsd/0.5.1" elementFormDefault="qualified" targetNamespace="http://www.eeml.org/xsd/0.5.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
3
|
+
<xsd:element name="eeml">
|
4
|
+
<xsd:complexType>
|
5
|
+
<xsd:choice>
|
6
|
+
<xsd:element maxOccurs="unbounded" name="environment">
|
7
|
+
<xsd:complexType>
|
8
|
+
<xsd:sequence>
|
9
|
+
<xsd:element minOccurs="0" name="title" type="xsd:string" />
|
10
|
+
<xsd:element minOccurs="0" name="feed" type="xsd:anyURI" />
|
11
|
+
<xsd:element minOccurs="0" name="status">
|
12
|
+
<xsd:simpleType>
|
13
|
+
<xsd:restriction base="xsd:string">
|
14
|
+
<xsd:enumeration value="frozen" />
|
15
|
+
<xsd:enumeration value="live" />
|
16
|
+
</xsd:restriction>
|
17
|
+
</xsd:simpleType>
|
18
|
+
</xsd:element>
|
19
|
+
<xsd:element minOccurs="0" name="private">
|
20
|
+
<xsd:simpleType>
|
21
|
+
<xsd:restriction base="xsd:string">
|
22
|
+
<xsd:enumeration value="true" />
|
23
|
+
<xsd:enumeration value="false" />
|
24
|
+
</xsd:restriction>
|
25
|
+
</xsd:simpleType>
|
26
|
+
</xsd:element>
|
27
|
+
<xsd:element minOccurs="0" name="description" type="xsd:string" />
|
28
|
+
<xsd:element minOccurs="0" name="icon" type="xsd:anyURI" />
|
29
|
+
<xsd:element minOccurs="0" name="website" type="xsd:anyURI" />
|
30
|
+
<xsd:element minOccurs="0" name="email" type="xsd:string" />
|
31
|
+
<xsd:element minOccurs="0" maxOccurs="unbounded" name="tag" type="xsd:string" />
|
32
|
+
<xsd:element minOccurs="0" name="location">
|
33
|
+
<xsd:complexType>
|
34
|
+
<xsd:sequence>
|
35
|
+
<xsd:element minOccurs="0" name="name" type="xsd:string" />
|
36
|
+
<xsd:element name="lat">
|
37
|
+
<xsd:simpleType>
|
38
|
+
<xsd:restriction base="xsd:double">
|
39
|
+
<xsd:minInclusive value="-90" />
|
40
|
+
<xsd:maxInclusive value="90" />
|
41
|
+
</xsd:restriction>
|
42
|
+
</xsd:simpleType>
|
43
|
+
</xsd:element>
|
44
|
+
<xsd:element name="lon">
|
45
|
+
<xsd:simpleType>
|
46
|
+
<xsd:restriction base="xsd:double">
|
47
|
+
<xsd:minInclusive value="-180" />
|
48
|
+
<xsd:maxInclusive value="180" />
|
49
|
+
</xsd:restriction>
|
50
|
+
</xsd:simpleType>
|
51
|
+
</xsd:element>
|
52
|
+
<xsd:element minOccurs="0" maxOccurs="1" name="ele" type="xsd:double" />
|
53
|
+
</xsd:sequence>
|
54
|
+
<xsd:attribute name="exposure" use="optional">
|
55
|
+
<xsd:simpleType>
|
56
|
+
<xsd:restriction base="xsd:string">
|
57
|
+
<xsd:enumeration value="indoor" />
|
58
|
+
<xsd:enumeration value="outdoor" />
|
59
|
+
</xsd:restriction>
|
60
|
+
</xsd:simpleType>
|
61
|
+
</xsd:attribute>
|
62
|
+
<xsd:attribute name="domain" use="required">
|
63
|
+
<xsd:simpleType>
|
64
|
+
<xsd:restriction base="xsd:string">
|
65
|
+
<xsd:enumeration value="physical" />
|
66
|
+
<xsd:enumeration value="virtual" />
|
67
|
+
</xsd:restriction>
|
68
|
+
</xsd:simpleType>
|
69
|
+
</xsd:attribute>
|
70
|
+
<xsd:attribute name="disposition" use="optional">
|
71
|
+
<xsd:simpleType>
|
72
|
+
<xsd:restriction base="xsd:string">
|
73
|
+
<xsd:enumeration value="fixed" />
|
74
|
+
<xsd:enumeration value="mobile" />
|
75
|
+
</xsd:restriction>
|
76
|
+
</xsd:simpleType>
|
77
|
+
</xsd:attribute>
|
78
|
+
</xsd:complexType>
|
79
|
+
</xsd:element>
|
80
|
+
<xsd:element minOccurs="1" maxOccurs="unbounded" name="data">
|
81
|
+
<xsd:complexType>
|
82
|
+
<xsd:sequence>
|
83
|
+
<xsd:element minOccurs="0" maxOccurs="unbounded" name="tag" type="xsd:string" />
|
84
|
+
<xsd:element name="current_value">
|
85
|
+
<xsd:complexType>
|
86
|
+
<xsd:simpleContent>
|
87
|
+
<xsd:extension base="xsd:string">
|
88
|
+
<xsd:attribute name="at" type="xsd:dateTime" use="optional" />
|
89
|
+
</xsd:extension>
|
90
|
+
</xsd:simpleContent>
|
91
|
+
</xsd:complexType>
|
92
|
+
</xsd:element>
|
93
|
+
<xsd:element minOccurs="0" maxOccurs="1" name="max_value" type="xsd:string" />
|
94
|
+
<xsd:element minOccurs="0" maxOccurs="1" name="min_value" type="xsd:string" />
|
95
|
+
<xsd:element minOccurs="0" maxOccurs="1" name="datapoints">
|
96
|
+
<xsd:complexType>
|
97
|
+
<xsd:sequence>
|
98
|
+
<xsd:element minOccurs="0" maxOccurs="unbounded" name="value">
|
99
|
+
<xsd:complexType>
|
100
|
+
<xsd:simpleContent>
|
101
|
+
<xsd:extension base="xsd:string">
|
102
|
+
<xsd:attribute name="at" type="xsd:dateTime" use="optional" />
|
103
|
+
</xsd:extension>
|
104
|
+
</xsd:simpleContent>
|
105
|
+
</xsd:complexType>
|
106
|
+
</xsd:element>
|
107
|
+
</xsd:sequence>
|
108
|
+
</xsd:complexType>
|
109
|
+
</xsd:element>
|
110
|
+
<xsd:element minOccurs="0" maxOccurs="1" name="unit">
|
111
|
+
<xsd:complexType>
|
112
|
+
<xsd:simpleContent>
|
113
|
+
<xsd:extension base="xsd:string">
|
114
|
+
<xsd:attribute name="symbol" type="xsd:string" use="optional">
|
115
|
+
</xsd:attribute>
|
116
|
+
<xsd:attribute name="type" use="optional">
|
117
|
+
<xsd:simpleType>
|
118
|
+
<xsd:restriction base="xsd:string">
|
119
|
+
<xsd:enumeration value="basicSI" />
|
120
|
+
<xsd:enumeration value="derivedSI" />
|
121
|
+
<xsd:enumeration value="conversionBasedUnits" />
|
122
|
+
<xsd:enumeration value="derivedUnits" />
|
123
|
+
<xsd:enumeration value="contextDependentUnits" />
|
124
|
+
</xsd:restriction>
|
125
|
+
</xsd:simpleType>
|
126
|
+
</xsd:attribute>
|
127
|
+
</xsd:extension>
|
128
|
+
</xsd:simpleContent>
|
129
|
+
</xsd:complexType>
|
130
|
+
</xsd:element>
|
131
|
+
</xsd:sequence>
|
132
|
+
<xsd:attribute name="id" type="xsd:nonNegativeInteger" use="required" />
|
133
|
+
</xsd:complexType>
|
134
|
+
</xsd:element>
|
135
|
+
</xsd:sequence>
|
136
|
+
<xsd:attribute name="updated" use="optional">
|
137
|
+
<xsd:simpleType>
|
138
|
+
<xsd:restriction base="xsd:dateTime" />
|
139
|
+
</xsd:simpleType>
|
140
|
+
</xsd:attribute>
|
141
|
+
<xsd:attribute name="creator" use="optional">
|
142
|
+
<xsd:simpleType>
|
143
|
+
<xsd:restriction base="xsd:string" />
|
144
|
+
</xsd:simpleType>
|
145
|
+
</xsd:attribute>
|
146
|
+
<xsd:attribute name="id" type="xsd:nonNegativeInteger" use="optional" />
|
147
|
+
</xsd:complexType>
|
148
|
+
</xsd:element>
|
149
|
+
</xsd:choice>
|
150
|
+
<xsd:attribute name="version" use="optional">
|
151
|
+
<xsd:simpleType>
|
152
|
+
<xsd:restriction base="xsd:string">
|
153
|
+
<xsd:enumeration value="0.5.1" />
|
154
|
+
</xsd:restriction>
|
155
|
+
</xsd:simpleType>
|
156
|
+
</xsd:attribute>
|
157
|
+
</xsd:complexType>
|
158
|
+
</xsd:element>
|
159
|
+
</xsd:schema>
|
data/schemas/eeml/005.xsd
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
{"datastreams":[
|
2
|
+
{"tags":["tagD0"],
|
3
|
+
"value":{"current_value":"0","min_value":"-9999.0","max_value":"1022.0"},
|
4
|
+
"unit":{"type":"basicSI","label":"Celsius","symbol":"C"},
|
5
|
+
"id":"0"},
|
6
|
+
{"value":{"current_value":"33","min_value":"0.0","max_value":"1023.0"},
|
7
|
+
"id":"1"},
|
8
|
+
{"tags":["tagD2a","tagD2b","tagD2c"],
|
9
|
+
"value":{"current_value":"42.1","min_value":"23.4","max_value":"1021.0"},
|
10
|
+
"id":"2"}
|
11
|
+
],
|
12
|
+
"description":"description here",
|
13
|
+
"updated":"2009-02-11T10:56:56Z",
|
14
|
+
"status":"frozen",
|
15
|
+
"website":"http:\/\/example.com\/studio\/",
|
16
|
+
"email":"someone@example.com",
|
17
|
+
"feed":"http:\/\/example.com\/api\/1247.xml",
|
18
|
+
"private":false,
|
19
|
+
"location":{
|
20
|
+
"lat":"50.1",
|
21
|
+
"lon":"48.7",
|
22
|
+
"ele":"1.34",
|
23
|
+
"name":"Up on the roof (somewhere)",
|
24
|
+
"domain":"physical",
|
25
|
+
"exposure":"outdoor",
|
26
|
+
"disposition":"mobile"
|
27
|
+
},
|
28
|
+
"icon":"http:\/\/example.com\/some\/icon.gif",
|
29
|
+
"id":"1247",
|
30
|
+
"title":"title here",
|
31
|
+
"version":"5"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<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">
|
3
|
+
<environment updated="2009-02-11T10:56:56Z" id="1247" creator="http://example.com/creator/">
|
4
|
+
<title>title here</title>
|
5
|
+
<feed>http://example.com/api/1247.xml</feed>
|
6
|
+
<status>frozen</status>
|
7
|
+
<description>description here</description>
|
8
|
+
<icon>http://example.com/some/icon.gif</icon>
|
9
|
+
<website>http://example.com/studio/</website>
|
10
|
+
<email>someone@example.com</email>
|
11
|
+
<private>false</private>
|
12
|
+
<location domain="physical" exposure="outdoor" disposition="mobile">
|
13
|
+
<name>Up on the roof (somewhere)</name>
|
14
|
+
<lat>50.1</lat>
|
15
|
+
<lon>48.7</lon>
|
16
|
+
<ele>1.34</ele>
|
17
|
+
</location>
|
18
|
+
<data id="0">
|
19
|
+
<tag>tagD0</tag>
|
20
|
+
<value minValue="-9999.0" maxValue="1022.0">0</value>
|
21
|
+
<unit type="basicSI" symbol="C">Celsius</unit>
|
22
|
+
</data>
|
23
|
+
<data id="1">
|
24
|
+
<value minValue="0.0" maxValue="1023.0">33</value>
|
25
|
+
</data>
|
26
|
+
<data id="2">
|
27
|
+
<tag>tagD2a</tag>
|
28
|
+
<tag>tagD2b</tag>
|
29
|
+
<tag>tagD2c</tag>
|
30
|
+
<value minValue="23.4" maxValue="1021.0">42.1</value>
|
31
|
+
</data>
|
32
|
+
</environment>
|
33
|
+
</eeml>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
{"datastreams":[
|
2
|
+
{"tags":["tagD0"],
|
3
|
+
"values":[{"value":"0","min_value":"-9999.0","max_value":"1022.0","recorded_at":"2009-02-11T10:56:56Z"}],
|
4
|
+
"unit":{"type":"basicSI","label":"Celsius","symbol":"C"},
|
5
|
+
"id":"0"},
|
6
|
+
{"values":[{"value":"33","min_value":"0.0","max_value":"1023.0","recorded_at":"2009-02-11T10:56:55Z"}],
|
7
|
+
"id":"1"},
|
8
|
+
{"tags":["tagD2a","tagD2b","tagD2c"],
|
9
|
+
"values":[{"value":"42.1","min_value":"23.4","max_value":"1021.0","recorded_at":"2009-02-11T10:55:10Z"}],
|
10
|
+
"id":"2"}
|
11
|
+
],
|
12
|
+
"description":"description here",
|
13
|
+
"updated":"2009-02-11T10:56:56Z",
|
14
|
+
"status":"frozen",
|
15
|
+
"website":"http:\/\/example.com\/studio\/",
|
16
|
+
"email":"someone@example.com",
|
17
|
+
"feed":"http:\/\/example.com\/api\/1247.xml",
|
18
|
+
"private":false,
|
19
|
+
"location":{
|
20
|
+
"lat":"50.1",
|
21
|
+
"lon":"48.7",
|
22
|
+
"ele":"1.34",
|
23
|
+
"name":"Up on the roof (somewhere)",
|
24
|
+
"domain":"physical",
|
25
|
+
"exposure":"outdoor",
|
26
|
+
"disposition":"mobile"
|
27
|
+
},
|
28
|
+
"icon":"http:\/\/example.com\/some\/icon.gif",
|
29
|
+
"id":"1247",
|
30
|
+
"title":"title here",
|
31
|
+
"version":"0.6"}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
{"datastreams":[
|
2
|
+
{
|
3
|
+
"tags":["tagD0"],
|
4
|
+
"current_value":"0",
|
5
|
+
"at":"2009-02-11T10:56:56Z",
|
6
|
+
"min_value":"-9999.0",
|
7
|
+
"max_value":"1022.0",
|
8
|
+
"unit":{"type":"basicSI","label":"Celsius","symbol":"C"},
|
9
|
+
"id":"0"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"current_value":"33",
|
13
|
+
"at":"2009-02-11T10:56:55Z",
|
14
|
+
"min_value":"0.0","max_value":"1023.0",
|
15
|
+
"id":"1"},
|
16
|
+
{"tags":["tagD2a","tagD2b","tagD2c"],
|
17
|
+
"current_value":"42.1",
|
18
|
+
"at":"2009-02-11T10:55:10Z",
|
19
|
+
"min_value":"23.4","max_value":"1021.0",
|
20
|
+
"id":"2"}
|
21
|
+
],
|
22
|
+
"description":"description here",
|
23
|
+
"updated":"2010-02-11T10:56:56Z",
|
24
|
+
"status":"frozen",
|
25
|
+
"website":"http:\/\/example.com\/studio\/",
|
26
|
+
"email":"someone@example.com",
|
27
|
+
"feed":"http:\/\/example.com\/api\/1247.xml",
|
28
|
+
"location":{
|
29
|
+
"lat":"50.1",
|
30
|
+
"lon":"48.7",
|
31
|
+
"ele":"1.34",
|
32
|
+
"name":"Up on the roof (somewhere)",
|
33
|
+
"domain":"physical",
|
34
|
+
"exposure":"outdoor",
|
35
|
+
"disposition":"mobile"
|
36
|
+
},
|
37
|
+
"icon":"http:\/\/example.com\/some\/icon.gif",
|
38
|
+
"id":"1247",
|
39
|
+
"title":"title here",
|
40
|
+
"version":"1.0.0",
|
41
|
+
"tags":["tagE0", "tagE1"]}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<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">
|
3
|
+
<environment>
|
4
|
+
<tag>Cambodia</tag>
|
5
|
+
<tag>House</tag>
|
6
|
+
<data id="0">
|
7
|
+
<tag>sometag</tag>
|
8
|
+
<current_value>65</current_value>
|
9
|
+
<max_value>100.0</max_value>
|
10
|
+
<min_value>4.0</min_value>
|
11
|
+
</data>
|
12
|
+
</environment>
|
13
|
+
</eeml>
|
14
|
+
|
data/test/test_environment.rb
CHANGED
@@ -180,6 +180,11 @@ class TestEnvironment < Test::Unit::TestCase
|
|
180
180
|
assert_equal true, env.private
|
181
181
|
end
|
182
182
|
|
183
|
+
test "captures the `private` attribute as false if present and false" do
|
184
|
+
env = create_env_from_xml_file("doc_1_non_private.xml")
|
185
|
+
assert_equal false, env.private
|
186
|
+
end
|
187
|
+
|
183
188
|
test "ok parsing oddly tagged eeml file" do
|
184
189
|
env = create_env_from_xml_file('difficult_tag.xml')
|
185
190
|
assert_equal 2, env.datastreams.size
|
@@ -196,6 +201,16 @@ class TestEnvironment < Test::Unit::TestCase
|
|
196
201
|
assert_equal 'celsius', d.unit_value
|
197
202
|
end
|
198
203
|
|
204
|
+
test "parses environment level tags from v051 xml" do
|
205
|
+
env = create_env_from_xml_file('environment_tags.xml')
|
206
|
+
|
207
|
+
assert_equal 2, env.tags.size
|
208
|
+
assert_equal 'Cambodia', env.tags[0]
|
209
|
+
assert_equal 'House', env.tags[1]
|
210
|
+
|
211
|
+
assert_equal 1, env.datastreams.size
|
212
|
+
end
|
213
|
+
|
199
214
|
test "creates multiple environments from list xml" do
|
200
215
|
xml = File.read('test/data/list.xml')
|
201
216
|
list = Environment.new_list_from_eeml(xml)
|
@@ -429,6 +444,15 @@ class TestEnvironment < Test::Unit::TestCase
|
|
429
444
|
end
|
430
445
|
end
|
431
446
|
|
447
|
+
test "parses environment level tags from v1.0.0 json" do
|
448
|
+
env = create_env_from_json_file('test/data/environment_tags.json')
|
449
|
+
assert_equal 3, env.datastreams.size
|
450
|
+
|
451
|
+
assert_equal 2, env.tags.size
|
452
|
+
assert_equal env.tags[0], 'tagE0'
|
453
|
+
assert_equal env.tags[1], 'tagE1'
|
454
|
+
end
|
455
|
+
|
432
456
|
test "parses a v6 input file ok" do
|
433
457
|
env = create_env_from_json_v6_file_one
|
434
458
|
assert_not_nil env
|
@@ -497,12 +521,23 @@ class TestEnvironment < Test::Unit::TestCase
|
|
497
521
|
assert_equal true, env.private
|
498
522
|
end
|
499
523
|
|
524
|
+
test "captures the `private` attribute as false if present and false when parsing old json" do
|
525
|
+
env = create_env_from_json_file("test/data/doc_1_non_private.json")
|
526
|
+
assert_equal false, env.private
|
527
|
+
end
|
528
|
+
|
500
529
|
test "captures `private` attribute when parsing v6 json" do
|
501
530
|
env = create_env_from_json_file("test/data/doc_1_v6_private.json")
|
502
531
|
assert_not_nil env
|
503
532
|
assert_equal true, env.private
|
504
533
|
end
|
505
534
|
|
535
|
+
test "captures the `private` attribute as false if present and false when parsing v6 json" do
|
536
|
+
env = create_env_from_json_file("test/data/doc_1_v6_non_private.json")
|
537
|
+
assert_not_nil env
|
538
|
+
assert_equal false, env.private
|
539
|
+
end
|
540
|
+
|
506
541
|
# --- -------------------------------------------------------
|
507
542
|
# --- csv input stuff -------------------------------------------------------
|
508
543
|
# --- -------------------------------------------------------
|
metadata
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eeml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 53
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 21
|
10
|
+
version: 0.0.21
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Neill Bogie
|
14
14
|
- Sam Mulube
|
15
15
|
- Levent Ali
|
16
|
+
- Paul Bellamy
|
16
17
|
autorequire:
|
17
18
|
bindir: bin
|
18
19
|
cert_chain: []
|
19
20
|
|
20
|
-
date: 2010-
|
21
|
+
date: 2010-08-20 00:00:00 +01:00
|
21
22
|
default_executable:
|
22
23
|
dependencies:
|
23
24
|
- !ruby/object:Gem::Dependency
|
@@ -85,20 +86,26 @@ files:
|
|
85
86
|
- lib/eeml/libxml_eeml_parser_v005.rb
|
86
87
|
- lib/eeml/libxml_eeml_parser_v051.rb
|
87
88
|
- lib/eeml/output_registry.rb
|
89
|
+
- schemas/eeml/0.5.1.xsd
|
88
90
|
- schemas/eeml/005.xsd
|
89
91
|
- test/data/.gitignore
|
90
92
|
- test/data/complete_namespaced.xml
|
91
93
|
- test/data/difficult_tag.xml
|
92
94
|
- test/data/doc_1.json
|
93
95
|
- test/data/doc_1.xml
|
96
|
+
- test/data/doc_1_non_private.json
|
97
|
+
- test/data/doc_1_non_private.xml
|
94
98
|
- test/data/doc_1_private.json
|
95
99
|
- test/data/doc_1_private.xml
|
96
100
|
- test/data/doc_1_v1-0-0.json
|
97
101
|
- test/data/doc_1_v6.json
|
102
|
+
- test/data/doc_1_v6_non_private.json
|
98
103
|
- test/data/doc_1_v6_private.json
|
99
104
|
- test/data/doc_2.xml
|
100
105
|
- test/data/doc_2_expected.json
|
101
106
|
- test/data/eeml_datastream_051.xml
|
107
|
+
- test/data/environment_tags.json
|
108
|
+
- test/data/environment_tags.xml
|
102
109
|
- test/data/list.xml
|
103
110
|
- test/data/minimal.xml
|
104
111
|
- test/data/no_namespace.xml
|
@@ -144,7 +151,7 @@ specification_version: 3
|
|
144
151
|
summary: Simple little library for programmatically manipulating EEML documents.
|
145
152
|
test_files:
|
146
153
|
- test/test_helper.rb
|
147
|
-
- test/test_libxml_eeml_parser_v005.rb
|
148
154
|
- test/test_libxml_test_helper.rb
|
155
|
+
- test/test_libxml_eeml_parser_v005.rb
|
149
156
|
- test/test_environment.rb
|
150
157
|
- test/libxml_test_helper.rb
|