riddl 0.99.105

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.
Files changed (92) hide show
  1. data/AUTHORS +1 -0
  2. data/COPYING +165 -0
  3. data/INSTALL +24 -0
  4. data/README.rdoc +2 -0
  5. data/Rakefile +17 -0
  6. data/TODO +17 -0
  7. data/contrib/riddl.jpg +0 -0
  8. data/contrib/riddl.png +0 -0
  9. data/contrib/riddl.svg +138 -0
  10. data/lib/riddl/client.rb +423 -0
  11. data/lib/riddl/commonlogger.rb +16 -0
  12. data/lib/riddl/constants.rb +5 -0
  13. data/lib/riddl/error.rb +8 -0
  14. data/lib/riddl/handlers.rb +14 -0
  15. data/lib/riddl/handlers/oauth.rb +19 -0
  16. data/lib/riddl/handlers/plain-type.rb +21 -0
  17. data/lib/riddl/handlers/relaxng.rb +16 -0
  18. data/lib/riddl/handlers/xmlschema.rb +16 -0
  19. data/lib/riddl/header.rb +9 -0
  20. data/lib/riddl/implementation.rb +57 -0
  21. data/lib/riddl/ns/common-patterns/addon-security/request.xml +25 -0
  22. data/lib/riddl/ns/common-patterns/addon-security/response.xml +25 -0
  23. data/lib/riddl/ns/common-patterns/downloadify/1.0/downloadify.xml +18 -0
  24. data/lib/riddl/ns/common-patterns/notifications-consumer/1.0/consumer.xml +100 -0
  25. data/lib/riddl/ns/common-patterns/notifications-producer/1.0/producer.xml +204 -0
  26. data/lib/riddl/ns/common-patterns/properties/1.0/properties.schema.schema +140 -0
  27. data/lib/riddl/ns/common-patterns/properties/1.0/properties.schema.xsl +89 -0
  28. data/lib/riddl/ns/common-patterns/properties/1.0/properties.xml +150 -0
  29. data/lib/riddl/ns/common/datatypes-1_0.rng +79 -0
  30. data/lib/riddl/ns/common/relaxng-modular.rng +330 -0
  31. data/lib/riddl/ns/common/relaxng.rng +10 -0
  32. data/lib/riddl/ns/declaration/1.0/declaration.rng +114 -0
  33. data/lib/riddl/ns/description/1.0/description.rng +302 -0
  34. data/lib/riddl/option.rb +9 -0
  35. data/lib/riddl/parameter.rb +54 -0
  36. data/lib/riddl/protocols/http/generator.rb +121 -0
  37. data/lib/riddl/protocols/http/parser.rb +199 -0
  38. data/lib/riddl/protocols/websocket.rb +103 -0
  39. data/lib/riddl/protocols/xmpp/generator.rb +176 -0
  40. data/lib/riddl/protocols/xmpp/parser.rb +118 -0
  41. data/lib/riddl/roles.rb +15 -0
  42. data/lib/riddl/roles/http%3A%2F%2Foauth.net%2F1.0%2Faccess_token.rb +30 -0
  43. data/lib/riddl/roles/http%3A%2F%2Foauth.net%2F1.0%2Fon_behalf.rb +22 -0
  44. data/lib/riddl/roles/http%3A%2F%2Foauth.net%2F1.0%2Frequest_token.rb +30 -0
  45. data/lib/riddl/roles/http%3A%2F%2Foauth.net%2F1.0/base.rb +67 -0
  46. data/lib/riddl/server.rb +519 -0
  47. data/lib/riddl/utils/description.rb +29 -0
  48. data/lib/riddl/utils/downloadify.rb +14 -0
  49. data/lib/riddl/utils/erbserve.rb +23 -0
  50. data/lib/riddl/utils/fileserve.rb +31 -0
  51. data/lib/riddl/utils/notifications_producer.rb +310 -0
  52. data/lib/riddl/utils/properties.rb +474 -0
  53. data/lib/riddl/utils/xsloverlay.rb +21 -0
  54. data/lib/riddl/wrapper.rb +280 -0
  55. data/lib/riddl/wrapper/declaration.rb +103 -0
  56. data/lib/riddl/wrapper/declaration/facade.rb +94 -0
  57. data/lib/riddl/wrapper/declaration/interface.rb +34 -0
  58. data/lib/riddl/wrapper/declaration/tile.rb +107 -0
  59. data/lib/riddl/wrapper/description.rb +69 -0
  60. data/lib/riddl/wrapper/description/access.rb +108 -0
  61. data/lib/riddl/wrapper/description/message_and_transformation.rb +131 -0
  62. data/lib/riddl/wrapper/description/resource.rb +271 -0
  63. data/lib/riddl/wrapper/layerchecker.rb +33 -0
  64. data/lib/riddl/wrapper/messageparser.rb +221 -0
  65. data/lib/riddl/wrapper/resourcechecker.rb +98 -0
  66. data/ns/common-patterns/addon-security/request.xml +25 -0
  67. data/ns/common-patterns/addon-security/response.xml +25 -0
  68. data/ns/common-patterns/downloadify/1.0/downloadify.xml +18 -0
  69. data/ns/common-patterns/notifications-consumer/1.0/consumer.xml +100 -0
  70. data/ns/common-patterns/notifications-producer/1.0/producer.xml +204 -0
  71. data/ns/common-patterns/properties/1.0/properties.schema.schema +140 -0
  72. data/ns/common-patterns/properties/1.0/properties.schema.xsl +89 -0
  73. data/ns/common-patterns/properties/1.0/properties.xml +150 -0
  74. data/ns/common/datatypes-1_0.rng +79 -0
  75. data/ns/common/relaxng-modular.rng +330 -0
  76. data/ns/common/relaxng.rng +10 -0
  77. data/ns/declaration/1.0/declaration.rng +114 -0
  78. data/ns/description/1.0/description.rng +302 -0
  79. data/riddl.gemspec +33 -0
  80. data/test/smartrunner.rb +48 -0
  81. data/test/tc_declaration-distributed.rb +79 -0
  82. data/test/tc_declaration-hybrid.rb +71 -0
  83. data/test/tc_declaration-local.rb +47 -0
  84. data/test/tc_helloworld.rb +17 -0
  85. data/test/tc_producer.rb +54 -0
  86. data/test/tc_properties.rb +72 -0
  87. data/tools/flash-policy-server.rb +12 -0
  88. data/tools/riddlcheck +36 -0
  89. data/tools/riddlcheck-1_0 +36 -0
  90. data/tools/riddlprocess +51 -0
  91. data/tools/riddlprocess-1_0 +51 -0
  92. metadata +291 -0
@@ -0,0 +1,71 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/client')
3
+ require 'xml/smart'
4
+ require 'pp'
5
+
6
+ class TestDecHy < MiniTest::Unit::TestCase
7
+ include ServerCase
8
+
9
+ SERVER = [
10
+ TestServerInfo.new(
11
+ File.expand_path(File.dirname(__FILE__) + '/../examples/declaration-server-hybrid/xsloverlay.rb'),
12
+ File.expand_path(File.dirname(__FILE__) + '/../examples/declaration-server-hybrid/xsloverlay.xml')
13
+ ),
14
+ TestServerInfo.new(
15
+ File.expand_path(File.dirname(__FILE__) + '/../examples/declaration-server-hybrid/declaration.rb'),
16
+ File.expand_path(File.dirname(__FILE__) + '/../examples/declaration-server-hybrid/declaration.xml')
17
+ )
18
+ ]
19
+ NORUN = false
20
+
21
+ def test_dechy
22
+ ep = Riddl::Client.interface(SERVER[1].url,SERVER[1].schema)
23
+
24
+ test = ep.resource('/')
25
+ status, res = test.get
26
+ assert status == 200
27
+ doc = XML::Smart.string(res[0].value.read)
28
+ assert doc.find('/processing-instruction("xml-stylesheet")').length == 1
29
+ assert doc.find('/processing-instruction("xml-stylesheet")').first.content =~ /instances\.xsl/
30
+ assert doc.find('/instances/instance').length == 2
31
+
32
+ test = ep.resource('/1')
33
+ status, res = test.get
34
+ assert status == 200
35
+ doc = XML::Smart.string(res[0].value.read)
36
+ assert doc.find('/processing-instruction("xml-stylesheet")').length == 1
37
+ assert doc.find('/processing-instruction("xml-stylesheet")').first.content =~ /info\.xsl/
38
+ assert doc.find('/info/properties').length == 1
39
+
40
+ test = ep.resource('/1/properties')
41
+ status, res = test.get
42
+ assert status == 200
43
+ doc = XML::Smart.string(res[0].value.read)
44
+ assert doc.find('/processing-instruction("xml-stylesheet")').length == 1
45
+ assert doc.find('/processing-instruction("xml-stylesheet")').first.content =~ /properties\.xsl/
46
+ assert doc.find('/xmlns:properties/xmlns:name').length == 1
47
+ assert doc.find('/xmlns:properties/xmlns:state').length == 1
48
+ assert doc.find('/xmlns:properties/xmlns:dataelements').length == 1
49
+ assert doc.find('/xmlns:properties/xmlns:endpoints').length == 1
50
+ assert doc.find('/xmlns:properties/xmlns:handlerwrapper').length == 1
51
+ assert doc.find('/xmlns:properties/xmlns:description').length == 1
52
+
53
+ test = ep.resource('/1/properties/values')
54
+ status, res = test.get
55
+ assert status == 200
56
+ doc = XML::Smart.string(res[0].value.read)
57
+ assert doc.find('/processing-instruction("xml-stylesheet")').length == 1
58
+ assert doc.find('/processing-instruction("xml-stylesheet")').first.content =~ /values\.xsl/
59
+ assert doc.find('/xmlns:properties/xmlns:property[.="name"]').length == 1
60
+ assert doc.find('/xmlns:properties/xmlns:property[.="state"]').length == 1
61
+ assert doc.find('/xmlns:properties/xmlns:property[.="dataelements"]').length == 1
62
+ assert doc.find('/xmlns:properties/xmlns:property[.="endpoints"]').length == 1
63
+ assert doc.find('/xmlns:properties/xmlns:property[.="handlerwrapper"]').length == 1
64
+ assert doc.find('/xmlns:properties/xmlns:property[.="description"]').length == 1
65
+
66
+ test = ep.resource('/1/properties/values/name')
67
+ status, res = test.get
68
+ assert status == 200
69
+ assert res[0].value == 'laller'
70
+ end
71
+ end
@@ -0,0 +1,47 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/client')
3
+ require 'xml/smart'
4
+ require 'pp'
5
+
6
+ class TestDecLo < MiniTest::Unit::TestCase
7
+ include ServerCase
8
+
9
+ SERVER = [
10
+ TestServerInfo.new(
11
+ File.expand_path(File.dirname(__FILE__) + '/../examples/declaration-server-local/declaration.rb'),
12
+ File.expand_path(File.dirname(__FILE__) + '/../examples/declaration-server-local/declaration.xml')
13
+ )
14
+ ]
15
+ NORUN = false
16
+
17
+ def test_declo
18
+ ep = Riddl::Client.interface(SERVER[0].url,SERVER[0].schema)
19
+
20
+ test = ep.resource('/')
21
+ status, res = test.get
22
+ assert status == 200
23
+ doc = XML::Smart.string(res[0].value.read)
24
+
25
+ assert doc.find('/processing-instruction("xml-stylesheet")').length == 1
26
+ assert doc.find('/processing-instruction("xml-stylesheet")').first.content =~ /properties\.xsl/
27
+ assert doc.find('/xmlns:properties/xmlns:dataelements/*').length == 2
28
+
29
+ test = ep.resource('/values')
30
+ status, res = test.get
31
+ assert status == 200
32
+ doc = XML::Smart.string(res[0].value.read)
33
+ assert doc.find('/processing-instruction("xml-stylesheet")').length == 1
34
+ assert doc.find('/processing-instruction("xml-stylesheet")').first.content =~ /values\.xsl/
35
+ assert doc.find('/xmlns:properties/xmlns:property[.="name"]').length == 1
36
+ assert doc.find('/xmlns:properties/xmlns:property[.="state"]').length == 1
37
+ assert doc.find('/xmlns:properties/xmlns:property[.="dataelements"]').length == 1
38
+ assert doc.find('/xmlns:properties/xmlns:property[.="endpoints"]').length == 1
39
+ assert doc.find('/xmlns:properties/xmlns:property[.="handlerwrapper"]').length == 1
40
+ assert doc.find('/xmlns:properties/xmlns:property[.="description"]').length == 1
41
+
42
+ test = ep.resource('/values/state')
43
+ status, res = test.get
44
+ assert status == 200
45
+ assert res[0].value == 'stopped'
46
+ end
47
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/wrapper')
3
+
4
+ class TestHelloWorld < MiniTest::Unit::TestCase
5
+
6
+ def test_hw
7
+ riddl = Riddl::Wrapper.new(
8
+ File.expand_path(File.dirname(__FILE__) + '/../examples/helloworld/declaration.xml')
9
+ )
10
+
11
+ assert riddl.declaration?
12
+ assert riddl.validate!
13
+ assert riddl.declaration.description_xml == File.read(
14
+ File.expand_path(File.dirname(__FILE__) + '/../examples/helloworld/declaration-definition_goal.xml')
15
+ )
16
+ end
17
+ end
@@ -0,0 +1,54 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/client')
3
+ require 'xml/smart'
4
+
5
+ class TestProd < MiniTest::Unit::TestCase
6
+ include ServerCase
7
+
8
+ SERVER = [
9
+ TestServerInfo.new(
10
+ File.expand_path(File.dirname(__FILE__) + '/../examples/notifications/producer.rb'),
11
+ File.expand_path(File.dirname(__FILE__) + '/../examples/notifications/producer.declaration.xml')
12
+ )
13
+ ]
14
+ NORUN = false
15
+
16
+ def test_producer
17
+ nots = Riddl::Client.interface(SERVER[0].url,SERVER[0].schema)
18
+
19
+ test = nots.resource("/notifications/subscriptions")
20
+ status, res = test.post [
21
+ Riddl::Parameter::Simple.new("url","http://test.org"),
22
+ Riddl::Parameter::Simple.new("topic","/oliver"),
23
+ Riddl::Parameter::Simple.new("events","get"),
24
+ Riddl::Parameter::Simple.new("topic","/juergen"),
25
+ Riddl::Parameter::Simple.new("events","praise,adore")
26
+ ]
27
+ assert status == 200
28
+ assert (key = res[0].value).is_a?(String)
29
+
30
+ status, res = test.get
31
+
32
+ doc = XML::Smart.string(res[0].value.read)
33
+ doc.register_namespace 'n', 'http://riddl.org/ns/common-patterns/notifications-producer/1.0'
34
+ assert doc.find("/n:subscriptions/n:subscription[@id='#{key}' and @url='http://test.org']").any?
35
+
36
+ test = nots.resource("/notifications/subscriptions/#{key}")
37
+ status, res = test.get
38
+ assert status == 200
39
+
40
+ doc = XML::Smart.string(res[0].value.read)
41
+ doc.register_namespace 'n', 'http://riddl.org/ns/common-patterns/notifications-producer/1.0'
42
+
43
+ assert doc.find('/n:subscription/n:topic').length == 2
44
+ assert doc.find('/n:subscription/n:topic[1]/n:event').length == 1
45
+ assert doc.find('/n:subscription/n:topic[2]/n:event').length == 2
46
+
47
+ status, res = test.delete
48
+ assert status == 200
49
+
50
+ test = nots.resource("/notifications/subscriptions/#{key}")
51
+ status, res = test.get
52
+ assert status == 500
53
+ end
54
+ end
@@ -0,0 +1,72 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/client')
3
+ require 'xml/smart'
4
+
5
+ class TestProp < MiniTest::Unit::TestCase
6
+ include ServerCase
7
+
8
+ SERVER = [
9
+ TestServerInfo.new(
10
+ File.expand_path(File.dirname(__FILE__) + '/../examples/properties/description.rb'),
11
+ File.expand_path(File.dirname(__FILE__) + '/../examples/properties/properties.xml')
12
+ )
13
+ ]
14
+ NORUN = false
15
+
16
+ def test_properties
17
+ props = Riddl::Client.new(SERVER[0].url,SERVER[0].schema)
18
+
19
+ test = props.resource("/values/state")
20
+ status, res = test.get
21
+ assert status == 200
22
+ assert res.length == 1
23
+
24
+ if res[0].value == 'running'
25
+ status, res = test.put [ Riddl::Parameter::Simple.new("value","stopped") ]; assert status == 200
26
+ status, res = test.put [ Riddl::Parameter::Simple.new("value","stopped") ]; assert status == 404
27
+ else
28
+ status, res = test.put [ Riddl::Parameter::Simple.new("value","running") ]; assert status == 200
29
+ status, res = test.put [ Riddl::Parameter::Simple.new("value","running") ]; assert status == 404
30
+ end
31
+
32
+ test = props.resource("/values")
33
+ status, res = test.get
34
+ assert status == 200
35
+ assert res.length == 1
36
+
37
+ doc = XML::Smart.open(res[0].value)
38
+ assert doc.find('/xmlns:properties/xmlns:property[.="name"]').any?
39
+ assert doc.find('/xmlns:properties/xmlns:property[.="description"]').any?
40
+ assert doc.find('/xmlns:properties/xmlns:property[.="dataelements"]').any?
41
+
42
+ if doc.find('/xmlns:properties/xmlns:property[.="transformation"]').any?
43
+ test = props.resource("/values/transformation")
44
+ status, res = test.delete; assert status == 200
45
+ test = props.resource("/values")
46
+ status, res = test.post [ Riddl::Parameter::Simple.new("name","transformation"), Riddl::Parameter::Simple.new("value","xxx") ]; assert status == 200
47
+ else
48
+ test = props.resource("/values")
49
+ status, res = test.post [ Riddl::Parameter::Simple.new("name","transformation"), Riddl::Parameter::Simple.new("value","xxx") ]; assert status == 200
50
+ end
51
+
52
+ test = props.resource("/values/dataelements/c")
53
+ status, res = test.get
54
+ if status == 404
55
+ test = props.resource("/values/dataelements")
56
+ status, res = test.post [ Riddl::Parameter::Simple.new("value","<c>hallo</c>") ]; assert status == 200
57
+ elsif status == 200
58
+ test = props.resource("/values/dataelements/c")
59
+ status, res = test.delete; assert status == 200
60
+ test = props.resource("/values/dataelements")
61
+ status, res = test.post [ Riddl::Parameter::Simple.new("value","<c>hallo</c>") ]; assert status == 200
62
+ else
63
+ assert false
64
+ end
65
+
66
+ test = props.resource("/values/dataelements/c")
67
+ status, res = test.put [ Riddl::Parameter::Simple.new("value","foo") ]; assert status == 200
68
+
69
+ test = props.resource("/values/name")
70
+ status, res = test.put [ Riddl::Parameter::Simple.new("value","juergen") ]; assert status == 500
71
+ end
72
+ end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/ruby
2
+ require "socket"
3
+
4
+ WS_FLASH_SOCKET_POLICY = "<cross-domain-policy><allow-access-from domain='*' to-ports='*'/></cross-domain-policy>\n"
5
+
6
+ server = TCPServer.open(843)
7
+ loop {
8
+ Thread.start(server.accept) do |client|
9
+ client.puts WS_FLASH_SOCKET_POLICY
10
+ client.close
11
+ end
12
+ }
data/tools/riddlcheck ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby
2
+ curpath = __FILE__
3
+ while ::File::symlink?(curpath)
4
+ curpath = ::File::dirname(curpath) + '/' + ::File::readlink(curpath)
5
+ end
6
+ require 'rubygems'
7
+ require ::File::dirname(curpath) + "/../lib/riddl/wrapper"
8
+ require 'optparse'
9
+
10
+ ARGV.options { |opt|
11
+ opt.summary_indent = ' ' * 2
12
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} [options] [FILENAME]\n"
13
+ opt.on("Options:")
14
+ opt.on("--help", "-h", "This text") { puts opt; exit }
15
+ opt.on("Filename is either a description or a declaration.")
16
+ opt.parse!
17
+ }
18
+ if ARGV.length == 0 || !File.exists?(ARGV[0])
19
+ puts ARGV.options
20
+ exit
21
+ end
22
+ fname = ARGV[0]
23
+
24
+ riddl = Riddl::Wrapper::new(fname)
25
+
26
+ if riddl.description?
27
+ puts 'RIDDL description found.'
28
+ elsif riddl.declaration?
29
+ puts 'RIDDL declaration found.'
30
+ else
31
+ puts 'Neither a RIDDL description, nor a RIDDL declaration.'
32
+ exit
33
+ end
34
+
35
+ messages = riddl.validate!
36
+ puts messages ? "RIDDL looks valid." : "RIDDL not valid."
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby
2
+ curpath = __FILE__
3
+ while ::File::symlink?(curpath)
4
+ curpath = ::File::dirname(curpath) + '/' + ::File::readlink(curpath)
5
+ end
6
+ require 'rubygems'
7
+ require ::File::dirname(curpath) + "/../lib/riddl/wrapper"
8
+ require 'optparse'
9
+
10
+ ARGV.options { |opt|
11
+ opt.summary_indent = ' ' * 2
12
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} [options] [FILENAME]\n"
13
+ opt.on("Options:")
14
+ opt.on("--help", "-h", "This text") { puts opt; exit }
15
+ opt.on("Filename is either a description or a declaration.")
16
+ opt.parse!
17
+ }
18
+ if ARGV.length == 0 || !File.exists?(ARGV[0])
19
+ puts ARGV.options
20
+ exit
21
+ end
22
+ fname = ARGV[0]
23
+
24
+ riddl = Riddl::Wrapper::new(fname)
25
+
26
+ if riddl.description?
27
+ puts 'RIDDL description found.'
28
+ elsif riddl.declaration?
29
+ puts 'RIDDL declaration found.'
30
+ else
31
+ puts 'Neither a RIDDL description, nor a RIDDL declaration.'
32
+ exit
33
+ end
34
+
35
+ messages = riddl.validate!
36
+ puts messages ? "RIDDL looks valid." : "RIDDL not valid."
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/ruby
2
+ curpath = __FILE__
3
+ while ::File::symlink?(curpath)
4
+ curpath = ::File::dirname(curpath) + '/' + ::File::readlink(curpath)
5
+ end
6
+ require 'rubygems'
7
+ require ::File::dirname(curpath) + "/../lib/riddl/wrapper"
8
+ require 'optparse'
9
+ require 'pp'
10
+
11
+ dowhat = nil
12
+ ARGV.options { |opt|
13
+ opt.summary_indent = ' ' * 2
14
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} [options] [FILENAME]\n"
15
+ opt.on("Options:")
16
+ opt.on("--help", "-h", "This text.") { puts opt; exit }
17
+ opt.on("--vtl", "-l", "For each tile visualize the resource tree and the layers.") { dowhat = "layers" }
18
+ opt.on("--vtc", "-c", "For each tile visualize the resource tree and the resulting compositions.") { dowhat = "compositions" }
19
+ opt.on("--vf", "-f", "Visualize the resulting facade.") { dowhat = "facade" }
20
+ opt.on("--description", "-d", "Return the XML description for the facade.") { dowhat = "description" }
21
+ opt.on("Filename has to be a declaration.")
22
+ opt.parse!
23
+ }
24
+ if ARGV.length == 0 || !File.exists?(ARGV[0]) || dowhat.nil?
25
+ puts ARGV.options
26
+ exit
27
+ end
28
+ fname = ARGV[0]
29
+
30
+ riddl = Riddl::Wrapper.new(fname)
31
+
32
+ unless riddl.declaration?
33
+ puts 'Not a RIDDL declaration.'
34
+ exit
35
+ end
36
+ unless riddl.validate!
37
+ puts "Does not conform to specification."
38
+ exit
39
+ end
40
+
41
+ d = riddl.declaration
42
+ case dowhat
43
+ when 'layers'
44
+ d.visualize_tiles_and_layers
45
+ when 'compositions'
46
+ d.visualize_tiles_and_compositions
47
+ when 'facade'
48
+ d.visualize_facade
49
+ when 'description'
50
+ puts d.description_xml
51
+ end
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/ruby
2
+ curpath = __FILE__
3
+ while ::File::symlink?(curpath)
4
+ curpath = ::File::dirname(curpath) + '/' + ::File::readlink(curpath)
5
+ end
6
+ require 'rubygems'
7
+ require ::File::dirname(curpath) + "/../lib/riddl/wrapper"
8
+ require 'optparse'
9
+ require 'pp'
10
+
11
+ dowhat = nil
12
+ ARGV.options { |opt|
13
+ opt.summary_indent = ' ' * 2
14
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} [options] [FILENAME]\n"
15
+ opt.on("Options:")
16
+ opt.on("--help", "-h", "This text.") { puts opt; exit }
17
+ opt.on("--vtl", "-l", "For each tile visualize the resource tree and the layers.") { dowhat = "layers" }
18
+ opt.on("--vtc", "-c", "For each tile visualize the resource tree and the resulting compositions.") { dowhat = "compositions" }
19
+ opt.on("--vf", "-f", "Visualize the resulting facade.") { dowhat = "facade" }
20
+ opt.on("--description", "-d", "Return the XML description for the facade.") { dowhat = "description" }
21
+ opt.on("Filename has to be a declaration.")
22
+ opt.parse!
23
+ }
24
+ if ARGV.length == 0 || !File.exists?(ARGV[0]) || dowhat.nil?
25
+ puts ARGV.options
26
+ exit
27
+ end
28
+ fname = ARGV[0]
29
+
30
+ riddl = Riddl::Wrapper.new(fname)
31
+
32
+ unless riddl.declaration?
33
+ puts 'Not a RIDDL declaration.'
34
+ exit
35
+ end
36
+ unless riddl.validate!
37
+ puts "Does not conform to specification."
38
+ exit
39
+ end
40
+
41
+ d = riddl.declaration
42
+ case dowhat
43
+ when 'layers'
44
+ d.visualize_tiles_and_layers
45
+ when 'compositions'
46
+ d.visualize_tiles_and_compositions
47
+ when 'facade'
48
+ d.visualize_facade
49
+ when 'description'
50
+ puts d.description_xml
51
+ end