eeml 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -13,6 +13,7 @@ test/data/list.xml
13
13
  test/data/out_empty.xml
14
14
  test/data/complete_namespaced.xml
15
15
  test/data/no_namespace.xml
16
+ test/data/difficult_tag.xml
16
17
  test/data/doc_1.xml
17
18
  test/data/doc_1.json
18
19
  test/data/doc_2.xml
data/eeml.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{eeml}
5
- s.version = "0.0.5"
5
+ s.version = "0.0.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Neill Bogie, Sam Mulube"]
9
9
  s.cert_chain = ["/home/sam/.gem/gem-public_cert.pem"]
10
- s.date = %q{2009-07-08}
10
+ s.date = %q{2009-08-18}
11
11
  s.description = %q{Simple little library for programmatically manipulating EEML documents, in particular this library is designed to work with the Pachube web service.}
12
12
  s.email = %q{sam.mulube@gmail.com}
13
13
  s.extra_rdoc_files = ["LICENSE", "CHANGELOG", "README", "lib/eeml.rb", "lib/eeml/constants.rb", "lib/eeml/json_environment_parser_v005.rb", "lib/eeml/output_registry.rb", "lib/eeml/parser_registry.rb", "lib/eeml/libxml_eeml_output_v005.rb", "lib/eeml/libxml_eeml_parser_v005.rb", "lib/eeml/exceptions.rb", "lib/eeml/csv_parser.rb", "lib/eeml/json_output.rb", "lib/eeml/environment.rb", "lib/blank.rb"]
14
- s.files = ["example.rb", "LICENSE", "CHANGELOG", "README", "test/test_environment.rb", "test/test_libxml_test_helper.rb", "test/libxml_test_helper.rb", "test/test_libxml_eeml_parser_v005.rb", "test/test_helper.rb", "test/data/minimal.xml", "test/data/doc_2_expected.json", "test/data/list.xml", "test/data/out_empty.xml", "test/data/complete_namespaced.xml", "test/data/no_namespace.xml", "test/data/doc_1.xml", "test/data/doc_1.json", "test/data/doc_2.xml", "lib/eeml.rb", "lib/eeml/constants.rb", "lib/eeml/json_environment_parser_v005.rb", "lib/eeml/output_registry.rb", "lib/eeml/parser_registry.rb", "lib/eeml/libxml_eeml_output_v005.rb", "lib/eeml/libxml_eeml_parser_v005.rb", "lib/eeml/exceptions.rb", "lib/eeml/csv_parser.rb", "lib/eeml/json_output.rb", "lib/eeml/environment.rb", "lib/blank.rb", "schemas/eeml/005.xsd", "Rakefile", "Manifest", "eeml.gemspec"]
14
+ s.files = ["example.rb", "LICENSE", "CHANGELOG", "README", "test/test_environment.rb", "test/test_libxml_test_helper.rb", "test/libxml_test_helper.rb", "test/test_libxml_eeml_parser_v005.rb", "test/test_helper.rb", "test/data/minimal.xml", "test/data/doc_2_expected.json", "test/data/list.xml", "test/data/out_empty.xml", "test/data/complete_namespaced.xml", "test/data/no_namespace.xml", "test/data/difficult_tag.xml", "test/data/doc_1.xml", "test/data/doc_1.json", "test/data/doc_2.xml", "lib/eeml.rb", "lib/eeml/constants.rb", "lib/eeml/json_environment_parser_v005.rb", "lib/eeml/output_registry.rb", "lib/eeml/parser_registry.rb", "lib/eeml/libxml_eeml_output_v005.rb", "lib/eeml/libxml_eeml_parser_v005.rb", "lib/eeml/exceptions.rb", "lib/eeml/csv_parser.rb", "lib/eeml/json_output.rb", "lib/eeml/environment.rb", "lib/blank.rb", "schemas/eeml/005.xsd", "Rakefile", "Manifest", "eeml.gemspec"]
15
15
  s.homepage = %q{}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Eeml", "--main", "README"]
17
17
  s.require_paths = ["lib"]
@@ -140,7 +140,7 @@ module Eeml
140
140
  raise MissingAttribute.new(node.name, 'id') if node['id'].nil?
141
141
  data.identifier = node['id']
142
142
  node.find('x:tag', "x:#{EEML_HREF}").each do |tag_node|
143
- data.tags << tag_node.content
143
+ data.tags << tag_node.content.strip
144
144
  end
145
145
 
146
146
  value_nodes = node.find('x:value', "x:#{EEML_HREF}")
@@ -150,7 +150,7 @@ module Eeml
150
150
  value_node = value_nodes.first
151
151
  data.min_value = value_node['minValue']
152
152
  data.max_value = value_node['maxValue']
153
- data.value = value_node.content
153
+ data.value = value_node.content.strip
154
154
 
155
155
  unit_nodes = node.find('x:unit', "x:#{EEML_HREF}")
156
156
  raise exception_for_node(node, DataHasMultipleUnits, "Data node has multiple 'unit' nodes.") if unit_nodes.size > 1
@@ -159,7 +159,7 @@ module Eeml
159
159
  unless unit_node.nil?
160
160
  data.unit_symbol = unit_node['symbol']
161
161
  data.unit_type = unit_node['type']
162
- data.unit_value = unit_node.content
162
+ data.unit_value = unit_node.content.strip
163
163
  end
164
164
 
165
165
  return data
data/lib/eeml.rb CHANGED
@@ -14,7 +14,7 @@ require 'eeml/output_registry'
14
14
  module Eeml
15
15
 
16
16
  # library version number
17
- VERSION = '0.0.5'
17
+ VERSION = '0.0.6'
18
18
 
19
19
  # TODO: put in some configuration file, not here
20
20
  LOCAL_EEML_SCHEMA_LOCATION = 'schemas/eeml/005.xsd'
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <eeml version="5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.eeml.org/xsd/005" xsi:schemaLocation="http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd">
3
+ <environment>
4
+ <data id="4773635294300160">
5
+ <tag>
6
+ 10.F59894010800</tag>
7
+ <tag>
8
+ Living Room, S wall</tag>
9
+ <value>
10
+ 24.1875</value>
11
+ <unit type="derivedSI">
12
+ celsius</unit>
13
+ </data>
14
+ <data id="11318471228981248">
15
+ <tag>
16
+ 28.3616F1010000</tag>
17
+ <tag>
18
+ Living Room, .7m above wood stove</tag>
19
+ <value>
20
+ 24.4375</value>
21
+ <unit type="derivedSI">
22
+ celsius</unit>
23
+ </data>
24
+ </environment>
25
+ </eeml>
26
+
@@ -175,6 +175,22 @@ class TestEnvironment < Test::Unit::TestCase
175
175
  assert_raise(MissingNamespace) {env = create_env_from_xml_file('no_namespace.xml')}
176
176
  end
177
177
 
178
+ test "ok parsing oddly tagged eeml file" do
179
+ env = create_env_from_xml_file('difficult_tag.xml')
180
+ assert_equal 2, env.datastreams.size
181
+ d = env.datastreams[0]
182
+ assert_equal 2, d.tags.size
183
+ assert_equal '10.F59894010800', d.tags[0]
184
+ assert_equal 'Living Room, S wall', d.tags[1]
185
+ d2 = env.datastreams[1]
186
+ assert_equal 2, d2.tags.size
187
+ assert_equal '28.3616F1010000', d2.tags[0]
188
+ assert_equal 'Living Room, .7m above wood stove', d2.tags[1]
189
+ assert_equal '24.1875', d.value
190
+ assert_equal '24.4375', d2.value
191
+ assert_equal 'celsius', d.unit_value
192
+ end
193
+
178
194
  test "creates multiple environments from list xml" do
179
195
  xml = File.read('test/data/list.xml')
180
196
  list = Environment.new_list_from_eeml(xml)
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eeml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neill Bogie, Sam Mulube
@@ -30,7 +30,7 @@ cert_chain:
30
30
  yyRwZdVyDdsafg==
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2009-07-08 00:00:00 +01:00
33
+ date: 2009-08-18 00:00:00 +01:00
34
34
  default_executable:
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
@@ -123,6 +123,7 @@ files:
123
123
  - test/data/out_empty.xml
124
124
  - test/data/complete_namespaced.xml
125
125
  - test/data/no_namespace.xml
126
+ - test/data/difficult_tag.xml
126
127
  - test/data/doc_1.xml
127
128
  - test/data/doc_1.json
128
129
  - test/data/doc_2.xml
metadata.gz.sig CHANGED
Binary file