obix 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +128 -0
- data/Rakefile +7 -0
- data/lib/obix.rb +55 -0
- data/lib/obix/alarms.rb +48 -0
- data/lib/obix/builder.rb +45 -0
- data/lib/obix/configuration.rb +79 -0
- data/lib/obix/errors.rb +6 -0
- data/lib/obix/history.rb +65 -0
- data/lib/obix/network.rb +76 -0
- data/lib/obix/objects.rb +46 -0
- data/lib/obix/objects/base.rb +97 -0
- data/lib/obix/objects/boolean.rb +13 -0
- data/lib/obix/objects/date.rb +15 -0
- data/lib/obix/objects/duration.rb +14 -0
- data/lib/obix/objects/enumerable.rb +13 -0
- data/lib/obix/objects/error.rb +26 -0
- data/lib/obix/objects/feed.rb +14 -0
- data/lib/obix/objects/float.rb +16 -0
- data/lib/obix/objects/integer.rb +15 -0
- data/lib/obix/objects/list.rb +14 -0
- data/lib/obix/objects/object.rb +20 -0
- data/lib/obix/objects/operation.rb +28 -0
- data/lib/obix/objects/reference.rb +10 -0
- data/lib/obix/objects/string.rb +14 -0
- data/lib/obix/objects/time.rb +15 -0
- data/lib/obix/objects/uri.rb +13 -0
- data/lib/obix/tag.rb +43 -0
- data/lib/obix/types.rb +15 -0
- data/lib/obix/types/boolean.rb +25 -0
- data/lib/obix/types/date.rb +20 -0
- data/lib/obix/types/duration.rb +21 -0
- data/lib/obix/types/float.rb +18 -0
- data/lib/obix/types/integer.rb +18 -0
- data/lib/obix/types/string.rb +18 -0
- data/lib/obix/types/time.rb +20 -0
- data/lib/obix/types/type.rb +17 -0
- data/lib/obix/types/uri.rb +28 -0
- data/lib/obix/version.rb +3 -0
- data/lib/obix/watch.rb +119 -0
- data/obix.gemspec +31 -0
- data/test/fixtures/alarmqueryout.xml +19 -0
- data/test/fixtures/alarmsubject.xml +5 -0
- data/test/fixtures/history.xml +9 -0
- data/test/fixtures/historyqueryout.xml +15 -0
- data/test/fixtures/invalid.xml +1 -0
- data/test/fixtures/objects/boolean.xml +1 -0
- data/test/fixtures/objects/date.xml +1 -0
- data/test/fixtures/objects/duration.xml +1 -0
- data/test/fixtures/objects/enumerable.xml +1 -0
- data/test/fixtures/objects/error.xml +1 -0
- data/test/fixtures/objects/feed.xml +4 -0
- data/test/fixtures/objects/float.xml +1 -0
- data/test/fixtures/objects/integer.xml +1 -0
- data/test/fixtures/objects/list.xml +4 -0
- data/test/fixtures/objects/object.xml +1 -0
- data/test/fixtures/objects/operation.xml +1 -0
- data/test/fixtures/objects/reference.xml +1 -0
- data/test/fixtures/objects/string.xml +1 -0
- data/test/fixtures/objects/time.xml +1 -0
- data/test/fixtures/objects/uri.xml +1 -0
- data/test/fixtures/valid.xml +11 -0
- data/test/fixtures/watch.xml +8 -0
- data/test/fixtures/watchout.xml +5 -0
- data/test/fixtures/watchservice.xml +3 -0
- data/test/obix/alarms_test.rb +36 -0
- data/test/obix/builder_test.rb +32 -0
- data/test/obix/configuration_test.rb +32 -0
- data/test/obix/history_test.rb +54 -0
- data/test/obix/network_test.rb +134 -0
- data/test/obix/objects/base_test.rb +54 -0
- data/test/obix/objects/boolean_test.rb +17 -0
- data/test/obix/objects/date_test.rb +16 -0
- data/test/obix/objects/duration_test.rb +16 -0
- data/test/obix/objects/enumerable_test.rb +17 -0
- data/test/obix/objects/error_test.rb +47 -0
- data/test/obix/objects/feed_test.rb +16 -0
- data/test/obix/objects/float_test.rb +16 -0
- data/test/obix/objects/integer_test.rb +16 -0
- data/test/obix/objects/list_test.rb +17 -0
- data/test/obix/objects/object_test.rb +17 -0
- data/test/obix/objects/operation_test.rb +37 -0
- data/test/obix/objects/reference_test.rb +16 -0
- data/test/obix/objects/string_test.rb +16 -0
- data/test/obix/objects/time_test.rb +16 -0
- data/test/obix/objects/uri_test.rb +16 -0
- data/test/obix/objects_test.rb +13 -0
- data/test/obix/tag_test.rb +42 -0
- data/test/obix/types/boolean_test.rb +18 -0
- data/test/obix/types/date_test.rb +20 -0
- data/test/obix/types/duration_test.rb +18 -0
- data/test/obix/types/float_test.rb +18 -0
- data/test/obix/types/integer_test.rb +18 -0
- data/test/obix/types/string_test.rb +18 -0
- data/test/obix/types/time_test.rb +20 -0
- data/test/obix/types/uri_test.rb +48 -0
- data/test/obix/watch_test.rb +169 -0
- data/test/obix_test.rb +42 -0
- data/test/test_helper.rb +18 -0
- metadata +357 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class BooleanTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_booleans
|
10
|
+
object = OBIX.parse string: fixture("objects/boolean.xml")
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::Boolean, object
|
13
|
+
assert_equal true, object.val
|
14
|
+
assert_equal "http://example.org/range", object.range
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class DateTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_strings
|
10
|
+
object = OBIX.parse string: fixture("objects/date.xml")
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::Date, object
|
13
|
+
assert_equal Date.parse("2007-11-26"), object.val
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class DurationTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_durations
|
10
|
+
object = OBIX.parse string: fixture("objects/duration.xml")
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::Duration, object
|
13
|
+
assert_equal 15, object.val
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class EnumerableTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_enumerables
|
10
|
+
object = OBIX.parse string: fixture("objects/enumerable.xml")
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::Enumerable, object
|
13
|
+
assert_equal "/enums/OffSlowFast", object.range
|
14
|
+
assert_equal "slow", object.val
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class ErrorTest < MiniTest::Unit::TestCase
|
8
|
+
def test_raises_errors
|
9
|
+
builder = OBIX::Builder.new do |obix|
|
10
|
+
obix.err display: "uh oh"
|
11
|
+
end
|
12
|
+
|
13
|
+
assert_raises OBIX::Error do
|
14
|
+
builder.object.raise
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_raises_bad_uri_errors
|
19
|
+
builder = OBIX::Builder.new do |obix|
|
20
|
+
obix.err display: "uh oh", is: "obix:BadUriErr"
|
21
|
+
end
|
22
|
+
|
23
|
+
assert_raises OBIX::BadURIError do
|
24
|
+
builder.object.raise
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_raises_unsupported_errors
|
29
|
+
builder = OBIX::Builder.new do |obix|
|
30
|
+
obix.err display: "uh oh", is: "obix:UnsupportedErr"
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_raises OBIX::UnsupportedError do
|
34
|
+
builder.object.raise
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_raises_permission_errors
|
39
|
+
builder = OBIX::Builder.new do |obix|
|
40
|
+
obix.err display: "uh oh", is: "obix:PermissionErr"
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_raises OBIX::PermissionError do
|
44
|
+
builder.object.raise
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class FeedTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_feeds
|
10
|
+
object = OBIX.parse string: fixture("objects/feed.xml")
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::Feed, object
|
13
|
+
assert_equal "obix:Alarm", object.of
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class FloatTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_floats
|
10
|
+
object = OBIX.parse string: fixture("objects/float.xml")
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::Float, object
|
13
|
+
assert_equal 41.06, object.val
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class IntegerTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_integers
|
10
|
+
object = OBIX.parse string: fixture("objects/integer.xml")
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::Integer, object
|
13
|
+
assert_equal 52, object.val
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class ListTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_booleans
|
10
|
+
object = OBIX.parse string: fixture("objects/list.xml")
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::List, object
|
13
|
+
assert_equal "obix:str", object.of
|
14
|
+
assert_equal 2, object.objects.size
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "active_support/all"
|
5
|
+
|
6
|
+
require "test_helper"
|
7
|
+
|
8
|
+
class ObjectTest < MiniTest::Unit::TestCase
|
9
|
+
|
10
|
+
def test_parses_objects
|
11
|
+
object = OBIX.parse string: fixture("objects/object.xml")
|
12
|
+
|
13
|
+
assert_instance_of OBIX::Objects::Object, object
|
14
|
+
assert_equal "object", object.name
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class OperationTest < MiniTest::Unit::TestCase
|
8
|
+
def test_parses_operations
|
9
|
+
operation = OBIX.parse string: fixture("objects/operation.xml")
|
10
|
+
|
11
|
+
assert_instance_of OBIX::Objects::Operation, operation
|
12
|
+
assert_equal "http://domain/operate", operation.href
|
13
|
+
assert_equal "obix:Nil", operation.in
|
14
|
+
assert_equal "obix:Nil", operation.out
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_invokes_operations
|
18
|
+
operation = OBIX.parse string: fixture("objects/operation.xml")
|
19
|
+
|
20
|
+
object = OBIX::Objects::Object.new
|
21
|
+
|
22
|
+
OBIX::Network.
|
23
|
+
expects(
|
24
|
+
:post
|
25
|
+
).
|
26
|
+
with(
|
27
|
+
'http://domain/operate', object
|
28
|
+
).
|
29
|
+
returns(
|
30
|
+
fixture "objects/string.xml"
|
31
|
+
)
|
32
|
+
|
33
|
+
result = operation.invoke object
|
34
|
+
|
35
|
+
assert_instance_of OBIX::Objects::String, result
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class ReferenceTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_references
|
10
|
+
object = OBIX.parse file: "test/fixtures/objects/reference.xml"
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::Reference, object
|
13
|
+
assert_equal "http://obix.org/", object.href
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class StringTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_strings
|
10
|
+
object = OBIX.parse string: fixture("objects/string.xml")
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::String, object
|
13
|
+
assert_equal "hello world", object.val
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class TimeTest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_strings
|
10
|
+
object = OBIX.parse string: fixture("objects/time.xml")
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::Time, object
|
13
|
+
assert_equal Time.parse("2005-03-09 13:30:00 UTC"), object.val
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
require "test_helper"
|
6
|
+
|
7
|
+
class URITest < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_parses_uris
|
10
|
+
object = OBIX.parse file: "test/fixtures/objects/uri.xml"
|
11
|
+
|
12
|
+
assert_instance_of OBIX::Objects::URI, object
|
13
|
+
assert_equal "http://obix.org/", object.val
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "nokogiri"
|
5
|
+
require "active_support/all"
|
6
|
+
|
7
|
+
require "test_helper"
|
8
|
+
|
9
|
+
class ObjectsTest < MiniTest::Unit::TestCase
|
10
|
+
def test_list
|
11
|
+
assert_equal 15, OBIX::Objects.list.size
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "nokogiri"
|
5
|
+
require "active_support/all"
|
6
|
+
|
7
|
+
require "test_helper"
|
8
|
+
|
9
|
+
class TagTest < MiniTest::Unit::TestCase
|
10
|
+
class Dummy < OBIX::Objects::Base
|
11
|
+
tag :dummy
|
12
|
+
|
13
|
+
attribute :foo, type: OBIX::Types::String
|
14
|
+
attribute :default, default: "default"
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_tag
|
18
|
+
dummy = Dummy.new
|
19
|
+
|
20
|
+
assert_equal :dummy, dummy.tag
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_get_attribute
|
24
|
+
dummy = Dummy.new
|
25
|
+
dummy.foo = "foo"
|
26
|
+
|
27
|
+
assert_equal "foo", dummy.foo
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_set_attribute
|
31
|
+
dummy = Dummy.new
|
32
|
+
dummy.foo = "bar"
|
33
|
+
|
34
|
+
assert_equal "bar", dummy.foo
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_default_attribute
|
38
|
+
dummy = Dummy.new
|
39
|
+
|
40
|
+
assert_equal "default", dummy.default
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "nokogiri"
|
5
|
+
require "active_support/all"
|
6
|
+
|
7
|
+
require "test_helper"
|
8
|
+
|
9
|
+
class BooleanTest < MiniTest::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@object = OBIX::Objects::Object.new
|
12
|
+
@type = OBIX::Types::Boolean.new @object
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_cast
|
16
|
+
assert_equal true, @type.cast("true")
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "nokogiri"
|
5
|
+
require "active_support/all"
|
6
|
+
|
7
|
+
require "test_helper"
|
8
|
+
|
9
|
+
class DateTest < MiniTest::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@object = OBIX::Objects::Object.new
|
12
|
+
@type = OBIX::Types::Date.new @object
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_cast
|
16
|
+
date = "2007-11-26"
|
17
|
+
|
18
|
+
assert_equal Date.parse(date), @type.cast(date)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "nokogiri"
|
5
|
+
require "active_support/all"
|
6
|
+
|
7
|
+
require "test_helper"
|
8
|
+
|
9
|
+
class DurationTest < MiniTest::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@object = OBIX::Objects::Object.new
|
12
|
+
@type = OBIX::Types::Duration.new @object
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_cast
|
16
|
+
assert_equal 15, @type.cast("PT15S")
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "obix"
|
2
|
+
require "minitest/unit"
|
3
|
+
require "minitest/autorun"
|
4
|
+
require "nokogiri"
|
5
|
+
require "active_support/all"
|
6
|
+
|
7
|
+
require "test_helper"
|
8
|
+
|
9
|
+
class FloatTest < MiniTest::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@object = OBIX::Objects::Object.new
|
12
|
+
@type = OBIX::Types::Float.new @object
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_cast
|
16
|
+
assert_equal 25.5, @type.cast("25.5")
|
17
|
+
end
|
18
|
+
end
|