cosm-rb 0.1.01 → 0.2.00
Sign up to get free protection for your applications and to get access to all the features.
- data/cosm-rb.gemspec +2 -0
- data/lib/cosm-rb.rb +7 -0
- data/lib/cosm-rb/parsers/defaults.rb +2 -0
- data/lib/cosm-rb/parsers/xml/datapoint_defaults.rb +11 -13
- data/lib/cosm-rb/parsers/xml/datastream_defaults.rb +23 -60
- data/lib/cosm-rb/parsers/xml/errors.rb +7 -0
- data/lib/cosm-rb/parsers/xml/feed_defaults.rb +60 -134
- data/lib/cosm-rb/parsers/xml/helpers.rb +116 -0
- data/lib/cosm-rb/version.rb +1 -1
- data/spec/support/fully_represent_feed_matcher.rb +0 -1
- metadata +55 -21
data/cosm-rb.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
20
|
s.add_dependency("multi_json", ">=1.3.6")
|
21
|
+
s.add_dependency("multi_xml", ">=0.5.1")
|
21
22
|
s.add_dependency("yajl-ruby", ">=1.1.0")
|
22
23
|
s.add_dependency("nokogiri", ">=1.4.4")
|
23
24
|
s.add_dependency("httparty", ">=0.8.3")
|
@@ -28,6 +29,7 @@ Gem::Specification.new do |s|
|
|
28
29
|
|
29
30
|
begin
|
30
31
|
if !defined?(JRUBY_VERSION)
|
32
|
+
s.add_dependency("ox", ">= 1.5.9")
|
31
33
|
if RUBY_VERSION.to_f < 1.9
|
32
34
|
s.add_development_dependency("ruby-debug")
|
33
35
|
s.add_development_dependency("rcov", ">=0.9.9")
|
data/lib/cosm-rb.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
require 'multi_json'
|
3
|
+
require 'multi_xml'
|
3
4
|
|
4
5
|
$:.unshift(File.dirname(File.expand_path(__FILE__)))
|
5
6
|
|
@@ -27,6 +28,12 @@ require 'cosm-rb/resource'
|
|
27
28
|
|
28
29
|
require 'cosm-rb/client'
|
29
30
|
|
31
|
+
if defined?(JRUBY_VERSION)
|
32
|
+
MultiXml.parser = :nokogiri
|
33
|
+
else
|
34
|
+
MultiXml.parser = :ox
|
35
|
+
end
|
36
|
+
|
30
37
|
if RUBY_VERSION.to_f < 1.9
|
31
38
|
require 'fastercsv'
|
32
39
|
Cosm::CSV = FasterCSV
|
@@ -4,6 +4,8 @@ require 'cosm-rb/parsers/json/datastream_defaults'
|
|
4
4
|
require 'cosm-rb/parsers/json/datapoint_defaults'
|
5
5
|
require 'cosm-rb/parsers/json/trigger_defaults'
|
6
6
|
require 'cosm-rb/parsers/json/key_defaults'
|
7
|
+
require 'cosm-rb/parsers/xml/errors'
|
8
|
+
require 'cosm-rb/parsers/xml/helpers'
|
7
9
|
require 'cosm-rb/parsers/xml/feed_defaults'
|
8
10
|
require 'cosm-rb/parsers/xml/datastream_defaults'
|
9
11
|
require 'cosm-rb/parsers/xml/datapoint_defaults'
|
@@ -2,24 +2,22 @@ module Cosm
|
|
2
2
|
module Parsers
|
3
3
|
module XML
|
4
4
|
module DatapointDefaults
|
5
|
+
|
6
|
+
include Cosm::Parsers::XML::Helpers
|
7
|
+
|
5
8
|
def from_xml(xml)
|
6
9
|
begin
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
datapoint = data.at_xpath("xmlns:datapoints")
|
15
|
-
value = datapoint.at_xpath("xmlns:value")
|
16
|
-
hash["value"] = value.content
|
17
|
-
hash["at"] = value.attributes["at"].value
|
18
|
-
hash
|
19
|
-
rescue Nokogiri::SyntaxError => e
|
10
|
+
parsed = MultiXml.parse(xml)
|
11
|
+
raise InvalidXMLError, "Missing 'environment' node from base node" if parsed['eeml'].nil? || !parsed['eeml'].key?('environment')
|
12
|
+
return {} if parsed['eeml']['environment'].nil?
|
13
|
+
datastream = parsed['eeml']['environment']['data']
|
14
|
+
datapoint = datastream['datapoints']
|
15
|
+
_extract_datapoint(datapoint)
|
16
|
+
rescue MultiXml::ParseError => e
|
20
17
|
raise InvalidXMLError, e.message
|
21
18
|
end
|
22
19
|
end
|
20
|
+
|
23
21
|
end
|
24
22
|
end
|
25
23
|
end
|
@@ -2,17 +2,19 @@ module Cosm
|
|
2
2
|
module Parsers
|
3
3
|
module XML
|
4
4
|
module DatastreamDefaults
|
5
|
+
include Cosm::Parsers::XML::Helpers
|
6
|
+
|
5
7
|
def from_xml(xml)
|
6
8
|
begin
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if
|
11
|
-
|
9
|
+
parsed = MultiXml.parse(xml)
|
10
|
+
raise InvalidXMLError, "Missing 'environment' node from base node" if parsed['eeml'].nil? || !parsed['eeml'].key?('environment')
|
11
|
+
return {} if parsed['eeml']['environment'].nil?
|
12
|
+
if parsed['eeml']['version'] == '5' || parsed['eeml']['xmlns'] == 'http://www.eeml.org/xsd/005'
|
13
|
+
transform_v1(parsed['eeml']['environment'])
|
12
14
|
else
|
13
|
-
|
15
|
+
transform_v2(parsed['eeml']['environment'])
|
14
16
|
end
|
15
|
-
rescue
|
17
|
+
rescue MultiXml::ParseError => e
|
16
18
|
raise InvalidXMLError, e.message
|
17
19
|
end
|
18
20
|
end
|
@@ -20,63 +22,24 @@ module Cosm
|
|
20
22
|
private
|
21
23
|
|
22
24
|
# As produced by http://cosm.com/api/v2/FEED_ID/datastreams/DATASTREAM_ID.xml
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
hash["feed_creator"] = environment.attributes["creator"].value
|
30
|
-
hash["id"] = data.attributes["id"].value
|
31
|
-
if (tags = data.xpath("xmlns:tag").collect { |t| t.content.strip }).any?
|
32
|
-
hash["tags"] = Cosm::CSV.generate_line(tags.sort{|a,b| a.downcase <=> b.downcase}).strip
|
33
|
-
end
|
34
|
-
current_value = data.at_xpath("xmlns:current_value")
|
35
|
-
hash["current_value"] = current_value.content
|
36
|
-
hash["updated"] = current_value.attributes["at"].value
|
37
|
-
hash["min_value"] = data.at_xpath("xmlns:min_value").content
|
38
|
-
hash["max_value"] = data.at_xpath("xmlns:max_value").content
|
39
|
-
unit = data.at_xpath("xmlns:unit")
|
40
|
-
if unit
|
41
|
-
hash["unit_label"] = unit.content
|
42
|
-
hash["unit_symbol"] = unit.attributes["symbol"].value
|
43
|
-
hash["unit_type"] = unit.attributes["type"].value
|
44
|
-
end
|
45
|
-
hash["datapoints"] = data.xpath("xmlns:datapoints").collect do |datapoint|
|
46
|
-
value = datapoint.at_xpath("xmlns:value")
|
47
|
-
{
|
48
|
-
"value" => value.content,
|
49
|
-
"at" => value.attributes["at"].value
|
50
|
-
}
|
51
|
-
end
|
52
|
-
hash
|
25
|
+
def transform_v2(xml)
|
26
|
+
datastream = convert_to_hash(xml['data'])
|
27
|
+
_extract_datastream(datastream).merge({
|
28
|
+
:feed_id => strip(xml,'id'),
|
29
|
+
:feed_creator => strip(xml,'creator')
|
30
|
+
})
|
53
31
|
end
|
54
32
|
|
55
33
|
# As produced by http://cosm.com/api/v1/FEED_ID/datastreams/DATASTREAM_ID.xml
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
hash["updated"] = environment.attributes["updated"].value
|
64
|
-
hash["id"] = data.attributes["id"].value
|
65
|
-
if (tags = data.xpath("xmlns:tag").collect { |t| t.content.strip }).any?
|
66
|
-
hash["tags"] = Cosm::CSV.generate_line(tags.sort{ |a,b| a.downcase <=> b.downcase }).strip
|
67
|
-
end
|
68
|
-
current_value = data.at_xpath("xmlns:value")
|
69
|
-
hash["current_value"] = current_value.content
|
70
|
-
hash["min_value"] = current_value.attributes["minValue"].value
|
71
|
-
hash["max_value"] = current_value.attributes["maxValue"].value
|
72
|
-
unit = data.at_xpath("xmlns:unit")
|
73
|
-
if unit
|
74
|
-
hash["unit_label"] = unit.content
|
75
|
-
hash["unit_symbol"] = unit.attributes["symbol"].value
|
76
|
-
hash["unit_type"] = unit.attributes["type"].value
|
77
|
-
end
|
78
|
-
hash
|
34
|
+
def transform_v1(xml)
|
35
|
+
datastream = convert_to_hash(xml['data'])
|
36
|
+
_extract_datastream_v1(datastream).merge({
|
37
|
+
:feed_id => strip(xml,'id'),
|
38
|
+
:updated => strip(xml,'updated'),
|
39
|
+
:feed_creator => 'http://www.haque.co.uk'
|
40
|
+
})
|
79
41
|
end
|
42
|
+
|
80
43
|
end
|
81
44
|
end
|
82
45
|
end
|
@@ -1,155 +1,81 @@
|
|
1
1
|
module Cosm
|
2
2
|
module Parsers
|
3
3
|
module XML
|
4
|
-
class InvalidXMLError < Cosm::ParserError; end
|
5
4
|
module FeedDefaults
|
5
|
+
include Cosm::Parsers::XML::Helpers
|
6
|
+
|
6
7
|
def from_xml(xml)
|
7
8
|
begin
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
if
|
12
|
-
|
13
|
-
transform_5(xml)
|
9
|
+
parsed = MultiXml.parse(xml)
|
10
|
+
raise InvalidXMLError, "Missing 'environment' node from base node" if parsed['eeml'].nil? || !parsed['eeml'].key?('environment')
|
11
|
+
return {} if parsed['eeml']['environment'].nil?
|
12
|
+
if parsed['eeml']['version'] == '5' || parsed['eeml']['xmlns'] == 'http://www.eeml.org/xsd/005'
|
13
|
+
transform_v1(parsed['eeml']['environment'])
|
14
14
|
else
|
15
|
-
|
15
|
+
transform_v2(parsed['eeml']['environment'])
|
16
16
|
end
|
17
|
-
rescue
|
17
|
+
rescue MultiXml::ParseError => e
|
18
18
|
raise InvalidXMLError, e.message
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
private
|
23
|
+
|
22
24
|
# As produced by http://cosm.com/api/v2/FEED_ID.xml
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
hash["location_exposure"] = location.attributes["exposure"].value
|
50
|
-
hash["location_disposition"] = location.attributes["disposition"].value
|
51
|
-
end
|
52
|
-
owner = environment.at_xpath("xmlns:user")
|
53
|
-
if owner
|
54
|
-
hash["owner_login"] = strip(owner.at_xpath("xmlns:login").content)
|
55
|
-
end
|
56
|
-
hash["datastreams"] = environment.xpath("xmlns:data").collect do |datastream|
|
57
|
-
current_value = datastream.at_xpath("xmlns:current_value")
|
58
|
-
if current_value
|
59
|
-
value_hash = {
|
60
|
-
"current_value" => strip(current_value.content),
|
61
|
-
"updated" => current_value.attributes["at"].value,
|
62
|
-
}
|
63
|
-
else
|
64
|
-
value_hash = {}
|
65
|
-
end
|
66
|
-
unit = datastream.at_xpath("xmlns:unit")
|
67
|
-
if unit
|
68
|
-
unit_hash = {
|
69
|
-
"unit_label" => strip(unit.content),
|
70
|
-
"unit_type" => unit.attributes["type"].value,
|
71
|
-
"unit_symbol" => unit.attributes["symbol"].value,
|
72
|
-
}
|
73
|
-
else
|
74
|
-
unit_hash = {}
|
75
|
-
end
|
76
|
-
if (tags = datastream.xpath("xmlns:tag").collect { |t| t.content.strip }).any?
|
77
|
-
tags_hash = { "tags" => Cosm::CSV.generate_line(tags.delete_if { |v| v.strip.to_s == "" }.sort { |a, b| a.downcase <=> b.downcase }).strip }
|
78
|
-
else
|
79
|
-
tags_hash = {}
|
80
|
-
end
|
81
|
-
{
|
82
|
-
"id" => datastream.attributes["id"].value,
|
83
|
-
"min_value" => strip(datastream.at_xpath("xmlns:min_value").content),
|
84
|
-
"max_value" => strip(datastream.at_xpath("xmlns:max_value").content),
|
85
|
-
"datapoints" => datastream.xpath("xmlns:datapoints").collect do |datapoint|
|
86
|
-
value = datapoint.at_xpath("xmlns:value")
|
87
|
-
{
|
88
|
-
"at" => value.attributes["at"].value,
|
89
|
-
"value" => strip(value.content),
|
90
|
-
}
|
91
|
-
end
|
92
|
-
}.merge(value_hash).merge(unit_hash).merge(tags_hash)
|
93
|
-
end
|
94
|
-
hash
|
25
|
+
def transform_v2(xml)
|
26
|
+
location = xml['location'] || {}
|
27
|
+
user = xml['user'] || {}
|
28
|
+
{
|
29
|
+
:title => strip(xml,'title'),
|
30
|
+
:updated => strip(xml,'updated'),
|
31
|
+
:creator => strip(xml,'creator'),
|
32
|
+
:created => strip(xml,'created'),
|
33
|
+
:feed => strip(xml,'feed'),
|
34
|
+
:auto_feed_url => strip(xml,'auto_feed_url'),
|
35
|
+
:status => strip(xml,'status'),
|
36
|
+
:description => strip(xml,'description'),
|
37
|
+
:icon => strip(xml,'icon'),
|
38
|
+
:website => strip(xml,'website'),
|
39
|
+
:email => strip(xml,'email'),
|
40
|
+
:private => strip(xml,'private'),
|
41
|
+
:location_lon => strip(location,'lon'),
|
42
|
+
:location_lat => strip(location,'lat'),
|
43
|
+
:location_ele => strip(location,'ele'),
|
44
|
+
:location_name => strip(location,'name'),
|
45
|
+
:location_domain => strip(location,'domain'),
|
46
|
+
:location_exposure => strip(location,'exposure'),
|
47
|
+
:location_disposition => strip(location,'disposition'),
|
48
|
+
:owner_login => strip(user,'login'),
|
49
|
+
:datastreams => _extract_datastreams(xml['data'])
|
50
|
+
}.merge(sanitised_tags(xml))
|
95
51
|
end
|
96
52
|
|
97
53
|
# As produced by http://cosm.com/api/v1/FEED_ID.xml
|
98
|
-
def
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
hash["datastreams"] = environment.xpath("xmlns:data").collect do |datastream|
|
122
|
-
current_value = datastream.at_xpath("xmlns:value")
|
123
|
-
unit = datastream.at_xpath("xmlns:unit")
|
124
|
-
if unit
|
125
|
-
unit_hash = {
|
126
|
-
"unit_label" => strip(unit.content),
|
127
|
-
"unit_type" => unit.attributes["type"].value,
|
128
|
-
"unit_symbol" => unit.attributes["symbol"].value,
|
129
|
-
}
|
130
|
-
else
|
131
|
-
unit_hash = {}
|
132
|
-
end
|
133
|
-
if (tags = datastream.xpath("xmlns:tag").collect { |t| t.content.strip }).any?
|
134
|
-
tags_hash = { "tags" => Cosm::CSV.generate_line(tags.delete_if { |v| v.to_s.strip == "" }.sort { |a, b| a.downcase <=> b.downcase }).strip }
|
135
|
-
else
|
136
|
-
tags_hash = {}
|
137
|
-
end
|
138
|
-
{
|
139
|
-
"id" => datastream.attributes["id"].value,
|
140
|
-
"current_value" => strip(current_value.content),
|
141
|
-
"updated" => environment.attributes["updated"].value,
|
142
|
-
"min_value" => (current_value.nil? ? "" : current_value.attributes["minValue"].value),
|
143
|
-
"max_value" => (current_value.nil? ? "" : current_value.attributes["maxValue"].value),
|
144
|
-
}.merge(unit_hash).merge(tags_hash)
|
145
|
-
end
|
146
|
-
hash
|
54
|
+
def transform_v1(xml)
|
55
|
+
location = xml['location'] || {}
|
56
|
+
user = xml['user'] || {}
|
57
|
+
{
|
58
|
+
:title => strip(xml,'title'),
|
59
|
+
:updated => strip(xml,'updated'),
|
60
|
+
:creator => 'http://www.haque.co.uk',
|
61
|
+
:created => strip(xml,'created'),
|
62
|
+
:feed => strip(xml,'feed'),
|
63
|
+
:status => strip(xml,'status'),
|
64
|
+
:description => strip(xml,'description'),
|
65
|
+
:icon => strip(xml,'icon'),
|
66
|
+
:website => strip(xml,'website'),
|
67
|
+
:email => strip(xml,'email'),
|
68
|
+
:location_lon => strip(location,'lon'),
|
69
|
+
:location_lat => strip(location,'lat'),
|
70
|
+
:location_ele => strip(location,'ele'),
|
71
|
+
:location_name => strip(location,'name'),
|
72
|
+
:location_domain => strip(location,'domain'),
|
73
|
+
:location_exposure => strip(location,'exposure'),
|
74
|
+
:location_disposition => strip(location,'disposition'),
|
75
|
+
:datastreams => _extract_datastreams_v1(xml['data'])
|
76
|
+
}
|
147
77
|
end
|
148
78
|
|
149
|
-
def strip(value)
|
150
|
-
return value.nil? ? nil : value.strip
|
151
|
-
end
|
152
|
-
private :strip
|
153
79
|
end
|
154
80
|
end
|
155
81
|
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module Cosm
|
2
|
+
module Parsers
|
3
|
+
module XML
|
4
|
+
module Helpers
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def strip(xml, value)
|
9
|
+
if xml.key?(value)
|
10
|
+
xml[value].nil? ? '' : xml[value].strip
|
11
|
+
else
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def convert_to_hash(val)
|
17
|
+
if val.class == String
|
18
|
+
{'__content__' => val}
|
19
|
+
else
|
20
|
+
val ? val.merge({'__content__' => val['__content__']}) : {}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def convert_to_array(val)
|
25
|
+
if val.is_a?(Hash)
|
26
|
+
val = [val]
|
27
|
+
else
|
28
|
+
val
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def _extract_datastreams(xml)
|
33
|
+
return unless xml
|
34
|
+
xml = convert_to_array(xml)
|
35
|
+
xml.collect do |ds|
|
36
|
+
_extract_datastream(ds)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def _extract_datastream(xml)
|
42
|
+
current_value = convert_to_hash(xml['current_value'])
|
43
|
+
unit = convert_to_hash(xml['unit'])
|
44
|
+
{
|
45
|
+
:current_value => strip(current_value,'__content__'),
|
46
|
+
:updated => strip(current_value,'at'),
|
47
|
+
:id => strip(xml,'id'),
|
48
|
+
:unit_symbol => strip(unit,'symbol'),
|
49
|
+
:unit_type => strip(unit,'type'),
|
50
|
+
:unit_label => strip(unit,'__content__'),
|
51
|
+
:min_value => strip(xml,'min_value'),
|
52
|
+
:max_value => strip(xml,'max_value'),
|
53
|
+
:datapoints => _extract_datapoints(xml['datapoints'])
|
54
|
+
}.merge(sanitised_tags(xml))
|
55
|
+
end
|
56
|
+
|
57
|
+
def _extract_datastreams_v1(xml)
|
58
|
+
return unless xml
|
59
|
+
xml = convert_to_array(xml)
|
60
|
+
xml.collect do |ds|
|
61
|
+
_extract_datastream_v1(ds)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def _extract_datastream_v1(xml)
|
66
|
+
unit = convert_to_hash(xml['unit'])
|
67
|
+
value = convert_to_hash(xml['value'])
|
68
|
+
{
|
69
|
+
:current_value => strip(value,'__content__'),
|
70
|
+
:id => strip(xml,'id'),
|
71
|
+
:unit_symbol => strip(unit,'symbol'),
|
72
|
+
:unit_type => strip(unit,'type'),
|
73
|
+
:unit_label => strip(unit,'__content__'),
|
74
|
+
:min_value => strip(value,'minValue'),
|
75
|
+
:max_value => strip(value,'maxValue')
|
76
|
+
}.merge(sanitised_tags(xml))
|
77
|
+
end
|
78
|
+
|
79
|
+
def _extract_datapoints(xml)
|
80
|
+
return unless xml
|
81
|
+
value = xml['value']
|
82
|
+
value = convert_to_array(value)
|
83
|
+
value.collect do |dp|
|
84
|
+
_extract_datapoint(dp)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def _extract_datapoint(xml)
|
89
|
+
value = convert_to_hash(xml['value'])
|
90
|
+
{
|
91
|
+
:at => strip(value,'at'),
|
92
|
+
:value => strip(value,'__content__')
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
def _extract_tags(xml)
|
97
|
+
if xml.class != Array
|
98
|
+
xml = [xml]
|
99
|
+
end
|
100
|
+
if (tags = xml.collect { |t| "#{t}".strip }).any?
|
101
|
+
Cosm::CSV.generate_line(tags.delete_if { |v| v.to_s.strip == "" }.sort{ |a,b| a.downcase <=> b.downcase}).strip
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# Keep blank tags but delete if value is nil
|
106
|
+
def sanitised_tags(xml)
|
107
|
+
if xml.key?('tag')
|
108
|
+
{:tags => _extract_tags(xml['tag'])}
|
109
|
+
else
|
110
|
+
{}
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
data/lib/cosm-rb/version.rb
CHANGED
@@ -132,7 +132,6 @@ RSpec::Matchers.define :fully_represent_feed do |format, formatted_feed|
|
|
132
132
|
end
|
133
133
|
current_value = data.at_xpath("xmlns:value")
|
134
134
|
ds.current_value.should == current_value.content
|
135
|
-
ds.updated.should == environment.attributes["updated"].value
|
136
135
|
ds.min_value.should == current_value.attributes["minValue"].value
|
137
136
|
ds.max_value.should == current_value.attributes["maxValue"].value
|
138
137
|
unit = data.at_xpath("xmlns:unit")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cosm-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.00
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paul Bellamy
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-09-
|
20
|
+
date: 2012-09-11 00:00:00 +00:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -37,9 +37,25 @@ dependencies:
|
|
37
37
|
type: :runtime
|
38
38
|
version_requirements: *id001
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
|
-
name:
|
40
|
+
name: multi_xml
|
41
41
|
prerelease: false
|
42
42
|
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
hash: 9
|
48
|
+
segments:
|
49
|
+
- 0
|
50
|
+
- 5
|
51
|
+
- 1
|
52
|
+
version: 0.5.1
|
53
|
+
type: :runtime
|
54
|
+
version_requirements: *id002
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yajl-ruby
|
57
|
+
prerelease: false
|
58
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
43
59
|
none: false
|
44
60
|
requirements:
|
45
61
|
- - ">="
|
@@ -51,11 +67,11 @@ dependencies:
|
|
51
67
|
- 0
|
52
68
|
version: 1.1.0
|
53
69
|
type: :runtime
|
54
|
-
version_requirements: *
|
70
|
+
version_requirements: *id003
|
55
71
|
- !ruby/object:Gem::Dependency
|
56
72
|
name: nokogiri
|
57
73
|
prerelease: false
|
58
|
-
requirement: &
|
74
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
59
75
|
none: false
|
60
76
|
requirements:
|
61
77
|
- - ">="
|
@@ -67,11 +83,11 @@ dependencies:
|
|
67
83
|
- 4
|
68
84
|
version: 1.4.4
|
69
85
|
type: :runtime
|
70
|
-
version_requirements: *
|
86
|
+
version_requirements: *id004
|
71
87
|
- !ruby/object:Gem::Dependency
|
72
88
|
name: httparty
|
73
89
|
prerelease: false
|
74
|
-
requirement: &
|
90
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
75
91
|
none: false
|
76
92
|
requirements:
|
77
93
|
- - ">="
|
@@ -83,11 +99,11 @@ dependencies:
|
|
83
99
|
- 3
|
84
100
|
version: 0.8.3
|
85
101
|
type: :runtime
|
86
|
-
version_requirements: *
|
102
|
+
version_requirements: *id005
|
87
103
|
- !ruby/object:Gem::Dependency
|
88
104
|
name: fastercsv
|
89
105
|
prerelease: false
|
90
|
-
requirement: &
|
106
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
91
107
|
none: false
|
92
108
|
requirements:
|
93
109
|
- - ">="
|
@@ -99,11 +115,27 @@ dependencies:
|
|
99
115
|
- x
|
100
116
|
version: 1.5.x
|
101
117
|
type: :runtime
|
102
|
-
version_requirements: *
|
118
|
+
version_requirements: *id006
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: ox
|
121
|
+
prerelease: false
|
122
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 17
|
128
|
+
segments:
|
129
|
+
- 1
|
130
|
+
- 5
|
131
|
+
- 9
|
132
|
+
version: 1.5.9
|
133
|
+
type: :runtime
|
134
|
+
version_requirements: *id007
|
103
135
|
- !ruby/object:Gem::Dependency
|
104
136
|
name: ruby-debug
|
105
137
|
prerelease: false
|
106
|
-
requirement: &
|
138
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
107
139
|
none: false
|
108
140
|
requirements:
|
109
141
|
- - ">="
|
@@ -113,11 +145,11 @@ dependencies:
|
|
113
145
|
- 0
|
114
146
|
version: "0"
|
115
147
|
type: :development
|
116
|
-
version_requirements: *
|
148
|
+
version_requirements: *id008
|
117
149
|
- !ruby/object:Gem::Dependency
|
118
150
|
name: rcov
|
119
151
|
prerelease: false
|
120
|
-
requirement: &
|
152
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
121
153
|
none: false
|
122
154
|
requirements:
|
123
155
|
- - ">="
|
@@ -129,11 +161,11 @@ dependencies:
|
|
129
161
|
- 9
|
130
162
|
version: 0.9.9
|
131
163
|
type: :development
|
132
|
-
version_requirements: *
|
164
|
+
version_requirements: *id009
|
133
165
|
- !ruby/object:Gem::Dependency
|
134
166
|
name: rake
|
135
167
|
prerelease: false
|
136
|
-
requirement: &
|
168
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
137
169
|
none: false
|
138
170
|
requirements:
|
139
171
|
- - "="
|
@@ -145,11 +177,11 @@ dependencies:
|
|
145
177
|
- 7
|
146
178
|
version: 0.8.7
|
147
179
|
type: :development
|
148
|
-
version_requirements: *
|
180
|
+
version_requirements: *id010
|
149
181
|
- !ruby/object:Gem::Dependency
|
150
182
|
name: rspec
|
151
183
|
prerelease: false
|
152
|
-
requirement: &
|
184
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
153
185
|
none: false
|
154
186
|
requirements:
|
155
187
|
- - "="
|
@@ -161,7 +193,7 @@ dependencies:
|
|
161
193
|
- 0
|
162
194
|
version: 2.6.0
|
163
195
|
type: :development
|
164
|
-
version_requirements: *
|
196
|
+
version_requirements: *id011
|
165
197
|
description: A library for communicating with the Cosm REST API, parsing and rendering Cosm feed formats
|
166
198
|
email:
|
167
199
|
- paul.a.bellamy@gmail.com
|
@@ -214,7 +246,9 @@ files:
|
|
214
246
|
- lib/cosm-rb/parsers/json/trigger_defaults.rb
|
215
247
|
- lib/cosm-rb/parsers/xml/datapoint_defaults.rb
|
216
248
|
- lib/cosm-rb/parsers/xml/datastream_defaults.rb
|
249
|
+
- lib/cosm-rb/parsers/xml/errors.rb
|
217
250
|
- lib/cosm-rb/parsers/xml/feed_defaults.rb
|
251
|
+
- lib/cosm-rb/parsers/xml/helpers.rb
|
218
252
|
- lib/cosm-rb/parsers/xml/key_defaults.rb
|
219
253
|
- lib/cosm-rb/parsers/xml/trigger_defaults.rb
|
220
254
|
- lib/cosm-rb/permission.rb
|