cosm-rb 0.2.07 → 0.2.09
Sign up to get free protection for your applications and to get access to all the features.
- data/.rbenv-version +1 -1
- data/.travis.yml +3 -2
- data/Gemfile +11 -0
- data/README.md +0 -8
- data/Rakefile +1 -13
- data/cosm-rb.gemspec +0 -9
- data/lib/cosm-rb/base/instance_methods.rb +1 -1
- data/lib/cosm-rb/client.rb +36 -0
- data/lib/cosm-rb/feed.rb +1 -1
- data/lib/cosm-rb/helpers.rb +1 -1
- data/lib/cosm-rb/templates/csv/feed_defaults.rb +1 -1
- data/lib/cosm-rb/templates/json/feed_defaults.rb +3 -1
- data/lib/cosm-rb/templates/xml/feed_defaults.rb +2 -0
- data/lib/cosm-rb/templates/xml/search_result_defaults.rb +2 -0
- data/lib/cosm-rb/version.rb +1 -1
- data/spec/cosm-rb/client_spec.rb +44 -0
- data/spec/cosm-rb/feed_spec.rb +1 -1
- data/spec/cosm-rb/helpers_spec.rb +2 -2
- data/spec/cosm-rb/parsers/csv/feed_defaults_spec.rb +4 -4
- data/spec/cosm-rb/parsers/xml/datastream_defaults_spec.rb +8 -8
- data/spec/cosm-rb/parsers/xml/feed_defaults_spec.rb +12 -12
- data/spec/cosm-rb/templates/json/feed_defaults_spec.rb +4 -2
- data/spec/cosm-rb/templates/json/search_result_defaults_spec.rb +2 -2
- data/spec/cosm-rb/templates/xml/datastream_defaults_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -12
- data/spec/support/contain_feed_eeml_matcher.rb +2 -0
- data/spec/support/datapoint_helper.rb +11 -11
- data/spec/support/datastream_helper.rb +122 -122
- data/spec/support/feed_helper.rb +302 -300
- data/spec/support/trigger_helper.rb +11 -11
- metadata +4 -68
data/.rbenv-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-1.9.3-
|
1
|
+
ruby-1.9.3-p392
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,11 +8,3 @@ You can also interact with the Cosm REST API using this gem.
|
|
8
8
|
### Documentation
|
9
9
|
|
10
10
|
Documentation can be found on the [wiki](https://github.com/cosm/cosm-rb/wiki/Documentation).
|
11
|
-
|
12
|
-
### Examples
|
13
|
-
|
14
|
-
A working example using this gem can be found [here](https://github.com/levent/cosm_app-rb/)
|
15
|
-
|
16
|
-
This gem will convert between Cosm Data Formats.
|
17
|
-
You can use it to prepare data for sending to Cosm or for parsing data received from Cosm.
|
18
|
-
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'bundler/setup'
|
|
2
2
|
|
3
3
|
#require 'rake/testtask'
|
4
4
|
require 'rake/clean'
|
5
|
-
require 'rake/
|
5
|
+
require 'rake/task'
|
6
6
|
require "rspec/core/rake_task"
|
7
7
|
|
8
8
|
CLEAN.include('pkg')
|
@@ -16,18 +16,6 @@ task :default => :spec
|
|
16
16
|
# run tests before building
|
17
17
|
task :build => :spec
|
18
18
|
|
19
|
-
desc "Run all specs in spec directory"
|
20
|
-
RSpec::Core::RakeTask.new do |t|
|
21
|
-
end
|
22
|
-
|
23
|
-
if RUBY_VERSION.to_f < 1.9
|
24
|
-
desc "Run all specs with rcov"
|
25
|
-
RSpec::Core::RakeTask.new(:rcov => :clean) do |t|
|
26
|
-
t.rcov = true
|
27
|
-
t.rcov_opts = '--exclude .gem/*,spec/*,.bundle/*,config/*,.rvm/*,lib/cosm-rb.rb'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
19
|
namespace :spec do
|
32
20
|
desc "Run all specs tagged with :focus => true"
|
33
21
|
RSpec::Core::RakeTask.new(:focus) do |t|
|
data/cosm-rb.gemspec
CHANGED
@@ -30,19 +30,10 @@ Gem::Specification.new do |s|
|
|
30
30
|
begin
|
31
31
|
if !defined?(JRUBY_VERSION)
|
32
32
|
s.add_dependency("ox", ">= 1.5.9")
|
33
|
-
if RUBY_VERSION.to_f < 1.9
|
34
|
-
s.add_development_dependency("ruby-debug")
|
35
|
-
s.add_development_dependency("rcov", ">=0.9.9")
|
36
|
-
else
|
37
|
-
s.add_development_dependency("debugger")
|
38
|
-
s.add_development_dependency("simplecov", ">=0.7.1")
|
39
|
-
end
|
40
33
|
end
|
41
34
|
rescue
|
42
35
|
p "Could not detect ruby version"
|
43
36
|
end
|
44
|
-
s.add_development_dependency("rake", "=0.8.7")
|
45
|
-
s.add_development_dependency("rspec", "=2.6.0")
|
46
37
|
|
47
38
|
s.extra_rdoc_files = ["README.md", "CHANGELOG.md", "MIT-LICENSE"]
|
48
39
|
s.rdoc_options << '--main' << 'README'
|
data/lib/cosm-rb/client.rb
CHANGED
@@ -3,5 +3,41 @@ module Cosm
|
|
3
3
|
class Client
|
4
4
|
include HTTParty
|
5
5
|
base_uri 'https://api.cosm.com'
|
6
|
+
|
7
|
+
attr_accessor :api_key
|
8
|
+
|
9
|
+
def self.user_agent
|
10
|
+
"cosm-rb/#{Cosm::VERSION}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(api_key)
|
14
|
+
@api_key = api_key
|
15
|
+
end
|
16
|
+
|
17
|
+
def get(url, options = {})
|
18
|
+
self.class.get(url, parse_options(options))
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete(url, options = {})
|
22
|
+
self.class.delete(url, parse_options(options))
|
23
|
+
end
|
24
|
+
|
25
|
+
def put(url, options = {})
|
26
|
+
self.class.put(url, parse_options(options))
|
27
|
+
end
|
28
|
+
|
29
|
+
def post(url, options = {})
|
30
|
+
self.class.post(url, parse_options(options))
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def parse_options(options = {})
|
36
|
+
new_options = options.clone
|
37
|
+
new_options[:headers] ||= {}
|
38
|
+
new_options[:headers].merge!("User-Agent" => self.class.user_agent, "X-ApiKey" => api_key)
|
39
|
+
new_options
|
40
|
+
end
|
41
|
+
|
6
42
|
end
|
7
43
|
end
|
data/lib/cosm-rb/feed.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Cosm
|
2
2
|
class Feed
|
3
3
|
# The order of these keys is the order attributes are assigned in. (i.e. id should come before datastreams)
|
4
|
-
ALLOWED_KEYS = %w(id creator owner_login datastreams description email feed icon location_disposition location_domain location_ele location_exposure location_lat location_lon location_name location_waypoints private status tags title updated created website auto_feed_url csv_version)
|
4
|
+
ALLOWED_KEYS = %w(id creator owner_login datastreams description email feed icon location_disposition location_domain location_ele location_exposure location_lat location_lon location_name location_waypoints private status tags title updated created website auto_feed_url product_id device_serial csv_version)
|
5
5
|
ALLOWED_KEYS.each { |key| attr_accessor(key.to_sym) }
|
6
6
|
|
7
7
|
include Cosm::Templates::JSON::FeedDefaults
|
data/lib/cosm-rb/helpers.rb
CHANGED
@@ -36,7 +36,9 @@ module Cosm
|
|
36
36
|
:user => ({ :login => owner_login } if owner_login),
|
37
37
|
:version => "1.0.0",
|
38
38
|
:datastreams => datastreams.map {|ds| ds.generate_json("1.0.0", options.merge({:hide_version => true}))},
|
39
|
-
:location => location_hash(options)
|
39
|
+
:location => location_hash(options),
|
40
|
+
:product_id => product_id,
|
41
|
+
:device_serial => device_serial
|
40
42
|
}
|
41
43
|
end
|
42
44
|
|
@@ -29,6 +29,8 @@ module Cosm
|
|
29
29
|
environment.icon icon unless icon.blank?
|
30
30
|
environment.website website unless website.blank?
|
31
31
|
environment.email email unless email.blank?
|
32
|
+
environment.product_id product_id unless product_id.blank?
|
33
|
+
environment.device_serial device_serial unless device_serial.blank?
|
32
34
|
environment.private_ self.private.to_s
|
33
35
|
parse_tag_string(tags).each do |tag|
|
34
36
|
environment.tag tag
|
@@ -32,6 +32,8 @@ module Cosm
|
|
32
32
|
environment.icon env.icon
|
33
33
|
environment.website env.website
|
34
34
|
environment.email env.email
|
35
|
+
environment.product_id env.product_id
|
36
|
+
environment.device_serial env.device_serial
|
35
37
|
environment.private_ env.private
|
36
38
|
parse_tag_string(env.tags).each do |tag|
|
37
39
|
environment.tag tag
|
data/lib/cosm-rb/version.rb
CHANGED
data/spec/cosm-rb/client_spec.rb
CHANGED
@@ -1,7 +1,51 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Cosm::Client" do
|
4
|
+
before do
|
5
|
+
@client = Cosm::Client.new("abcdefg")
|
6
|
+
end
|
7
|
+
|
4
8
|
it "should have the base uri defined" do
|
5
9
|
Cosm::Client.base_uri.should == 'https://api.cosm.com'
|
6
10
|
end
|
11
|
+
|
12
|
+
it "should be initializable with an api key" do
|
13
|
+
@client.api_key.should eql("abcdefg")
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#get" do
|
17
|
+
it "should make the appropriate request" do
|
18
|
+
request_stub = stub_request(:get, "#{Cosm::Client.base_uri}/v2/feeds/504.json").
|
19
|
+
with(:headers => {'User-Agent' => Cosm::Client.user_agent, 'X-ApiKey' => 'abcdefg'})
|
20
|
+
@client.get('/v2/feeds/504.json')
|
21
|
+
request_stub.should have_been_made
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#put" do
|
26
|
+
it "should make the appropriate request" do
|
27
|
+
request_stub = stub_request(:put, "#{Cosm::Client.base_uri}/v2/feeds/504.json").
|
28
|
+
with(:headers => {'User-Agent' => Cosm::Client.user_agent, 'X-ApiKey' => 'abcdefg'}, :body => "dataz")
|
29
|
+
@client.put('/v2/feeds/504.json', :body => "dataz")
|
30
|
+
request_stub.should have_been_made
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#post" do
|
35
|
+
it "should make the appropriate request" do
|
36
|
+
request_stub = stub_request(:post, "#{Cosm::Client.base_uri}/v2/feeds/504.json").
|
37
|
+
with(:headers => {'User-Agent' => Cosm::Client.user_agent, 'X-ApiKey' => 'abcdefg'}, :body => "dataz")
|
38
|
+
@client.post('/v2/feeds/504.json', :body => "dataz")
|
39
|
+
request_stub.should have_been_made
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#delete" do
|
44
|
+
it "should make the appropriate request" do
|
45
|
+
request_stub = stub_request(:delete, "#{Cosm::Client.base_uri}/v2/feeds/504/datastreams/test.json").
|
46
|
+
with(:headers => {'User-Agent' => Cosm::Client.user_agent, 'X-ApiKey' => 'abcdefg'})
|
47
|
+
@client.delete('/v2/feeds/504/datastreams/test.json')
|
48
|
+
request_stub.should have_been_made
|
49
|
+
end
|
50
|
+
end
|
7
51
|
end
|
data/spec/cosm-rb/feed_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Cosm::Feed do
|
4
4
|
|
5
5
|
it "should have a constant that defines the allowed keys" do
|
6
|
-
Cosm::Feed::ALLOWED_KEYS.should == %w(id creator owner_login datastreams description email feed icon location_disposition location_domain location_ele location_exposure location_lat location_lon location_name location_waypoints private status tags title updated created website auto_feed_url csv_version)
|
6
|
+
Cosm::Feed::ALLOWED_KEYS.should == %w(id creator owner_login datastreams description email feed icon location_disposition location_domain location_ele location_exposure location_lat location_lon location_name location_waypoints private status tags title updated created website auto_feed_url product_id device_serial csv_version)
|
7
7
|
end
|
8
8
|
|
9
9
|
context "attr accessors" do
|
@@ -29,7 +29,7 @@ describe "Template helpers" do
|
|
29
29
|
|
30
30
|
it "should handle complex tags" do
|
31
31
|
string = 'apple, orange, "red room", " I like space ", "tennis, later"'
|
32
|
-
parse_tag_string(string).should ==
|
32
|
+
parse_tag_string(string).should ==
|
33
33
|
[
|
34
34
|
" I like space ",
|
35
35
|
"apple",
|
@@ -41,7 +41,7 @@ describe "Template helpers" do
|
|
41
41
|
|
42
42
|
it "should handle tags with escaped double quote" do
|
43
43
|
string = 'apple, orange, "horse:height=2\"", " I like space ", "tennis, later", "\"quote\""'
|
44
|
-
parse_tag_string(string).should ==
|
44
|
+
parse_tag_string(string).should ==
|
45
45
|
[
|
46
46
|
" I like space ",
|
47
47
|
"\"quote\"",
|
@@ -64,9 +64,9 @@ describe "default feed csv parser" do
|
|
64
64
|
it "should raise an error if passed some wild csv with more than max permitted three columns" do
|
65
65
|
csv =<<-CSV
|
66
66
|
Date-Time, System HOA,Jockey Pump HOA,VFD Pump HOA,Lag Pump HOA,Lag Pump 2 HOA,Power Monitor,Water Level Relay,High Discharge Pressure,Reset Function,Jockey Running,VFD Run,Lag Pump Run,VFD Fault,Filter In Auto,Filter In Hand,Differential Press 1,Filter 1 Running,High Limit Switch,Low Limit Switch,Lag Pump Running,VFD Run Output Auto,VFD Pump On,Lag Pump,Lag Pump 1 On,System Auto Mode,Fault,Lag Pump 2 Run,Jockey On,Jockey Pump Run,Lag Pump 2,Filter Forward,Filter Reverse,Filter Solenoid,Pressure,Flow,Unknown?,VFD Input,VFD Output,
|
67
|
-
2009;Apr;19;12;44;15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1,
|
68
|
-
2009;Apr;19;12;44;30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1,
|
69
|
-
2009;Apr;19;12;48;52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1,
|
67
|
+
2009;Apr;19;12;44;15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1,
|
68
|
+
2009;Apr;19;12;44;30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1,
|
69
|
+
2009;Apr;19;12;48;52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1,
|
70
70
|
CSV
|
71
71
|
expect {
|
72
72
|
Cosm::Feed.new(csv)
|
@@ -108,7 +108,7 @@ CSV
|
|
108
108
|
context "unwanted whitespace" do
|
109
109
|
it "should strip whitespace from v2" do
|
110
110
|
dodgy_csv = <<-CSV
|
111
|
-
0, 00035
|
111
|
+
0, 00035
|
112
112
|
stream1, 0012
|
113
113
|
2, 2012-08-02T14:11:14Z ," red car "
|
114
114
|
CSV
|
@@ -47,10 +47,10 @@ describe "default datastream xml parser" do
|
|
47
47
|
|
48
48
|
it "should raise exception if passed xml without any datastreams" do
|
49
49
|
xml = <<-XML
|
50
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
51
|
-
<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">
|
52
|
-
<environment id="504" creator="http://appdev.loc:3000/users/occaecati">
|
53
|
-
</environment>
|
50
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
51
|
+
<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">
|
52
|
+
<environment id="504" creator="http://appdev.loc:3000/users/occaecati">
|
53
|
+
</environment>
|
54
54
|
</eeml>
|
55
55
|
XML
|
56
56
|
|
@@ -106,9 +106,9 @@ XML
|
|
106
106
|
it "should raise exception if passed xml without any datastreams" do
|
107
107
|
xml = <<-XML
|
108
108
|
<?xml version="1.0" encoding="UTF-8"?>
|
109
|
-
<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">
|
110
|
-
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://appdev.loc:3000/users/occaecati">
|
111
|
-
</environment>
|
109
|
+
<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">
|
110
|
+
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://appdev.loc:3000/users/occaecati">
|
111
|
+
</environment>
|
112
112
|
</eeml>
|
113
113
|
XML
|
114
114
|
|
@@ -126,7 +126,7 @@ XML
|
|
126
126
|
|
127
127
|
it "should handle being passed xml containing datapoints with no timestamp" do
|
128
128
|
xml = <<-XML
|
129
|
-
<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">
|
129
|
+
<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">
|
130
130
|
<environment>
|
131
131
|
<data>
|
132
132
|
<datapoints>
|
@@ -61,13 +61,13 @@ EOXML
|
|
61
61
|
it "should handle datastream with no current_value" do
|
62
62
|
xml = <<-EOXML
|
63
63
|
<?xml version="1.0" encoding="UTF-8"?>
|
64
|
-
<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">
|
65
|
-
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
|
66
|
-
<title>Cosm Office environment</title>
|
67
|
-
<data id="0">
|
68
|
-
<tag>freakin lasers</tag>
|
69
|
-
<tag>humidity</tag>
|
70
|
-
<tag>Temperature</tag>
|
64
|
+
<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">
|
65
|
+
<environment updated="2011-02-16T16:21:01.834174Z" id="504" creator="http://test.host/users/fred">
|
66
|
+
<title>Cosm Office environment</title>
|
67
|
+
<data id="0">
|
68
|
+
<tag>freakin lasers</tag>
|
69
|
+
<tag>humidity</tag>
|
70
|
+
<tag>Temperature</tag>
|
71
71
|
</data>
|
72
72
|
</environment>
|
73
73
|
</eeml>
|
@@ -120,11 +120,11 @@ EOXML
|
|
120
120
|
feed = Cosm::Feed.new(@xml)
|
121
121
|
Cosm::Feed.new(@xml).should fully_represent_feed(:xml, @xml)
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
it "should handle present but empty tags" do
|
125
125
|
xml = <<-EOXML
|
126
126
|
<?xml version="1.0" encoding="UTF-8"?>
|
127
|
-
<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">
|
127
|
+
<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">
|
128
128
|
<environment>
|
129
129
|
<title>ohai</title>
|
130
130
|
<data id="123">
|
@@ -141,7 +141,7 @@ EOXML
|
|
141
141
|
it "should gracefully handle 5 xml missing the base environment node" do
|
142
142
|
xml = <<-EOXML
|
143
143
|
<?xml version="1.0" encoding="UTF-8"?>
|
144
|
-
<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">
|
144
|
+
<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">
|
145
145
|
<title>ohai</title>
|
146
146
|
</eeml>
|
147
147
|
EOXML
|
@@ -220,7 +220,7 @@ EOXML
|
|
220
220
|
context "feeds with datapoints" do
|
221
221
|
it "should grab all datapoints present in valid xml" do
|
222
222
|
xml = <<-XML
|
223
|
-
<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">
|
223
|
+
<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">
|
224
224
|
<environment>
|
225
225
|
<data id="0">
|
226
226
|
<datapoints>
|
@@ -231,7 +231,7 @@ EOXML
|
|
231
231
|
</datapoints>
|
232
232
|
</data>
|
233
233
|
<data id="1">
|
234
|
-
<current_value at="2010-05-20T11:01:47Z">23</current_value>
|
234
|
+
<current_value at="2010-05-20T11:01:47Z">23</current_value>
|
235
235
|
<datapoints>
|
236
236
|
<value at="2010-05-20T11:01:43Z">24</value>
|
237
237
|
<value at="2010-05-20T11:01:44Z">25</value>
|
@@ -28,6 +28,8 @@ describe "default feed json templates" do
|
|
28
28
|
json[:created].should == "2011-01-01T00:00:00.000000+00:00"
|
29
29
|
json[:email].should == "abc@example.com"
|
30
30
|
json[:creator].should == "http://cosm.com/users/skeletor"
|
31
|
+
json[:product_id].should == "product_id"
|
32
|
+
json[:device_serial].should == "device_serial"
|
31
33
|
json[:location][:disposition].should == "fixed"
|
32
34
|
json[:location][:name].should == "office"
|
33
35
|
json[:location][:exposure].should == "indoor"
|
@@ -175,7 +177,7 @@ describe "default feed json templates" do
|
|
175
177
|
json[:location][:disposition].should be_nil
|
176
178
|
json[:location][:ele].should be_nil
|
177
179
|
end
|
178
|
-
|
180
|
+
|
179
181
|
it "should ignore location_waypoints if it is nil" do
|
180
182
|
@feed.location_disposition = 'mobile'
|
181
183
|
@feed.location_waypoints = nil
|
@@ -183,7 +185,7 @@ describe "default feed json templates" do
|
|
183
185
|
json[:location][:disposition].should == 'mobile'
|
184
186
|
json[:location][:waypoints].should be_nil
|
185
187
|
end
|
186
|
-
|
188
|
+
|
187
189
|
it "should use location_waypoints if it is set" do
|
188
190
|
@feed.location_disposition = 'mobile'
|
189
191
|
@feed.location_waypoints = [
|
@@ -18,7 +18,7 @@ describe "default search result json templates" do
|
|
18
18
|
}
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
context "0.6-alpha" do
|
23
23
|
it "should represent Pachube v1 json for search results" do
|
24
24
|
@search_result.results.each do |feed|
|
@@ -31,7 +31,7 @@ describe "default search result json templates" do
|
|
31
31
|
:results => ["feed_6_json"]
|
32
32
|
}
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
35
35
|
end
|
36
36
|
|
37
37
|
|