riddl 0.99.125 → 0.99.129

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/Rakefile +4 -0
  2. data/lib/{riddl → ruby/riddl}/client.rb +0 -0
  3. data/lib/{riddl → ruby/riddl}/commonlogger.rb +0 -0
  4. data/lib/{riddl → ruby/riddl}/constants.rb +0 -0
  5. data/lib/{riddl → ruby/riddl}/error.rb +0 -0
  6. data/lib/{riddl → ruby/riddl}/handlers.rb +0 -0
  7. data/lib/{riddl → ruby/riddl}/handlers/oauth.rb +0 -0
  8. data/lib/{riddl → ruby/riddl}/handlers/plain-type.rb +0 -0
  9. data/lib/{riddl → ruby/riddl}/handlers/relaxng.rb +3 -1
  10. data/lib/{riddl → ruby/riddl}/handlers/xmlschema.rb +0 -0
  11. data/lib/{riddl → ruby/riddl}/header.rb +0 -0
  12. data/lib/{riddl → ruby/riddl}/implementation.rb +0 -0
  13. data/lib/{riddl → ruby/riddl}/ns/common-patterns/addon-security/request.xml +0 -0
  14. data/lib/{riddl → ruby/riddl}/ns/common-patterns/addon-security/response.xml +0 -0
  15. data/lib/{riddl → ruby/riddl}/ns/common-patterns/downloadify/1.0/downloadify.xml +0 -0
  16. data/lib/{riddl → ruby/riddl}/ns/common-patterns/notifications-consumer/1.0/consumer.xml +0 -0
  17. data/lib/{riddl → ruby/riddl}/ns/common-patterns/notifications-producer/1.0/producer.xml +0 -0
  18. data/lib/{riddl → ruby/riddl}/ns/common-patterns/properties/1.0/properties.schema.schema +0 -0
  19. data/lib/{riddl → ruby/riddl}/ns/common-patterns/properties/1.0/properties.schema.xsl +0 -0
  20. data/lib/{riddl → ruby/riddl}/ns/common-patterns/properties/1.0/properties.xml +0 -0
  21. data/lib/{riddl → ruby/riddl}/ns/common-patterns/riddl-description/resource-show.xml +1 -0
  22. data/lib/{riddl → ruby/riddl}/ns/common-patterns/riddl-description/show.xml +1 -0
  23. data/lib/{riddl → ruby/riddl}/ns/common/datatypes-1_0.rng +0 -0
  24. data/lib/{riddl → ruby/riddl}/ns/common/relaxng-modular.rng +0 -0
  25. data/lib/{riddl → ruby/riddl}/ns/common/relaxng.rng +0 -0
  26. data/lib/{riddl → ruby/riddl}/ns/declaration/1.0/declaration.rng +0 -0
  27. data/lib/{riddl → ruby/riddl}/ns/description/1.0/description.rng +0 -0
  28. data/lib/{riddl → ruby/riddl}/option.rb +0 -0
  29. data/lib/{riddl → ruby/riddl}/parameter.rb +0 -0
  30. data/lib/{riddl → ruby/riddl}/protocols/http/generator.rb +0 -0
  31. data/lib/{riddl → ruby/riddl}/protocols/http/parser.rb +0 -0
  32. data/lib/{riddl → ruby/riddl}/protocols/websocket.rb +0 -0
  33. data/lib/{riddl → ruby/riddl}/protocols/xmpp/generator.rb +0 -0
  34. data/lib/{riddl → ruby/riddl}/protocols/xmpp/parser.rb +0 -0
  35. data/lib/{riddl → ruby/riddl}/roles.rb +0 -0
  36. data/lib/{riddl → ruby/riddl}/roles/http%3A%2F%2Foauth.net%2F1.0%2Faccess_token.rb +0 -0
  37. data/lib/{riddl → ruby/riddl}/roles/http%3A%2F%2Foauth.net%2F1.0%2Fon_behalf.rb +0 -0
  38. data/lib/{riddl → ruby/riddl}/roles/http%3A%2F%2Foauth.net%2F1.0%2Frequest_token.rb +0 -0
  39. data/lib/{riddl → ruby/riddl}/roles/http%3A%2F%2Foauth.net%2F1.0/base.rb +0 -0
  40. data/lib/{riddl → ruby/riddl}/server.rb +2 -2
  41. data/lib/{riddl → ruby/riddl}/utils/description.rb +6 -2
  42. data/lib/{riddl → ruby/riddl}/utils/downloadify.rb +0 -0
  43. data/lib/{riddl → ruby/riddl}/utils/erbserve.rb +0 -0
  44. data/lib/{riddl → ruby/riddl}/utils/fileserve.rb +0 -0
  45. data/lib/{riddl → ruby/riddl}/utils/notifications_producer.rb +0 -0
  46. data/lib/{riddl → ruby/riddl}/utils/properties.rb +0 -0
  47. data/lib/{riddl → ruby/riddl}/utils/xsloverlay.rb +0 -0
  48. data/lib/{riddl → ruby/riddl}/wrapper.rb +3 -3
  49. data/lib/{riddl → ruby/riddl}/wrapper/declaration.rb +3 -2
  50. data/lib/{riddl → ruby/riddl}/wrapper/declaration/facade.rb +10 -34
  51. data/lib/{riddl → ruby/riddl}/wrapper/declaration/interface.rb +0 -0
  52. data/lib/{riddl → ruby/riddl}/wrapper/declaration/tile.rb +2 -2
  53. data/lib/{riddl → ruby/riddl}/wrapper/description.rb +1 -0
  54. data/lib/{riddl → ruby/riddl}/wrapper/description/access.rb +12 -6
  55. data/lib/{riddl → ruby/riddl}/wrapper/description/message_and_transformation.rb +27 -4
  56. data/lib/{riddl → ruby/riddl}/wrapper/description/resource.rb +91 -41
  57. data/lib/{riddl → ruby/riddl}/wrapper/layerchecker.rb +0 -0
  58. data/lib/{riddl → ruby/riddl}/wrapper/messageparser.rb +0 -0
  59. data/lib/{riddl → ruby/riddl}/wrapper/resourcechecker.rb +0 -0
  60. data/ns/common-patterns/riddl-description/resource-show.xml +1 -0
  61. data/ns/common-patterns/riddl-description/show.xml +1 -0
  62. data/riddl.gemspec +3 -3
  63. data/test/tc_declaration-distributed.rb +1 -1
  64. data/test/tc_declaration-hybrid.rb +1 -1
  65. data/test/tc_declaration-local.rb +1 -1
  66. data/test/tc_helloworld.rb +1 -1
  67. data/test/tc_library.rb +1 -1
  68. data/test/tc_producer.rb +1 -1
  69. data/test/tc_properties.rb +1 -1
  70. data/tools/riddlcheck +1 -1
  71. data/tools/riddlcheck-1_0 +1 -1
  72. data/tools/riddlprocess +1 -1
  73. data/tools/riddlprocess-1_0 +1 -1
  74. metadata +61 -61
data/Rakefile CHANGED
@@ -19,3 +19,7 @@ end
19
19
  task :push => :gem do |r|
20
20
  `gem push pkg/riddl.gem`
21
21
  end
22
+
23
+ task :install => :gem do |r|
24
+ `sudo gem install pkg/riddl.gem`
25
+ end
File without changes
File without changes
File without changes
File without changes
@@ -7,7 +7,9 @@ module Riddl
7
7
  else
8
8
  XML::Smart.string(what)
9
9
  end
10
- w.validate_against(XML::Smart.string(hinfo)) rescue false
10
+ rng = XML::Smart.string("<payload>" + hinfo + "</payload>")
11
+ rng.register_namespace 'r', 'http://relaxng.org/ns/structure/1.0'
12
+ w.validate_against(rng.find("//r:grammar|//r:element").first.to_doc) rescue false
11
13
  end
12
14
  end
13
15
  end
File without changes
@@ -1,6 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <description xmlns="http://riddl.org/ns/description/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
3
  <message name="riddl-description-response">
4
+ <header name="RIDDL_DESCRIPTION" fixed="oh my, a riddl description"/>
4
5
  <parameter name="riddl-description" mimetype="text/xml"/>
5
6
  </message>
6
7
  <message name="riddl-resource-description-request">
@@ -1,6 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <description xmlns="http://riddl.org/ns/description/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
3
  <message name="riddl-description-response">
4
+ <header name="RIDDL_DESCRIPTION" fixed="oh my, a riddl description"/>
4
5
  <parameter name="riddl-description" mimetype="text/xml"/>
5
6
  </message>
6
7
  <message name="riddl-description-request">
File without changes
File without changes
File without changes
@@ -253,9 +253,9 @@ module Riddl
253
253
  @riddl_status = 501 # not implemented?!
254
254
  end
255
255
  else
256
- if !@riddl_message.nil? && @riddl_message.in.name == 'riddl-description-request' && @riddl_method == 'get' && '/' + @riddl_info[:s].join('/') == '/'
256
+ if !@riddl_message.nil? && @accessible_description && @riddl_message.in.name == 'riddl-description-request' && @riddl_method == 'get' && '/' + @riddl_info[:s].join('/') == '/'
257
257
  run Riddl::Utils::Description::RDR, @riddl_description_string
258
- elsif !@riddl_message.nil? && @riddl_message.in.name == 'riddl-resource-description-request' && @riddl_method == 'get'
258
+ elsif !@riddl_message.nil? && @accessible_description && @riddl_message.in.name == 'riddl-resource-description-request' && @riddl_method == 'get'
259
259
  @riddl_path = File.dirname('/' + @riddl_info[:s].join('/')).gsub(/\/+/,'/')
260
260
  on resource File.basename('/' + @riddl_info[:s].join('/')).gsub(/\/+/,'/') do
261
261
  run Riddl::Utils::Description::RDR, @riddl.resource_description(@riddl_matching_path[0])
@@ -6,6 +6,7 @@ module Riddl
6
6
 
7
7
  class RDR < Riddl::Implementation
8
8
  def response
9
+ @headers << Riddl::Header.new("RIDDL_DESCRIPTION", 'oh my, a riddl description')
9
10
  return Riddl::Parameter::Complex.new("riddl-description","text/xml",@a[0])
10
11
  end
11
12
  end
@@ -15,11 +16,14 @@ module Riddl
15
16
  client = Riddl::Client.new(@a[3],@a[4])
16
17
 
17
18
  path = client.resource "/" + @a[5]
18
- @status, result = if @a[0].nil?
19
+ @status, result, headers = if @a[0].nil?
19
20
  path.request @m => [ Riddl::Header.new("RIDDL_DECLARATION_RESOURCE", @a[2]), Riddl::Header.new("RIDDL-DECLARATION-PATH", @a[1]) ] + @h.map{|a,b| Riddl::Header.new(a,b)} + @p
20
21
  else
21
22
  path.request @m => [ Riddl::Header.new("RIDDL_DECLARATION_RESOURCE", @a[2]), Riddl::Header.new("RIDDL-DECLARATION-PATH", @a[1]) ] + @a[0].headers.map{|a,b| Riddl::Header.new(a,b)} + @a[0].response
22
- end
23
+ end
24
+ headers.each do |k,v|
25
+ @headers << Riddl::Header.new(k,v) unless ["CONTENT_TYPE", "CONTENT_DISPOSITION", "RIDDL_TYPE", "CONTENT_ID", "CONTENT_LENGTH", "CONNECTION", "SERVER"].include?(k)
26
+ end
23
27
  result
24
28
  end
25
29
  end
@@ -129,7 +129,7 @@ module Riddl
129
129
  @declaration
130
130
  #}}}
131
131
  end
132
-
132
+
133
133
  def description
134
134
  #{{{
135
135
  if @description.nil? && @is_description
@@ -148,8 +148,8 @@ module Riddl
148
148
  end #}}}
149
149
 
150
150
  def resource_description(path)
151
- req = @description.get_resource(path).description_xml if @is_description
152
- req = @declaration.get_resource(path).description_xml if @is_declaration
151
+ req = @description.get_resource(path).description_xml(@doc.namespaces) if @is_description
152
+ req = @declaration.get_resource(path).description_xml(@doc.namespaces) if @is_declaration
153
153
  req.to_s
154
154
  end
155
155
 
@@ -15,11 +15,11 @@ module Riddl
15
15
  end
16
16
 
17
17
  def description_xml
18
- @facade.description_xml
18
+ @facade.description_xml(@namespaces)
19
19
  end
20
20
 
21
21
  def description
22
- Riddl::Wrapper.new(@facade.description_xml)
22
+ Riddl::Wrapper.new(@facade.description_xml(@namespaces))
23
23
  end
24
24
 
25
25
  def visualize_tiles_and_layers
@@ -59,6 +59,7 @@ module Riddl
59
59
 
60
60
  def initialize(riddl)
61
61
  @facade = Riddl::Wrapper::Declaration::Facade.new
62
+ @namespaces = riddl.namespaces
62
63
  #{{{
63
64
  ### create single tiles
64
65
  @tiles = []
@@ -7,8 +7,14 @@ module Riddl
7
7
  @resource = Riddl::Wrapper::Description::Resource.new("/")
8
8
  end
9
9
 
10
- def description_xml
10
+ def description_xml(namespaces)
11
11
  #{{{
12
+ namespaces = namespaces.delete_if do |k,n|
13
+ k =~ /^xmlns\d+$/ || [Riddl::Wrapper::DESCRIPTION, Riddl::Wrapper::DECLARATION, Riddl::Wrapper::XINCLUDE].include?(n)
14
+ end.map do |k,n|
15
+ "xmlns:#{k}=\"#{n}\""
16
+ end.join(' ')
17
+
12
18
  result = ""
13
19
  messages = {}
14
20
  names = []
@@ -23,7 +29,7 @@ module Riddl
23
29
  t.root.attributes['name'] = name
24
30
  messages_result << t.root.dump + "\n"
25
31
  end
26
- XML::Smart.string("<description #{Riddl::Wrapper::COMMON}>\n\n" + description_result + messages_result.gsub(/^/,' ') + "\n" + result + "\n</description>").to_s
32
+ XML::Smart.string("<description #{Riddl::Wrapper::COMMON} #{namespaces}>\n\n" + description_result + messages_result.gsub(/^/,' ') + "\n" + result + "\n</description>").to_s
27
33
  #}}}
28
34
  end
29
35
  def description_xml_priv(result,messages,level,res=@resource)
@@ -31,38 +37,7 @@ module Riddl
31
37
  s = " " * (level + 1)
32
38
  t = " " * (level + 2)
33
39
  result << s + "<resource#{res.path != '/' && res.path != '{}' ? " relative=\"#{res.path}\"" : ''}#{res.recursive ? " recursive=\"true\"" : ''}>\n"
34
- res.composition.each do |k,v|
35
- v.each do |m|
36
- m = m.result
37
- if %w{get post put delete websocket}.include?(k)
38
- result << t + "<#{k} "
39
- else
40
- result << t + "<request method=\"#{k}\" "
41
- end
42
- case m
43
- when Riddl::Wrapper::Description::RequestInOut
44
- messages[m.in.hash] ||= m.in
45
- result << "in=\"#{messages[m.in.hash].name}\""
46
- unless m.out.nil?
47
- messages[m.out.hash] ||= m.out
48
- result << " out=\"#{messages[m.out.hash].name}\""
49
- end
50
- when Riddl::Wrapper::Description::RequestStarOut
51
- result << "in=\"*\""
52
- unless m.out.nil?
53
- messages[m.out.hash] ||= m.out
54
- result << " out=\"#{messages[m.out.hash].name}\""
55
- end
56
- when Riddl::Wrapper::Description::RequestPass
57
- messages[m.pass.hash] ||= m.pass
58
- result << "pass=\"#{messages[m.pass.hash].name}\""
59
- when Riddl::Wrapper::Description::RequestTransformation
60
- messages[m.trans.hash] ||= m.trans
61
- result << "transformation=\"#{messages[m.trans.hash].name}\""
62
- end
63
- result << "/>\n"
64
- end
65
- end
40
+ result << res.description_xml_string(messages,t)
66
41
  res.resources.each do |k,v|
67
42
  description_xml_priv(result,messages,level+1,v)
68
43
  end
@@ -74,6 +49,7 @@ module Riddl
74
49
 
75
50
  def merge_tiles(res,fac=@resource)
76
51
  #{{{
52
+ fac.custom = fac.custom + res.custom
77
53
  res.composition.each do |method,s|
78
54
  fac.composition[method] ||= []
79
55
  fac.composition[method] += s
@@ -47,6 +47,7 @@ module Riddl
47
47
  #{{{
48
48
  res = add_path(path,res,rec)
49
49
  res.add_access_methods(des,desres,index,interface)
50
+ res.add_custom(desres)
50
51
  block.each do |bl|
51
52
  bpath = bl.to_s.gsub(/\/+/,'/').gsub(/\/$/,'')
52
53
  bpath = (bpath == "" ? "/" : bpath)
@@ -73,9 +74,8 @@ module Riddl
73
74
  #}}}
74
75
  end
75
76
 
76
- def add_path(path,res,rec=nil)
77
+ def add_path(path,pres,rec=nil)
77
78
  #{{{
78
- pres = res
79
79
  path.split('/').each do |pa|
80
80
  next if pa == ""
81
81
  unless pres.resources.has_key?(pa)
@@ -44,6 +44,7 @@ module Riddl
44
44
  res = res.resources[path]
45
45
  end
46
46
  res.add_access_methods(des,desres,0,nil)
47
+ res.add_custom(desres)
47
48
  desres.find("des:resource").each do |desres|
48
49
  cpath = desres.attributes['relative'] || "{}"
49
50
  rec = desres.attributes['recursive']
@@ -10,10 +10,12 @@ module Riddl
10
10
  @used || false
11
11
  end
12
12
  attr_reader :interface
13
+ attr_reader :custom
13
14
  end# }}}
14
15
 
15
16
  class RequestInOut < AccessBase# {{{
16
- def initialize(des,min,mout,interface)
17
+ def initialize(des,min,mout,interface,custom=[])
18
+ @custom = custom
17
19
  @interface = interface
18
20
  if des.nil?
19
21
  @in = min
@@ -34,7 +36,8 @@ module Riddl
34
36
  end# }}}
35
37
 
36
38
  class RequestTransformation < AccessBase# {{{
37
- def initialize(des,mtrans,interface)
39
+ def initialize(des,mtrans,interface,custom=[])
40
+ @custom = custom
38
41
  @interface = interface
39
42
  if des.nil?
40
43
  @trans = mtrans
@@ -65,7 +68,8 @@ module Riddl
65
68
  end# }}}
66
69
 
67
70
  class RequestStarOut < AccessBase# {{{
68
- def initialize(des,mout,interface)
71
+ def initialize(des,mout,interface,custom=[])
72
+ @custom = custom
69
73
  @interface = interface
70
74
  if des.nil?
71
75
  @out = mout
@@ -84,7 +88,8 @@ module Riddl
84
88
  end# }}}
85
89
 
86
90
  class RequestPass < AccessBase# {{{
87
- def initialize(interface)
91
+ def initialize(interface,custom=[])
92
+ @custom = custom
88
93
  @interface = interface
89
94
  end
90
95
  def visualize; ""; end
@@ -94,10 +99,11 @@ module Riddl
94
99
  end# }}}
95
100
 
96
101
  class WebSocket < AccessBase# {{{
97
- def visualize; ""; end
98
- def initialize(interface)
102
+ def initialize(interface,custom=[])
103
+ @custom = custom
99
104
  @interface = interface
100
105
  end
106
+ def visualize; ""; end
101
107
  def hash
102
108
  0
103
109
  end
@@ -13,18 +13,41 @@ module Riddl
13
13
  @content = layer.find("des:#{type}[@name='#{name}']").first.to_doc
14
14
  @content.root.find("@name").delete_all!
15
15
  @content.register_namespace 'des', Riddl::Wrapper::DESCRIPTION
16
- @content.register_namespace 'dec', Riddl::Wrapper::DECLARATION
17
16
  end
18
17
  update_hash!
19
18
  end
20
19
  def update_hash!
21
20
  # TODO too simple
22
- @hash = @content.to_s.hash
21
+ hb = @content.root.to_doc
22
+ hb.register_namespace 'des', Riddl::Wrapper::DESCRIPTION
23
+ hb.unformated = true
24
+ hb.find("//comment()").delete_all!
25
+ hb.find("//des:parameter/*").delete_all!
26
+ hb.find("//text()").delete_all!
27
+ hb.find("//des:header/*").delete_all!
28
+ hb.find("//des:parameter/@handler").delete_all!
29
+ hb.find("//des:parameter/@mimetype").each { |e| e.value = '' }
30
+ hb.root.namespaces.delete_all!
31
+ @hash_base = hb
32
+ @hash = hb.serialize.hash
23
33
  end
24
34
  def traverse?(other)
25
- other.name.nil? ? false : (self.hash == other.hash)
35
+ if other.name.nil?
36
+ false
37
+ else
38
+ paths = self.hash_base.find("//des:parameter").map{ |e| e.path + "/@name" }
39
+ hb2 = XML::Smart::string(other.hash_base.serialize)
40
+ hb2.register_namespace 'des', Riddl::Wrapper::DESCRIPTION
41
+ hb2.unformated = true
42
+
43
+ paths.each do |p|
44
+ (hb2.find(p).first.value = '*') rescue nil
45
+ end
46
+
47
+ self.hash_base.serialize.hash == hb2.serialize.hash
48
+ end
26
49
  end
27
- attr_reader :name, :content, :hash
50
+ attr_reader :name, :content, :hash, :hash_base
28
51
  #}}}
29
52
  end
30
53
 
@@ -11,6 +11,7 @@ module Riddl
11
11
  @access_methods = {}
12
12
  @composition = {}
13
13
  @recursive = recursive
14
+ @custom = []
14
15
  #}}}
15
16
  end
16
17
 
@@ -18,36 +19,42 @@ module Riddl
18
19
  #{{{
19
20
  desres.find("des:*[not(name()='resource') and not(name()='websocket') and @in and not(@in='*')]").each do |m|
20
21
  method = m.attributes['method'] || m.qname.name
21
- add_request_in_out(index,interface,des,method,m.attributes['in'],m.attributes['out'])
22
+ add_request_in_out(index,interface,des,method,m.attributes['in'],m.attributes['out'],m.find('*|text()'))
22
23
  end
23
24
  desres.find("des:*[not(name()='resource') and not(name()='websocket') and @pass and not(@pass='*')]").each do |m|
24
25
  method = m.attributes['method'] || m.qname.name
25
- add_request_in_out(index,interface,des,method,m.attributes['pass'],m.attributes['pass'])
26
+ add_request_in_out(index,interface,des,method,m.attributes['pass'],m.attributes['pass'],m.find('*|text()'))
26
27
  end
27
28
  desres.find("des:*[not(name()='resource') and not(name()='websocket') and @transformation]").each do |m|
28
29
  method = m.attributes['method'] || m.qname.name
29
- add_request_transform(index,interface,des,method,m.attributes['transformation'])
30
+ add_request_transform(index,interface,des,method,m.attributes['transformation'],m.find('*|text()'))
30
31
  end
31
32
  desres.find("des:*[not(name()='resource') and not(name()='websocket') and @in and @in='*']").each do |m|
32
33
  method = m.attributes['method'] || m.qname.name
33
- add_request_star_out(index,interface,des,method,m.attributes['out'])
34
+ add_request_star_out(index,interface,des,method,m.attributes['out'],m.find('*|text()'))
34
35
  end
35
36
  desres.find("des:*[not(name()='resource') and not(name()='websocket') and not(@in)]").each do |m|
36
37
  method = m.attributes['method'] || m.qname.name
37
- add_request_star_out(index,interface,des,method,m.attributes['out'])
38
+ add_request_star_out(index,interface,des,method,m.attributes['out'],m.find('*|text()'))
38
39
  end
39
40
  desres.find("des:*[not(name()='resource') and not(name()='websocket') and @pass and @pass='*']").each do |m|
40
41
  method = m.attributes['method'] || m.qname.name
41
- add_request_pass(index,interface,method)
42
+ add_request_pass(index,interface,method,m.find('*|text()'))
42
43
  end
43
44
  desres.find("des:*[not(name()='resource') and name()='websocket']").each do |m|
44
- add_websocket(index,interface)
45
+ add_websocket(index,interface,m.find('*|text()'))
45
46
  end
46
47
  @role = desres.find("string(@role)")
47
48
  @role = nil if @role.strip == ''
48
49
  #}}}
49
50
  end
50
51
 
52
+ def add_custom(desres)
53
+ #{{{
54
+ @custom = desres.find("*[not(self::des:*)]").to_a
55
+ #}}}
56
+ end
57
+
51
58
  # TODO add websockets
52
59
 
53
60
  def remove_access_methods(des,filter)
@@ -72,6 +79,7 @@ module Riddl
72
79
  reqs.delete_if do |req|
73
80
  if req.class == freq[0]
74
81
  if req.class == RequestInOut
82
+ # TODO These hash comparisons are maybe too trivial, as we want to catch name="*" parameters
75
83
  if freq[1] && freq[1].hash == req.in.hash && freq[2] && req.out && freq[2].hash == req.out.hash
76
84
  true
77
85
  elsif freq[1] && freq[1].hash == req.in.hash && !freq[2]
@@ -224,33 +232,73 @@ module Riddl
224
232
  end
225
233
  private :add_to_path_and_split
226
234
 
227
- def description_xml
228
- collect = ''
229
- messages = {}
230
- messages_result = ''
231
-
235
+ def description_xml_string(messages,t)
236
+ #{{{
237
+ result = ''
238
+ @custom.each do |c|
239
+ result << c.dump
240
+ end
232
241
  if @composition.any?
233
242
  @composition.each do |k,v|
234
- v.each do |e|
235
- collect << if e.result.class==Riddl::Wrapper::Description::RequestInOut
236
- messages[e.result.in.hash] = e.result.in
237
- messages[e.result.out.hash] = e.result.out if e.result.out
238
- " <#{k} in=\"#{e.result.in.name}\"#{e.result.out.nil? ? '' : " out=\"#{e.result.out.name}\""}/>\n"
239
- elsif e.result.class==Riddl::Wrapper::Description::RequestTransformation
240
- ' '
241
- elsif e.result.class==Riddl::Wrapper::Description::RequestStarOut
242
- messages[e.result.out.hash] = e.result.out if e.result.out
243
- " <#{k} in=\"*\"#{e.result.out.nil? ? '' : " out=\"#{e.result.out.name}\""}/>\n"
244
- elsif e.result.class==Riddl::Wrapper::Description::RequestPass
245
- ' '
246
- elsif e.result.class==Riddl::Wrapper::Description::WebSocket
247
- " <websocket/>\n"
243
+ v.each do |m|
244
+ m = m.result
245
+ if %w{get post put delete websocket}.include?(k)
246
+ result << t + "<#{k} "
248
247
  else
249
- ''
248
+ result << t + "<request method=\"#{k}\" "
249
+ end
250
+ case m
251
+ when Riddl::Wrapper::Description::RequestInOut
252
+ messages[m.in.hash] ||= m.in
253
+ result << "in=\"#{messages[m.in.hash].name}\""
254
+ unless m.out.nil?
255
+ messages[m.out.hash] ||= m.out
256
+ result << " out=\"#{messages[m.out.hash].name}\""
257
+ end
258
+ when Riddl::Wrapper::Description::RequestStarOut
259
+ result << "in=\"*\""
260
+ unless m.out.nil?
261
+ messages[m.out.hash] ||= m.out
262
+ result << " out=\"#{messages[m.out.hash].name}\""
263
+ end
264
+ when Riddl::Wrapper::Description::RequestPass
265
+ messages[m.pass.hash] ||= m.pass
266
+ result << "pass=\"#{messages[m.pass.hash].name}\""
267
+ when Riddl::Wrapper::Description::RequestTransformation
268
+ messages[m.trans.hash] ||= m.trans
269
+ result << "transformation=\"#{messages[m.trans.hash].name}\""
250
270
  end
251
- end
271
+ if m.custom.length > 0
272
+ result << ">\n"
273
+ m.custom.each do |e|
274
+ result << e.dump + "\n"
275
+ end
276
+ if %w{get post put delete websocket}.include?(k)
277
+ result << t + "</#{k}>"
278
+ else
279
+ result << t + "</request>\n"
280
+ end
281
+ else
282
+ result << "/>\n"
283
+ end
284
+ end
252
285
  end
253
- end
286
+ end
287
+ result
288
+ #}}}
289
+ end
290
+
291
+ def description_xml(namespaces)
292
+ #{{{
293
+ namespaces = namespaces.delete_if do |k,n|
294
+ k =~ /^xmlns\d+$/ || [Riddl::Wrapper::DESCRIPTION, Riddl::Wrapper::DECLARATION, Riddl::Wrapper::XINCLUDE].include?(n)
295
+ end.map do |k,n|
296
+ "xmlns:#{k}=\"#{n}\""
297
+ end.join(' ')
298
+
299
+ messages = {}
300
+ messages_result = ''
301
+ collect = description_xml_string(messages," " * 4)
254
302
 
255
303
  names = []
256
304
  messages.each do |hash,mess|
@@ -261,48 +309,50 @@ module Riddl
261
309
  t.root.attributes['name'] = name
262
310
  messages_result << t.root.dump + "\n"
263
311
  end
264
- XML::Smart.string("<description #{Riddl::Wrapper::COMMON}>\n\n" + messages_result.gsub(/^/,' ') + "\n <resource>\n" + collect + " </resource>\n</description>").to_s
312
+ XML::Smart.string("<description #{Riddl::Wrapper::COMMON} #{namespaces}>\n\n" + messages_result.gsub(/^/,' ') + "\n <resource>\n" + collect + " </resource>\n</description>").to_s
313
+ #}}}
265
314
  end
266
315
 
267
- # add requests helper methods
316
+ # private add requests helper methods
268
317
  #{{{
269
- def add_request_in_out(index,interface,des,method,min,mout)
318
+ def add_request_in_out(index,interface,des,method,min,mout,custom)
270
319
  @access_methods[method] ||= []
271
320
  @access_methods[method][index] ||= []
272
- @access_methods[method][index] << RequestInOut.new(des,min,mout,interface)
321
+ @access_methods[method][index] << RequestInOut.new(des,min,mout,interface,custom)
273
322
  end
274
323
  private :add_request_in_out
275
324
 
276
- def add_request_transform(index,interface,des,method,mtrans)
325
+ def add_request_transform(index,interface,des,method,mtrans,custom)
277
326
  @access_methods[method] ||= []
278
327
  @access_methods[method][index] ||= []
279
- @access_methods[method][index] << RequestTransformation.new(des,mtrans,interface)
328
+ @access_methods[method][index] << RequestTransformation.new(des,mtrans,interface,custom)
280
329
  end
281
330
  private :add_request_transform
282
331
 
283
- def add_request_star_out(index,interface,des,method,mout)
332
+ def add_request_star_out(index,interface,des,method,mout,custom)
284
333
  @access_methods[method] ||= []
285
334
  @access_methods[method][index] ||= []
286
- @access_methods[method][index] << RequestStarOut.new(des,mout,interface)
335
+ @access_methods[method][index] << RequestStarOut.new(des,mout,interface,custom)
287
336
  end
288
337
  private :add_request_star_out
289
338
 
290
- def add_request_pass(index,interface,method)
339
+ def add_request_pass(index,interface,method,custom)
291
340
  @access_methods[method] ||= []
292
341
  @access_methods[method][index] ||= []
293
- @access_methods[method][index] << RequestPass.new(interface)
342
+ @access_methods[method][index] << RequestPass.new(interface,custom)
294
343
  end
295
344
  private :add_request_pass
296
345
 
297
- def add_websocket(index,interface)
346
+ def add_websocket(index,interface,custom)
298
347
  @access_methods['websocket'] ||= []
299
348
  @access_methods['websocket'][index] ||= []
300
- @access_methods['websocket'][index] << WebSocket.new(interface)
349
+ @access_methods['websocket'][index] << WebSocket.new(interface,custom)
301
350
  end
302
351
  private :add_request_pass
303
352
  #}}}
304
353
 
305
354
  attr_reader :resources,:path,:access_methods,:composition,:recursive,:role
355
+ attr_accessor :custom
306
356
  end
307
357
 
308
358
  Composition = Struct.new(:route,:result)
@@ -1,6 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <description xmlns="http://riddl.org/ns/description/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
3
  <message name="riddl-description-response">
4
+ <header name="RIDDL_DESCRIPTION" fixed="oh my, a riddl description"/>
4
5
  <parameter name="riddl-description" mimetype="text/xml"/>
5
6
  </message>
6
7
  <message name="riddl-resource-description-request">
@@ -1,6 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <description xmlns="http://riddl.org/ns/description/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
3
  <message name="riddl-description-response">
4
+ <header name="RIDDL_DESCRIPTION" fixed="oh my, a riddl description"/>
4
5
  <parameter name="riddl-description" mimetype="text/xml"/>
5
6
  </message>
6
7
  <message name="riddl-description-request">
@@ -1,14 +1,14 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "riddl"
3
- s.version = "0.99.125"
3
+ s.version = "0.99.129"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3"
6
6
  s.summary = "restful interface description and declaration language: tools and client/server libs"
7
7
 
8
8
  s.description = "rest service interface definition, mixing, and evolution"
9
9
 
10
- s.files = Dir['{lib/riddl/ns/**/*,tools/**/*,ns/**/*,contrib/**/*,lib/riddl/**/*,example/**/*}'] + %w(COPYING Rakefile riddl.gemspec README.rdoc TODO AUTHORS INSTALL)
11
- s.require_path = 'lib'
10
+ s.files = Dir['{lib/ruby/riddl/ns/**/*,tools/**/*,ns/**/*,contrib/**/*,lib/ruby/riddl/**/*,example/**/*}'] + %w(COPYING Rakefile riddl.gemspec README.rdoc TODO AUTHORS INSTALL)
11
+ s.require_path = 'lib/ruby'
12
12
  s.extra_rdoc_files = ['README.rdoc']
13
13
  s.bindir = 'tools'
14
14
  s.executables = ['riddlcheck','riddlprocess']
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
- require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/client')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/ruby/riddl/client')
3
3
  require 'xml/smart'
4
4
  require 'pp'
5
5
 
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
- require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/client')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/ruby/riddl/client')
3
3
  require 'xml/smart'
4
4
  require 'pp'
5
5
 
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
- require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/client')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/ruby/riddl/client')
3
3
  require 'xml/smart'
4
4
  require 'pp'
5
5
 
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
- require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/wrapper')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/ruby/riddl/wrapper')
3
3
 
4
4
  class TestHelloWorld < MiniTest::Unit::TestCase
5
5
 
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
- require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/client')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/ruby/riddl/client')
3
3
  require 'xml/smart'
4
4
  require 'pp'
5
5
 
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
- require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/client')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/ruby/riddl/client')
3
3
  require 'xml/smart'
4
4
 
5
5
  class TestProd < MiniTest::Unit::TestCase
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/smartrunner.rb')
2
- require File.expand_path(File.dirname(__FILE__) + '/../lib/riddl/client')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/ruby/riddl/client')
3
3
  require 'xml/smart'
4
4
 
5
5
  class TestProp < MiniTest::Unit::TestCase
@@ -4,7 +4,7 @@ while ::File::symlink?(curpath)
4
4
  curpath = ::File::dirname(curpath) + '/' + ::File::readlink(curpath)
5
5
  end
6
6
  require 'rubygems'
7
- require ::File::dirname(curpath) + "/../lib/riddl/wrapper"
7
+ require ::File::dirname(curpath) + "/../lib/ruby/riddl/wrapper"
8
8
  require 'optparse'
9
9
 
10
10
  ARGV.options { |opt|
@@ -4,7 +4,7 @@ while ::File::symlink?(curpath)
4
4
  curpath = ::File::dirname(curpath) + '/' + ::File::readlink(curpath)
5
5
  end
6
6
  require 'rubygems'
7
- require ::File::dirname(curpath) + "/../lib/riddl/wrapper"
7
+ require ::File::dirname(curpath) + "/../lib/ruby/riddl/wrapper"
8
8
  require 'optparse'
9
9
 
10
10
  ARGV.options { |opt|
@@ -4,7 +4,7 @@ while ::File::symlink?(curpath)
4
4
  curpath = ::File::dirname(curpath) + '/' + ::File::readlink(curpath)
5
5
  end
6
6
  require 'rubygems'
7
- require ::File::dirname(curpath) + "/../lib/riddl/wrapper"
7
+ require ::File::dirname(curpath) + "/../lib/ruby/riddl/wrapper"
8
8
  require 'optparse'
9
9
  require 'pp'
10
10
 
@@ -4,7 +4,7 @@ while ::File::symlink?(curpath)
4
4
  curpath = ::File::dirname(curpath) + '/' + ::File::readlink(curpath)
5
5
  end
6
6
  require 'rubygems'
7
- require ::File::dirname(curpath) + "/../lib/riddl/wrapper"
7
+ require ::File::dirname(curpath) + "/../lib/ruby/riddl/wrapper"
8
8
  require 'optparse'
9
9
  require 'pp'
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riddl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.99.125
4
+ version: 0.99.129
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: tools
11
11
  cert_chain: []
12
- date: 2013-09-14 00:00:00.000000000 Z
12
+ date: 2013-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xml-smart
@@ -164,21 +164,21 @@ extensions: []
164
164
  extra_rdoc_files:
165
165
  - README.rdoc
166
166
  files:
167
- - lib/riddl/ns/declaration/1.0/declaration.rng
168
- - lib/riddl/ns/common/relaxng-modular.rng
169
- - lib/riddl/ns/common/relaxng.rng
170
- - lib/riddl/ns/common/datatypes-1_0.rng
171
- - lib/riddl/ns/description/1.0/description.rng
172
- - lib/riddl/ns/common-patterns/properties/1.0/properties.xml
173
- - lib/riddl/ns/common-patterns/properties/1.0/properties.schema.xsl
174
- - lib/riddl/ns/common-patterns/properties/1.0/properties.schema.schema
175
- - lib/riddl/ns/common-patterns/notifications-producer/1.0/producer.xml
176
- - lib/riddl/ns/common-patterns/addon-security/request.xml
177
- - lib/riddl/ns/common-patterns/addon-security/response.xml
178
- - lib/riddl/ns/common-patterns/downloadify/1.0/downloadify.xml
179
- - lib/riddl/ns/common-patterns/notifications-consumer/1.0/consumer.xml
180
- - lib/riddl/ns/common-patterns/riddl-description/resource-show.xml
181
- - lib/riddl/ns/common-patterns/riddl-description/show.xml
167
+ - lib/ruby/riddl/ns/declaration/1.0/declaration.rng
168
+ - lib/ruby/riddl/ns/common/relaxng-modular.rng
169
+ - lib/ruby/riddl/ns/common/relaxng.rng
170
+ - lib/ruby/riddl/ns/common/datatypes-1_0.rng
171
+ - lib/ruby/riddl/ns/description/1.0/description.rng
172
+ - lib/ruby/riddl/ns/common-patterns/properties/1.0/properties.xml
173
+ - lib/ruby/riddl/ns/common-patterns/properties/1.0/properties.schema.xsl
174
+ - lib/ruby/riddl/ns/common-patterns/properties/1.0/properties.schema.schema
175
+ - lib/ruby/riddl/ns/common-patterns/notifications-producer/1.0/producer.xml
176
+ - lib/ruby/riddl/ns/common-patterns/addon-security/request.xml
177
+ - lib/ruby/riddl/ns/common-patterns/addon-security/response.xml
178
+ - lib/ruby/riddl/ns/common-patterns/downloadify/1.0/downloadify.xml
179
+ - lib/ruby/riddl/ns/common-patterns/notifications-consumer/1.0/consumer.xml
180
+ - lib/ruby/riddl/ns/common-patterns/riddl-description/resource-show.xml
181
+ - lib/ruby/riddl/ns/common-patterns/riddl-description/show.xml
182
182
  - tools/riddlprocess-1_0
183
183
  - tools/flash-policy-server.rb
184
184
  - tools/riddlprocess
@@ -202,49 +202,49 @@ files:
202
202
  - contrib/riddl.svg
203
203
  - contrib/riddl.jpg
204
204
  - contrib/riddl.png
205
- - lib/riddl/parameter.rb
206
- - lib/riddl/handlers/plain-type.rb
207
- - lib/riddl/handlers/oauth.rb
208
- - lib/riddl/handlers/relaxng.rb
209
- - lib/riddl/handlers/xmlschema.rb
210
- - lib/riddl/client.rb
211
- - lib/riddl/option.rb
212
- - lib/riddl/roles/http%3A%2F%2Foauth.net%2F1.0/base.rb
213
- - lib/riddl/roles/http%3A%2F%2Foauth.net%2F1.0%2Fon_behalf.rb
214
- - lib/riddl/roles/http%3A%2F%2Foauth.net%2F1.0%2Faccess_token.rb
215
- - lib/riddl/roles/http%3A%2F%2Foauth.net%2F1.0%2Frequest_token.rb
216
- - lib/riddl/roles.rb
217
- - lib/riddl/handlers.rb
218
- - lib/riddl/server.rb
219
- - lib/riddl/constants.rb
220
- - lib/riddl/wrapper.rb
221
- - lib/riddl/implementation.rb
222
- - lib/riddl/header.rb
223
- - lib/riddl/error.rb
224
- - lib/riddl/wrapper/declaration/tile.rb
225
- - lib/riddl/wrapper/declaration/facade.rb
226
- - lib/riddl/wrapper/declaration/interface.rb
227
- - lib/riddl/wrapper/layerchecker.rb
228
- - lib/riddl/wrapper/declaration.rb
229
- - lib/riddl/wrapper/description.rb
230
- - lib/riddl/wrapper/resourcechecker.rb
231
- - lib/riddl/wrapper/messageparser.rb
232
- - lib/riddl/wrapper/description/message_and_transformation.rb
233
- - lib/riddl/wrapper/description/access.rb
234
- - lib/riddl/wrapper/description/resource.rb
235
- - lib/riddl/utils/properties.rb
236
- - lib/riddl/utils/xsloverlay.rb
237
- - lib/riddl/utils/downloadify.rb
238
- - lib/riddl/utils/notifications_producer.rb
239
- - lib/riddl/utils/erbserve.rb
240
- - lib/riddl/utils/description.rb
241
- - lib/riddl/utils/fileserve.rb
242
- - lib/riddl/commonlogger.rb
243
- - lib/riddl/protocols/http/generator.rb
244
- - lib/riddl/protocols/http/parser.rb
245
- - lib/riddl/protocols/xmpp/generator.rb
246
- - lib/riddl/protocols/xmpp/parser.rb
247
- - lib/riddl/protocols/websocket.rb
205
+ - lib/ruby/riddl/parameter.rb
206
+ - lib/ruby/riddl/handlers/plain-type.rb
207
+ - lib/ruby/riddl/handlers/oauth.rb
208
+ - lib/ruby/riddl/handlers/relaxng.rb
209
+ - lib/ruby/riddl/handlers/xmlschema.rb
210
+ - lib/ruby/riddl/client.rb
211
+ - lib/ruby/riddl/option.rb
212
+ - lib/ruby/riddl/roles/http%3A%2F%2Foauth.net%2F1.0/base.rb
213
+ - lib/ruby/riddl/roles/http%3A%2F%2Foauth.net%2F1.0%2Fon_behalf.rb
214
+ - lib/ruby/riddl/roles/http%3A%2F%2Foauth.net%2F1.0%2Faccess_token.rb
215
+ - lib/ruby/riddl/roles/http%3A%2F%2Foauth.net%2F1.0%2Frequest_token.rb
216
+ - lib/ruby/riddl/roles.rb
217
+ - lib/ruby/riddl/handlers.rb
218
+ - lib/ruby/riddl/server.rb
219
+ - lib/ruby/riddl/constants.rb
220
+ - lib/ruby/riddl/wrapper.rb
221
+ - lib/ruby/riddl/implementation.rb
222
+ - lib/ruby/riddl/header.rb
223
+ - lib/ruby/riddl/error.rb
224
+ - lib/ruby/riddl/wrapper/declaration/tile.rb
225
+ - lib/ruby/riddl/wrapper/declaration/facade.rb
226
+ - lib/ruby/riddl/wrapper/declaration/interface.rb
227
+ - lib/ruby/riddl/wrapper/layerchecker.rb
228
+ - lib/ruby/riddl/wrapper/declaration.rb
229
+ - lib/ruby/riddl/wrapper/description.rb
230
+ - lib/ruby/riddl/wrapper/resourcechecker.rb
231
+ - lib/ruby/riddl/wrapper/messageparser.rb
232
+ - lib/ruby/riddl/wrapper/description/message_and_transformation.rb
233
+ - lib/ruby/riddl/wrapper/description/access.rb
234
+ - lib/ruby/riddl/wrapper/description/resource.rb
235
+ - lib/ruby/riddl/utils/properties.rb
236
+ - lib/ruby/riddl/utils/xsloverlay.rb
237
+ - lib/ruby/riddl/utils/downloadify.rb
238
+ - lib/ruby/riddl/utils/notifications_producer.rb
239
+ - lib/ruby/riddl/utils/erbserve.rb
240
+ - lib/ruby/riddl/utils/description.rb
241
+ - lib/ruby/riddl/utils/fileserve.rb
242
+ - lib/ruby/riddl/commonlogger.rb
243
+ - lib/ruby/riddl/protocols/http/generator.rb
244
+ - lib/ruby/riddl/protocols/http/parser.rb
245
+ - lib/ruby/riddl/protocols/xmpp/generator.rb
246
+ - lib/ruby/riddl/protocols/xmpp/parser.rb
247
+ - lib/ruby/riddl/protocols/websocket.rb
248
248
  - COPYING
249
249
  - Rakefile
250
250
  - riddl.gemspec
@@ -266,7 +266,7 @@ licenses:
266
266
  post_install_message:
267
267
  rdoc_options: []
268
268
  require_paths:
269
- - lib
269
+ - lib/ruby
270
270
  required_ruby_version: !ruby/object:Gem::Requirement
271
271
  none: false
272
272
  requirements: