eeml 0.0.36 → 0.0.37
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/eeml.rb +1 -2
- data/lib/eeml/constants.rb +0 -8
- data/lib/eeml/environment.rb +9 -11
- data/lib/eeml/environment_builder.rb +0 -3
- data/lib/eeml/json_environment_parser_v100.rb +1 -1
- data/test/data/doc_1_v1-0-0.json +1 -1
- data/test/test_environment.rb +1 -27
- metadata +6 -11
- data/lib/eeml/attr_alias.rb +0 -8
- data/lib/eeml/libxml_eeml_parser_v052.rb +0 -217
- data/schemas/eeml/0.5.2.xsd +0 -167
- data/test/data/eeml_datastream_052.xml +0 -40
- data/test/data/environment_minimal_052.xml +0 -8
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ begin
|
|
13
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
|
-
gem.add_dependency("yajl-ruby", ">=0.
|
16
|
+
gem.add_dependency("yajl-ruby", ">=0.8.1")
|
17
17
|
gem.add_dependency("lightcsv", ">=0.2.2")
|
18
18
|
gem.files.exclude("test/data/real_xmls/*")
|
19
19
|
end
|
data/lib/eeml.rb
CHANGED
@@ -6,7 +6,6 @@ require 'blank'
|
|
6
6
|
require 'libxml'
|
7
7
|
require 'yajl/json_gem'
|
8
8
|
require 'lightcsv'
|
9
|
-
require 'eeml/attr_alias'
|
10
9
|
require 'eeml/constants'
|
11
10
|
require 'eeml/exceptions'
|
12
11
|
require 'eeml/helpers'
|
@@ -17,6 +16,6 @@ require 'time'
|
|
17
16
|
module Eeml
|
18
17
|
|
19
18
|
# library version number
|
20
|
-
VERSION = '0.0.
|
19
|
+
VERSION = '0.0.37'
|
21
20
|
|
22
21
|
end #module
|
data/lib/eeml/constants.rb
CHANGED
@@ -21,14 +21,6 @@ module Eeml
|
|
21
21
|
:schema_location => 'http://www.eeml.org/xsd/0.5.1 http://www.eeml.org/xsd/0.5.1/0.5.1.xsd'
|
22
22
|
}
|
23
23
|
|
24
|
-
# This is NEWER than version 5
|
25
|
-
EEML["0.5.2"] =
|
26
|
-
{
|
27
|
-
:href => 'http://www.eeml.org/xsd/0.5.2',
|
28
|
-
:versions => '0.5.2',
|
29
|
-
:schema_location => 'http://www.eeml.org/xsd/0.5.2 http://www.eeml.org/xsd/0.5.2/0.5.2.xsd'
|
30
|
-
}
|
31
|
-
|
32
24
|
JSON_API["0.6-alpha"] =
|
33
25
|
{
|
34
26
|
:versions => ['0.6', '0.6-alpha']
|
data/lib/eeml/environment.rb
CHANGED
@@ -93,27 +93,25 @@ module Eeml
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
# This class represents the main point of entry to this library. In general
|
97
|
-
#
|
98
|
-
#
|
96
|
+
# This class represents the main point of entry to this library. In general
|
97
|
+
# we will be creating instances of this class, either by manually specifying
|
98
|
+
# the parameters, or probably more commonly, by passing in either an EEML or
|
99
|
+
# JSON formatted string which will be parsed to initialize the object.
|
99
100
|
class Environment
|
100
|
-
attr_accessor :identifier, :updated, :publisher
|
101
|
+
attr_accessor :identifier, :updated, :creator, :publisher
|
101
102
|
attr_accessor :title, :description, :feed_url, :website, :email, :icon, :status
|
102
|
-
attr_accessor :owner
|
103
103
|
attr_accessor :location
|
104
104
|
attr_accessor :csv_version
|
105
105
|
attr_accessor :datastreams
|
106
106
|
attr_accessor :tags
|
107
107
|
attr_writer :private
|
108
|
-
attr_accessor :owner
|
109
108
|
|
110
|
-
|
111
|
-
|
112
|
-
# Create a new Environment object by passing parameters in a hash (just like creating an ActiveRecord object)
|
109
|
+
# Create a new Environment object by passing parameters in a hash (just
|
110
|
+
# like creating an ActiveRecord object)
|
113
111
|
def initialize(options = {})
|
114
112
|
@datastreams = []
|
115
113
|
@identifier = options[:identifier]
|
116
|
-
@
|
114
|
+
@creator = options[:creator]
|
117
115
|
@title = options[:title]
|
118
116
|
@status = options[:status]
|
119
117
|
@feed_url = options[:feed_url]
|
@@ -123,7 +121,7 @@ module Eeml
|
|
123
121
|
@icon = options[:icon]
|
124
122
|
@private = options[:private]
|
125
123
|
@csv_version = options[:csv_version]
|
126
|
-
@
|
124
|
+
@publisher = options[:publisher]
|
127
125
|
@tags = []
|
128
126
|
end
|
129
127
|
|
@@ -2,7 +2,6 @@ require 'eeml/csv_parser_v1'
|
|
2
2
|
require 'eeml/csv_parser_v2'
|
3
3
|
require 'eeml/libxml_eeml_parser_v005'
|
4
4
|
require 'eeml/libxml_eeml_parser_v051'
|
5
|
-
require 'eeml/libxml_eeml_parser_v052'
|
6
5
|
require 'eeml/json_environment_parser_v005'
|
7
6
|
require 'eeml/json_environment_parser_v006'
|
8
7
|
require 'eeml/json_environment_parser_v100'
|
@@ -17,8 +16,6 @@ module Eeml
|
|
17
16
|
xml = XML::Parser.string(xml_str).parse
|
18
17
|
if xml.root.namespaces.default.to_s == Constants::EEML['0.5.1'][:href]
|
19
18
|
parser = LibXMLEemlParserV051.new
|
20
|
-
elsif xml.root.namespaces.default.to_s == Constants::EEML['0.5.2'][:href]
|
21
|
-
parser = LibXMLEemlParserV052.new
|
22
19
|
else
|
23
20
|
parser = LibXMLEemlParserV005.new
|
24
21
|
end
|
@@ -14,7 +14,7 @@ module Eeml
|
|
14
14
|
:identifier => env_hash["id"],
|
15
15
|
:private => env_hash["private"].to_s == "true",
|
16
16
|
:publisher => env_hash["publisher"],
|
17
|
-
:
|
17
|
+
:creator => env_hash["creator"])
|
18
18
|
|
19
19
|
env.updated = Time.gm(*ParseDate.parsedate(env_hash['updated'])) unless env_hash['updated'].nil?
|
20
20
|
|
data/test/data/doc_1_v1-0-0.json
CHANGED
data/test/test_environment.rb
CHANGED
@@ -36,24 +36,6 @@ class TestEnvironment < Test::Unit::TestCase
|
|
36
36
|
assert_equal('http://example.com/creator/', env.creator)
|
37
37
|
end
|
38
38
|
|
39
|
-
test "creating minimal Env object from some 0.5.2 eeml" do
|
40
|
-
env = create_env_from_eeml_052
|
41
|
-
|
42
|
-
# simple text nodes available
|
43
|
-
assert_equal("Pachube Office environment", env.title)
|
44
|
-
end
|
45
|
-
|
46
|
-
test "creating complete Env object from some 0.5.2 eeml" do
|
47
|
-
env = create_complete_env_from_eeml_052
|
48
|
-
|
49
|
-
# simple text nodes available
|
50
|
-
assert_equal("title here", env.title)
|
51
|
-
|
52
|
-
# new attributes
|
53
|
-
assert_equal("http://www.pachube.com", env.publisher)
|
54
|
-
assert_equal("http://www.pachube.com/users/joe", env.owner)
|
55
|
-
end
|
56
|
-
|
57
39
|
test 'location parses ok' do
|
58
40
|
env = create_env_from_xml_file_one
|
59
41
|
|
@@ -442,7 +424,7 @@ class TestEnvironment < Test::Unit::TestCase
|
|
442
424
|
|
443
425
|
# new stuff
|
444
426
|
assert_equal("http://www.pachube.com", env.publisher)
|
445
|
-
assert_equal("http://www.pachube.com/users/joe", env.
|
427
|
+
assert_equal("http://www.pachube.com/users/joe", env.creator)
|
446
428
|
end
|
447
429
|
|
448
430
|
test "location parses ok from json when parsing a v1.0.0 file" do
|
@@ -787,12 +769,4 @@ CSV
|
|
787
769
|
return nil if json.nil?
|
788
770
|
json.gsub(/","/, '"' + "\n" + '"').sort
|
789
771
|
end
|
790
|
-
|
791
|
-
def create_env_from_eeml_052
|
792
|
-
return create_env_from_xml_file("environment_minimal_052.xml")
|
793
|
-
end
|
794
|
-
|
795
|
-
def create_complete_env_from_eeml_052
|
796
|
-
return create_env_from_xml_file("eeml_datastream_052.xml")
|
797
|
-
end
|
798
772
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eeml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 85
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 37
|
10
|
+
version: 0.0.37
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Neill Bogie
|
@@ -45,12 +45,12 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
hash:
|
48
|
+
hash: 61
|
49
49
|
segments:
|
50
50
|
- 0
|
51
|
-
- 7
|
52
51
|
- 8
|
53
|
-
|
52
|
+
- 1
|
53
|
+
version: 0.8.1
|
54
54
|
type: :runtime
|
55
55
|
version_requirements: *id002
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -89,7 +89,6 @@ files:
|
|
89
89
|
- example.rb
|
90
90
|
- lib/blank.rb
|
91
91
|
- lib/eeml.rb
|
92
|
-
- lib/eeml/attr_alias.rb
|
93
92
|
- lib/eeml/constants.rb
|
94
93
|
- lib/eeml/csv_parser_v1.rb
|
95
94
|
- lib/eeml/csv_parser_v2.rb
|
@@ -102,9 +101,7 @@ files:
|
|
102
101
|
- lib/eeml/json_environment_parser_v100.rb
|
103
102
|
- lib/eeml/libxml_eeml_parser_v005.rb
|
104
103
|
- lib/eeml/libxml_eeml_parser_v051.rb
|
105
|
-
- lib/eeml/libxml_eeml_parser_v052.rb
|
106
104
|
- schemas/eeml/0.5.1.xsd
|
107
|
-
- schemas/eeml/0.5.2.xsd
|
108
105
|
- schemas/eeml/005.xsd
|
109
106
|
- test/data/.gitignore
|
110
107
|
- test/data/complete_namespaced.xml
|
@@ -122,9 +119,7 @@ files:
|
|
122
119
|
- test/data/doc_2.xml
|
123
120
|
- test/data/doc_2_expected.json
|
124
121
|
- test/data/eeml_datastream_051.xml
|
125
|
-
- test/data/eeml_datastream_052.xml
|
126
122
|
- test/data/environment_minimal_051.xml
|
127
|
-
- test/data/environment_minimal_052.xml
|
128
123
|
- test/data/environment_tags.json
|
129
124
|
- test/data/environment_tags.xml
|
130
125
|
- test/data/list.xml
|
data/lib/eeml/attr_alias.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
class Module
|
2
|
-
def attr_alias(new_attr, original)
|
3
|
-
alias_method(new_attr, original) if method_defined?(original)
|
4
|
-
new_writer = "#{new_attr}="
|
5
|
-
original_writer = "#{original}="
|
6
|
-
alias_method(new_writer, original_writer) if method_defined?(original_writer)
|
7
|
-
end
|
8
|
-
end
|
@@ -1,217 +0,0 @@
|
|
1
|
-
require "parsedate.rb"
|
2
|
-
module Eeml
|
3
|
-
#a parser for xml eeml v052, implemented with LibXML
|
4
|
-
class LibXMLEemlParserV052 # :nodoc:
|
5
|
-
include LibXML
|
6
|
-
include Exceptions
|
7
|
-
|
8
|
-
@@eeml_version = Constants::EEML['0.5.2']
|
9
|
-
#main method
|
10
|
-
|
11
|
-
#take an xml string, and create an Environment from it.
|
12
|
-
#If an optional environment is given, that will be populated (overwritten) instead of a new environment.
|
13
|
-
def make_environment_from_xml(xml_str, given_environment = nil)
|
14
|
-
doc = parse_xml(xml_str)
|
15
|
-
raise MissingNamespace if doc.root.namespaces.namespace.blank?
|
16
|
-
env = given_environment || Environment.new
|
17
|
-
#TODO: what has to be reset in a given environment before passing it for re-population?
|
18
|
-
return extract_environment_from_doc(doc, env)
|
19
|
-
end
|
20
|
-
|
21
|
-
#take an xml string containing zero or more environment nodes, and create an array of Environment objects from it.
|
22
|
-
def make_environments_from_xml(xml_str)
|
23
|
-
doc = parse_xml(xml_str)
|
24
|
-
raise MissingNamespace if doc.root.namespaces.namespace.blank?
|
25
|
-
return extract_environments_from_doc(doc)
|
26
|
-
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
|
30
|
-
def parse_xml(xml_str)
|
31
|
-
errors = []
|
32
|
-
#http://libxml.rubyforge.org/rdoc/classes/LibXML/XML/Error.html
|
33
|
-
#TODO: is the error handler set up per thread? (XML::Error.set_handler)
|
34
|
-
XML::Error.set_handler { |error| errors << error }
|
35
|
-
|
36
|
-
#TODO: performance - is this expensive?
|
37
|
-
#TODO: are these configurations per-thread? If they're global (e.g. class variables) then we shouldn't be setting them here.
|
38
|
-
XML.default_line_numbers=true
|
39
|
-
|
40
|
-
parser = XML::Parser.string(strip_content(xml_str))
|
41
|
-
begin
|
42
|
-
doc = parser.parse
|
43
|
-
rescue XML::Error => e
|
44
|
-
#note: errors var available here, too.
|
45
|
-
raise BadXML, "Malformed xml: #{e.class}: #{e}", e.backtrace
|
46
|
-
end
|
47
|
-
#validation?
|
48
|
-
# seems we have to recreate our XML::Schema object on each invocation
|
49
|
-
# else libxml segfaults very quickly
|
50
|
-
return doc
|
51
|
-
end
|
52
|
-
|
53
|
-
#multiple (zero or more)
|
54
|
-
def extract_environments_from_doc(doc)
|
55
|
-
env_nodes = doc.find('x:environment', "x:#{@@eeml_version[:href]}")
|
56
|
-
return env_nodes.map{|env_node| new_env = Environment.new; extract_environment_from_node(env_node, new_env)}
|
57
|
-
end
|
58
|
-
|
59
|
-
#single, mandatory
|
60
|
-
def extract_environment_from_doc(doc, env_to_populate)
|
61
|
-
env_node = find_first_node_or_fail(doc, 'x:environment', 'environment', "x:#{@@eeml_version[:href]}")
|
62
|
-
return extract_environment_from_node(env_node, env_to_populate)
|
63
|
-
end
|
64
|
-
|
65
|
-
#single, from node (everyone uses this to get the work done)
|
66
|
-
def extract_environment_from_node(env_node, env_to_populate)
|
67
|
-
env = env_to_populate
|
68
|
-
env.identifier = env_node['id']
|
69
|
-
env.updated = Time.parse(env_node['updated']) if !env_node['updated'].nil?
|
70
|
-
|
71
|
-
env.publisher = env_node['publisher']
|
72
|
-
|
73
|
-
env.title = optional_content(env_node, 'x:title', 'title', "x:#{@@eeml_version[:href]}")
|
74
|
-
env.feed_url = optional_content(env_node, 'x:feed', 'feed', "x:#{@@eeml_version[:href]}")
|
75
|
-
env.description = optional_content(env_node, 'x:description', 'description', "x:#{@@eeml_version[:href]}")
|
76
|
-
env.website = optional_content(env_node, 'x:website', 'website', "x:#{@@eeml_version[:href]}")
|
77
|
-
env.status = optional_content(env_node, 'x:status', 'status', "x:#{@@eeml_version[:href]}")
|
78
|
-
env.email = optional_content(env_node, 'x:email', 'email', "x:#{@@eeml_version[:href]}")
|
79
|
-
env.icon = optional_content(env_node, 'x:icon', 'icon', "x:#{@@eeml_version[:href]}")
|
80
|
-
env.private = (optional_content(env_node, 'x:private', 'private', "x:#{@@eeml_version[:href]}") == "true")
|
81
|
-
env.owner = optional_content(env_node, 'x:owner', 'owner', "x:#{@@eeml_version[:href]}")
|
82
|
-
|
83
|
-
#find_first_node_or_fail(env_node, 'x:location', 'location')
|
84
|
-
loc_node = env_node.find_first('x:location', "x:#{@@eeml_version[:href]}")
|
85
|
-
env.location = extractLocation(loc_node) if loc_node
|
86
|
-
|
87
|
-
env_node.find('x:tag', "x:#{@@eeml_version[:href]}").each do |tag_node|
|
88
|
-
env.tags << tag_node.content.strip
|
89
|
-
end
|
90
|
-
|
91
|
-
datastream_nodes = env_node.find('x:data', "x:#{@@eeml_version[:href]}")
|
92
|
-
# raise NoDataStreams.new, "no datastreams found" if datastream_nodes.empty?
|
93
|
-
env.add_datastreams(extractDataStreams(datastream_nodes)) unless datastream_nodes.empty?
|
94
|
-
|
95
|
-
return env
|
96
|
-
end
|
97
|
-
|
98
|
-
def extractLocation(node)
|
99
|
-
#<location domain="physical" exposure="outdoor" disposition="mobile">
|
100
|
-
# <lat>50.1</lat>
|
101
|
-
# <lon>48.7</lon>
|
102
|
-
# <ele>1.34</ele>
|
103
|
-
#</location>
|
104
|
-
raise "given nil node" if node.nil?
|
105
|
-
loc = Location.new
|
106
|
-
loc.domain = node['domain']
|
107
|
-
loc.disposition = node['disposition']
|
108
|
-
loc.exposure = node['exposure']
|
109
|
-
loc.name = optional_content(node, 'x:name', 'name', "x:#{@@eeml_version[:href]}")
|
110
|
-
loc.latitude = optional_content(node, 'x:lat', 'lat', "x:#{@@eeml_version[:href]}")
|
111
|
-
loc.longitude = optional_content(node, 'x:lon', 'lon', "x:#{@@eeml_version[:href]}")
|
112
|
-
loc.elevation = optional_content(node, 'x:ele', 'ele', "x:#{@@eeml_version[:href]}")
|
113
|
-
return loc
|
114
|
-
end
|
115
|
-
|
116
|
-
#return an array (TODO: or a hash?) of DataStream objects from the given list of data nodes
|
117
|
-
def extractDataStreams(nodes)
|
118
|
-
#<data id="blah1">...</data><data id="blah2">...</data>
|
119
|
-
dataStreams = []
|
120
|
-
nodes.each do |node|
|
121
|
-
dataStreams << extractDataStream(node)
|
122
|
-
end
|
123
|
-
return dataStreams
|
124
|
-
end
|
125
|
-
|
126
|
-
#builds and returns a detailed exception of the given class, for problems concerning the given node (or its missing children)
|
127
|
-
#details include node's name and line number (zero if not available)
|
128
|
-
def exception_for_node(node, exception_class, message)
|
129
|
-
ex = exception_class.new(message)
|
130
|
-
ex.line_num = node.line_num
|
131
|
-
ex.node_name = node_name_or_root(node)
|
132
|
-
return ex
|
133
|
-
end
|
134
|
-
|
135
|
-
|
136
|
-
def extractDataStream(node)
|
137
|
-
#<data id="0">
|
138
|
-
#<tag>some_tag</tag>
|
139
|
-
#<tag>another_tag</tag>
|
140
|
-
#<current_value>0</current_value>
|
141
|
-
#<min_value>0.0</min_value>
|
142
|
-
#<max_value>1022.0</max_value>
|
143
|
-
#<unit symbol="C" type="basicSI">Celsius</unit>
|
144
|
-
#</data>
|
145
|
-
data = DataStream.new
|
146
|
-
raise MissingAttribute.new(node.name, 'id') if node['id'].nil?
|
147
|
-
data.identifier = node['id']
|
148
|
-
node.find('x:tag', "x:#{@@eeml_version[:href]}").each do |tag_node|
|
149
|
-
data.tags << tag_node.content.strip
|
150
|
-
end
|
151
|
-
|
152
|
-
value_nodes = node.find('x:current_value', "x:#{@@eeml_version[:href]}")
|
153
|
-
# raise exception_for_node(node, DataMissingValue, "Data node is missing current_value node.") if value_nodes.empty?
|
154
|
-
raise exception_for_node(node, DataHasMultipleValues, "Data node has multiple 'value' nodes.") if value_nodes.size > 1
|
155
|
-
|
156
|
-
value_node = value_nodes.first
|
157
|
-
|
158
|
-
max_value_node = node.find_first('x:max_value', "x:#{@@eeml_version[:href]}")
|
159
|
-
min_value_node = node.find_first('x:min_value', "x:#{@@eeml_version[:href]}")
|
160
|
-
|
161
|
-
value = Value.new
|
162
|
-
value.min_value = min_value_node.content if min_value_node
|
163
|
-
value.max_value = max_value_node.content if max_value_node
|
164
|
-
if value_node
|
165
|
-
value.value = value_node.content.strip
|
166
|
-
value.recorded_at = value_node['at'] unless value_node['at'].blank?
|
167
|
-
end
|
168
|
-
|
169
|
-
data.add_value(value)
|
170
|
-
|
171
|
-
unit_nodes = node.find('x:unit', "x:#{@@eeml_version[:href]}")
|
172
|
-
raise exception_for_node(node, DataHasMultipleUnits, "Data node has multiple 'unit' nodes.") if unit_nodes.size > 1
|
173
|
-
|
174
|
-
unit_node = unit_nodes.first
|
175
|
-
unless unit_node.nil?
|
176
|
-
data.unit_symbol = unit_node['symbol']
|
177
|
-
data.unit_type = unit_node['type']
|
178
|
-
data.unit_value = unit_node.content.strip
|
179
|
-
end
|
180
|
-
|
181
|
-
return data
|
182
|
-
end
|
183
|
-
|
184
|
-
#Helpers ------------------------------------------------------------------
|
185
|
-
#Consider mixing these in to the libxml parser for more readable code
|
186
|
-
|
187
|
-
#raises MissingNode if the node isn't there
|
188
|
-
def mandatory_content(base_node, xpath, description, nslist = nil)
|
189
|
-
node = base_node.find_first(xpath, nslist)
|
190
|
-
raise(MissingNode.new(node_name_or_root(base_node), description, xpath)) if node.nil?
|
191
|
-
return node.content
|
192
|
-
end
|
193
|
-
|
194
|
-
#returns the node's content, or the given default if the node isn't there (default itself defaults to nil)
|
195
|
-
#description isn't used, but keeps our signature same as mandatory_content(), up to that point.
|
196
|
-
def optional_content(base_node, xpath, description, nslist = nil, default = nil)
|
197
|
-
node = base_node.find_first(xpath, nslist)
|
198
|
-
return node.nil? ? default : node.content
|
199
|
-
end
|
200
|
-
|
201
|
-
|
202
|
-
#get the name of the given node if it is a node, or 'root' if it is a doc.
|
203
|
-
#for use only for error messages
|
204
|
-
def node_name_or_root(node)
|
205
|
-
node.respond_to?(:name) ? node.name : 'root'
|
206
|
-
end
|
207
|
-
|
208
|
-
def find_first_node_or_fail(base_node, xpath, description, nslist = nil)
|
209
|
-
node = base_node.find_first(xpath, nslist)
|
210
|
-
raise(MissingNode.new(node_name_or_root(base_node), description, xpath)) if node.nil?
|
211
|
-
return node
|
212
|
-
end
|
213
|
-
|
214
|
-
end
|
215
|
-
|
216
|
-
end
|
217
|
-
|
data/schemas/eeml/0.5.2.xsd
DELETED
@@ -1,167 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<xsd:schema xmlns="http://www.eeml.org/xsd/0.5.2" elementFormDefault="qualified" targetNamespace="http://www.eeml.org/xsd/0.5.2" 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="owner">
|
33
|
-
<xsd:complexType>
|
34
|
-
<xsd:sequence>
|
35
|
-
<xsd:element minOccurs="0" name="login" type="xsd:string" />
|
36
|
-
<xsd:element minOccurs="0" name="url" type="xsd:anyURI" />
|
37
|
-
</xsd:sequence>
|
38
|
-
</xsd:complexType>
|
39
|
-
</xsd:element>
|
40
|
-
<xsd:element minOccurs="0" name="location">
|
41
|
-
<xsd:complexType>
|
42
|
-
<xsd:sequence>
|
43
|
-
<xsd:element minOccurs="0" name="name" type="xsd:string" />
|
44
|
-
<xsd:element name="lat">
|
45
|
-
<xsd:simpleType>
|
46
|
-
<xsd:restriction base="xsd:double">
|
47
|
-
<xsd:minInclusive value="-90" />
|
48
|
-
<xsd:maxInclusive value="90" />
|
49
|
-
</xsd:restriction>
|
50
|
-
</xsd:simpleType>
|
51
|
-
</xsd:element>
|
52
|
-
<xsd:element name="lon">
|
53
|
-
<xsd:simpleType>
|
54
|
-
<xsd:restriction base="xsd:double">
|
55
|
-
<xsd:minInclusive value="-180" />
|
56
|
-
<xsd:maxInclusive value="180" />
|
57
|
-
</xsd:restriction>
|
58
|
-
</xsd:simpleType>
|
59
|
-
</xsd:element>
|
60
|
-
<xsd:element minOccurs="0" maxOccurs="1" name="ele" type="xsd:double" />
|
61
|
-
</xsd:sequence>
|
62
|
-
<xsd:attribute name="exposure" use="optional">
|
63
|
-
<xsd:simpleType>
|
64
|
-
<xsd:restriction base="xsd:string">
|
65
|
-
<xsd:enumeration value="indoor" />
|
66
|
-
<xsd:enumeration value="outdoor" />
|
67
|
-
</xsd:restriction>
|
68
|
-
</xsd:simpleType>
|
69
|
-
</xsd:attribute>
|
70
|
-
<xsd:attribute name="domain" use="required">
|
71
|
-
<xsd:simpleType>
|
72
|
-
<xsd:restriction base="xsd:string">
|
73
|
-
<xsd:enumeration value="physical" />
|
74
|
-
<xsd:enumeration value="virtual" />
|
75
|
-
</xsd:restriction>
|
76
|
-
</xsd:simpleType>
|
77
|
-
</xsd:attribute>
|
78
|
-
<xsd:attribute name="disposition" use="optional">
|
79
|
-
<xsd:simpleType>
|
80
|
-
<xsd:restriction base="xsd:string">
|
81
|
-
<xsd:enumeration value="fixed" />
|
82
|
-
<xsd:enumeration value="mobile" />
|
83
|
-
</xsd:restriction>
|
84
|
-
</xsd:simpleType>
|
85
|
-
</xsd:attribute>
|
86
|
-
</xsd:complexType>
|
87
|
-
</xsd:element>
|
88
|
-
<xsd:element minOccurs="1" maxOccurs="unbounded" name="data">
|
89
|
-
<xsd:complexType>
|
90
|
-
<xsd:sequence>
|
91
|
-
<xsd:element minOccurs="0" maxOccurs="unbounded" name="tag" type="xsd:string" />
|
92
|
-
<xsd:element minOccurs="0" maxOccurs="1" name="current_value">
|
93
|
-
<xsd:complexType>
|
94
|
-
<xsd:simpleContent>
|
95
|
-
<xsd:extension base="xsd:string">
|
96
|
-
<xsd:attribute name="at" type="xsd:dateTime" use="optional" />
|
97
|
-
</xsd:extension>
|
98
|
-
</xsd:simpleContent>
|
99
|
-
</xsd:complexType>
|
100
|
-
</xsd:element>
|
101
|
-
<xsd:element minOccurs="0" maxOccurs="1" name="max_value" type="xsd:string" />
|
102
|
-
<xsd:element minOccurs="0" maxOccurs="1" name="min_value" type="xsd:string" />
|
103
|
-
<xsd:element minOccurs="0" maxOccurs="1" name="datapoints">
|
104
|
-
<xsd:complexType>
|
105
|
-
<xsd:sequence>
|
106
|
-
<xsd:element minOccurs="0" maxOccurs="unbounded" name="value">
|
107
|
-
<xsd:complexType>
|
108
|
-
<xsd:simpleContent>
|
109
|
-
<xsd:extension base="xsd:string">
|
110
|
-
<xsd:attribute name="at" type="xsd:dateTime" use="optional" />
|
111
|
-
</xsd:extension>
|
112
|
-
</xsd:simpleContent>
|
113
|
-
</xsd:complexType>
|
114
|
-
</xsd:element>
|
115
|
-
</xsd:sequence>
|
116
|
-
</xsd:complexType>
|
117
|
-
</xsd:element>
|
118
|
-
<xsd:element minOccurs="0" maxOccurs="1" name="unit">
|
119
|
-
<xsd:complexType>
|
120
|
-
<xsd:simpleContent>
|
121
|
-
<xsd:extension base="xsd:string">
|
122
|
-
<xsd:attribute name="symbol" type="xsd:string" use="optional">
|
123
|
-
</xsd:attribute>
|
124
|
-
<xsd:attribute name="type" use="optional">
|
125
|
-
<xsd:simpleType>
|
126
|
-
<xsd:restriction base="xsd:string">
|
127
|
-
<xsd:enumeration value="basicSI" />
|
128
|
-
<xsd:enumeration value="derivedSI" />
|
129
|
-
<xsd:enumeration value="conversionBasedUnits" />
|
130
|
-
<xsd:enumeration value="derivedUnits" />
|
131
|
-
<xsd:enumeration value="contextDependentUnits" />
|
132
|
-
</xsd:restriction>
|
133
|
-
</xsd:simpleType>
|
134
|
-
</xsd:attribute>
|
135
|
-
</xsd:extension>
|
136
|
-
</xsd:simpleContent>
|
137
|
-
</xsd:complexType>
|
138
|
-
</xsd:element>
|
139
|
-
</xsd:sequence>
|
140
|
-
<xsd:attribute name="id" type="xsd:nonNegativeInteger" use="required" />
|
141
|
-
</xsd:complexType>
|
142
|
-
</xsd:element>
|
143
|
-
</xsd:sequence>
|
144
|
-
<xsd:attribute name="updated" use="optional">
|
145
|
-
<xsd:simpleType>
|
146
|
-
<xsd:restriction base="xsd:dateTime" />
|
147
|
-
</xsd:simpleType>
|
148
|
-
</xsd:attribute>
|
149
|
-
<xsd:attribute name="creator" use="optional">
|
150
|
-
<xsd:simpleType>
|
151
|
-
<xsd:restriction base="xsd:string" />
|
152
|
-
</xsd:simpleType>
|
153
|
-
</xsd:attribute>
|
154
|
-
<xsd:attribute name="id" type="xsd:nonNegativeInteger" use="optional" />
|
155
|
-
</xsd:complexType>
|
156
|
-
</xsd:element>
|
157
|
-
</xsd:choice>
|
158
|
-
<xsd:attribute name="version" use="optional">
|
159
|
-
<xsd:simpleType>
|
160
|
-
<xsd:restriction base="xsd:string">
|
161
|
-
<xsd:enumeration value="0.5.1" />
|
162
|
-
</xsd:restriction>
|
163
|
-
</xsd:simpleType>
|
164
|
-
</xsd:attribute>
|
165
|
-
</xsd:complexType>
|
166
|
-
</xsd:element>
|
167
|
-
</xsd:schema>
|
@@ -1,40 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<eeml xmlns="http://www.eeml.org/xsd/0.5.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="0.5.2" xsi:schemaLocation="http://www.eeml.org/xsd/0.5.2 http://www.eeml.org/xsd/0.5.2/0.5.2.xsd">
|
3
|
-
<environment updated="2010-09-23T09:54:57.873029Z" publisher="http://www.pachube.com">
|
4
|
-
<title>title here</title>
|
5
|
-
<feed>http://appdev.loc:3000/api/feeds/.xml</feed>
|
6
|
-
<status>live</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
|
-
<owner>http://www.pachube.com/users/joe</owner>
|
13
|
-
<location domain="physical" exposure="outdoor" disposition="mobile">
|
14
|
-
<name>Up on the roof (somewhere)</name>
|
15
|
-
<lat>50.1</lat>
|
16
|
-
<lon>48.7</lon>
|
17
|
-
<ele>1.34</ele>
|
18
|
-
</location>
|
19
|
-
<data id="0">
|
20
|
-
<tag>tagD0</tag>
|
21
|
-
<current_value at="2010-09-23T09:54:57.873029Z">0</current_value>
|
22
|
-
<max_value>1022.0</max_value>
|
23
|
-
<min_value>-9999.0</min_value>
|
24
|
-
<unit type="basicSI" symbol="C">Celsius</unit>
|
25
|
-
</data>
|
26
|
-
<data id="1">
|
27
|
-
<current_value at="2010-09-23T09:54:57.873029Z">33</current_value>
|
28
|
-
<max_value>1023.0</max_value>
|
29
|
-
<min_value>0.0</min_value>
|
30
|
-
</data>
|
31
|
-
<data id="2">
|
32
|
-
<tag>tagD2a</tag>
|
33
|
-
<tag>tagD2b</tag>
|
34
|
-
<tag>tagD2c</tag>
|
35
|
-
<current_value at="2010-09-23T09:54:57.873029Z">42.1</current_value>
|
36
|
-
<max_value>1021.0</max_value>
|
37
|
-
<min_value>23.4</min_value>
|
38
|
-
</data>
|
39
|
-
</environment>
|
40
|
-
</eeml>
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<eeml xmlns="http://www.eeml.org/xsd/0.5.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="0.5.2" xsi:schemaLocation="http://www.eeml.org/xsd/0.5.2 http://www.eeml.org/xsd/0.5.2/0.5.2.xsd">
|
2
|
-
<environment>
|
3
|
-
<title>Pachube Office environment</title>
|
4
|
-
<data id="0" />
|
5
|
-
<data id="1" />
|
6
|
-
</environment>
|
7
|
-
</eeml>
|
8
|
-
|