riddl 0.127 → 0.129
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/declaration-server-distributed/main.rb +1 -1
- data/examples/declaration-server-hybrid/declaration.rb +1 -1
- data/examples/flickr/Flickr/authenticate.rb +3 -3
- data/examples/flickr/Flickr/find.rb +6 -6
- data/examples/flickr/Flickr/flickr.rb +6 -6
- data/examples/flickr/Flickr/public.rb +6 -6
- data/examples/flickr/Helpers/flickr.rb +5 -5
- data/examples/twitter/client.rb +1 -1
- data/examples/twitter/timeline.rb +1 -1
- data/examples/zotero/client.rb +1 -1
- data/lib/ruby/riddl/protocols/http/generator.rb +2 -1
- data/lib/ruby/riddl/utils/erbserve.rb +3 -3
- data/lib/ruby/riddl/utils/fileserve.rb +1 -1
- data/lib/ruby/riddl/utils/notifications_producer.rb +5 -5
- data/lib/ruby/riddl/utils/oauth2-helper.rb +6 -6
- data/lib/ruby/riddl/utils/properties.rb +5 -5
- data/lib/ruby/riddl/utils/xmlserve.rb +7 -7
- data/lib/ruby/riddl/wrapper.rb +2 -2
- data/riddl.gemspec +7 -7
- data/tools/riddlcheck +4 -4
- data/tools/riddlprocess +5 -5
- metadata +9 -10
- data/lib/ruby/riddl/protocols/generator.rb +0 -118
- data/lib/ruby/riddl/protocols/parser.rb +0 -205
- /data/{README.rdoc → README.md} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6316fd15d163902d1742764b42bc4886aaeb270a4957f540c2f617b099c5b15a
|
4
|
+
data.tar.gz: 35713bac9ab94975e7aa396966443d54c11b45085ad640280faa9fd6e63225e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 268485523d1c71d829e7f9576244d438fd914f89dba9e1c039adf90155e2d0eb2f5bfb784344780f8fd97bc5627579f6ae7174f74629c5632396c438c3bb3137
|
7
|
+
data.tar.gz: f80e80903d09ae3c4b756ab3dd75897fb3d4586e02e4c04e0c4ffc852b5b694cd7fc79b76d82d03a4e79a512331d5140ab45a2f5d8394f0482ca0edc306bc882
|
@@ -12,9 +12,9 @@ key = File.read('flickr.key').strip
|
|
12
12
|
secret = File.read('flickr.secret').strip
|
13
13
|
|
14
14
|
### get frob
|
15
|
-
if File.
|
15
|
+
if File.exist?('flickr.frob')
|
16
16
|
frob = File.read('flickr.frob').strip
|
17
|
-
else
|
17
|
+
else
|
18
18
|
method = 'flickr.auth.getFrob'
|
19
19
|
sig = Digest::MD5.hexdigest("#{secret}api_key#{key}method#{method}")
|
20
20
|
status, res = rest.get [
|
@@ -25,7 +25,7 @@ else
|
|
25
25
|
raise "no valid frob" unless status == 200
|
26
26
|
frob = XML::Smart::string(res[0].value.read).find('string(/rsp/frob)')
|
27
27
|
File.open('flickr.frob','w'){|f|f.write(frob)}
|
28
|
-
end
|
28
|
+
end
|
29
29
|
|
30
30
|
### prepare auth link
|
31
31
|
method = 'flickr.auth.getFrob'
|
@@ -4,7 +4,7 @@ require '../../../lib/ruby/riddl/client'
|
|
4
4
|
require 'pp'
|
5
5
|
|
6
6
|
# no ready for use
|
7
|
-
unless File.
|
7
|
+
unless File.exist?('.flickr.frob')
|
8
8
|
puts "Check the README file and use authenticate.rb."
|
9
9
|
exit
|
10
10
|
end
|
@@ -24,11 +24,11 @@ key = File.read('.flickr.key').strip
|
|
24
24
|
secret = File.read('.flickr.secret').strip
|
25
25
|
frob = File.read('.flickr.frob').strip
|
26
26
|
|
27
|
-
### get
|
28
|
-
if File.
|
27
|
+
### get
|
28
|
+
if File.exist?('.flickr.token')
|
29
29
|
token = File.read('.flickr.token').strip
|
30
|
-
else
|
31
|
-
puts "hmm, there is no token...."
|
30
|
+
else
|
31
|
+
puts "hmm, there is no token...."
|
32
32
|
method = 'flickr.auth.getToken'
|
33
33
|
sig = Digest::MD5.hexdigest("#{secret}api_key#{key}frob#{frob}method#{method}")
|
34
34
|
status, res = rest.request :get => [
|
@@ -66,4 +66,4 @@ status, res, headers = rest.get [
|
|
66
66
|
]
|
67
67
|
raise "token no longer valid, delete .flickr.token, .flickr.frob then retry authenticate.rb, flickr.rb" unless status == 200
|
68
68
|
|
69
|
-
puts "STATUS: #{status} RES:" + res[0].value.read + " HEADERS: #{headers}"
|
69
|
+
puts "STATUS: #{status} RES:" + res[0].value.read + " HEADERS: #{headers}"
|
@@ -4,7 +4,7 @@ require '../../../lib/ruby/riddl/client'
|
|
4
4
|
require 'pp'
|
5
5
|
|
6
6
|
# no ready for use
|
7
|
-
unless File.
|
7
|
+
unless File.exist?('.flickr.frob')
|
8
8
|
puts "Check the README file and use authenticate.rb."
|
9
9
|
exit
|
10
10
|
end
|
@@ -29,11 +29,11 @@ key = File.read('.flickr.key').strip
|
|
29
29
|
secret = File.read('.flickr.secret').strip
|
30
30
|
frob = File.read('.flickr.frob').strip
|
31
31
|
|
32
|
-
### get
|
33
|
-
if File.
|
32
|
+
### get
|
33
|
+
if File.exist?('.flickr.token')
|
34
34
|
token = File.read('.flickr.token').strip
|
35
|
-
else
|
36
|
-
puts "hmm, there is no token...."
|
35
|
+
else
|
36
|
+
puts "hmm, there is no token...."
|
37
37
|
method = 'flickr.auth.getToken'
|
38
38
|
sig = Digest::MD5.hexdigest("#{secret}api_key#{key}frob#{frob}method#{method}")
|
39
39
|
status, res = rest.get [
|
@@ -76,7 +76,7 @@ status, res = upload.post [
|
|
76
76
|
Riddl::Parameter::Simple.new("tags", tags),
|
77
77
|
Riddl::Parameter::Simple.new("is_public", is_public),
|
78
78
|
Riddl::Parameter::Simple.new("api_sig", sig)
|
79
|
-
]
|
79
|
+
]
|
80
80
|
|
81
81
|
rsp = XML::Smart::string(res[0].value.read)
|
82
82
|
stat = rsp.find('string(/rsp/@stat)')
|
@@ -4,7 +4,7 @@ require '../../../lib/ruby/riddl/client'
|
|
4
4
|
require 'pp'
|
5
5
|
|
6
6
|
# no ready for use
|
7
|
-
unless File.
|
7
|
+
unless File.exist?('.flickr.frob')
|
8
8
|
puts "Check the README file and use authenticate.rb."
|
9
9
|
exit
|
10
10
|
end
|
@@ -29,11 +29,11 @@ key = File.read('.flickr.key').strip
|
|
29
29
|
secret = File.read('.flickr.secret').strip
|
30
30
|
frob = File.read('.flickr.frob').strip
|
31
31
|
|
32
|
-
### get
|
33
|
-
if File.
|
32
|
+
### get
|
33
|
+
if File.exist?('.flickr.token')
|
34
34
|
token = File.read('.flickr.token').strip
|
35
|
-
else
|
36
|
-
puts "hmm, there is no token...."
|
35
|
+
else
|
36
|
+
puts "hmm, there is no token...."
|
37
37
|
method = 'flickr.auth.getToken'
|
38
38
|
sig = Digest::MD5.hexdigest("#{secret}api_key#{key}frob#{frob}method#{method}")
|
39
39
|
status, res = rest.get [
|
@@ -90,7 +90,7 @@ puts "RES:" + res[0].value.read
|
|
90
90
|
# Riddl::Parameter::Simple.new("tags", tags),
|
91
91
|
# Riddl::Parameter::Simple.new("is_public", is_public),
|
92
92
|
# Riddl::Parameter::Simple.new("api_sig", sig)
|
93
|
-
#]
|
93
|
+
#]
|
94
94
|
|
95
95
|
#rsp = XML::Smart::string(res[0].value.read)
|
96
96
|
#stat = rsp.find('string(/rsp/@stat)')
|
@@ -4,9 +4,9 @@ class FlickrHelper
|
|
4
4
|
def initialize(dir)
|
5
5
|
@api_key = File.read(dir + '/flickr.key').strip
|
6
6
|
@api_secret = File.read(dir + '/flickr.secret').strip
|
7
|
-
if File.
|
7
|
+
if File.exist?(dir + 'flickr.token')
|
8
8
|
@auth_token = File.read(dir + 'flickr.token').strip
|
9
|
-
else
|
9
|
+
else
|
10
10
|
@auth_token = "simulated"
|
11
11
|
end
|
12
12
|
end
|
@@ -19,10 +19,10 @@ class FlickrHelper
|
|
19
19
|
if e.class == Riddl::Parameter::Simple
|
20
20
|
if names.empty?
|
21
21
|
sig += "#{e.name}#{e.value}"
|
22
|
-
else
|
22
|
+
else
|
23
23
|
sig += "#{e.name}#{e.value}" if names.include?(e.name)
|
24
|
-
end
|
25
|
-
end
|
24
|
+
end
|
25
|
+
end
|
26
26
|
end
|
27
27
|
Digest::MD5.hexdigest(sig)
|
28
28
|
end
|
data/examples/twitter/client.rb
CHANGED
@@ -12,7 +12,7 @@ file_token = File.expand_path(File.dirname(__FILE__) + '/.twitter.token')
|
|
12
12
|
file_token_secret = File.expand_path(File.dirname(__FILE__) + '/.twitter.token_secret')
|
13
13
|
|
14
14
|
### When token and secret already saved, skip this part
|
15
|
-
if !File.
|
15
|
+
if !File.exist?(file_token) && !File.exist?(file_token_secret)
|
16
16
|
### go to request token resource and set necessary role options
|
17
17
|
resource = twitter.resource("/oauth/request_token")
|
18
18
|
params = [
|
@@ -12,7 +12,7 @@ file_token = File.expand_path(File.dirname(__FILE__) + '/.twitter.token')
|
|
12
12
|
file_token_secret = File.expand_path(File.dirname(__FILE__) + '/.twitter.token_secret')
|
13
13
|
|
14
14
|
### When token and secret already saved, skip this part
|
15
|
-
if !File.
|
15
|
+
if !File.exist?(file_token) && !File.exist?(file_token_secret)
|
16
16
|
### go to request token resource and set necessary role options
|
17
17
|
resource = twitter.resource("/oauth/request_token")
|
18
18
|
params = [
|
data/examples/zotero/client.rb
CHANGED
@@ -11,7 +11,7 @@ file_token = File.expand_path(File.dirname(__FILE__) + '/.zotero.token')
|
|
11
11
|
file_token_secret = File.expand_path(File.dirname(__FILE__) + '/.zotero.token_secret') #}}}
|
12
12
|
|
13
13
|
### When token and secret already saved, skip this part #{{{
|
14
|
-
if !File.
|
14
|
+
if !File.exist?(file_token) && !File.exist?(file_token_secret)
|
15
15
|
zotero = Riddl::Client.interface("https://www.zotero.org/","zotero.xml")
|
16
16
|
|
17
17
|
### go to request token resource and set necessary role options
|
@@ -95,7 +95,8 @@ module Riddl
|
|
95
95
|
tmp.write '--' + BOUNDARY + EOL
|
96
96
|
tmp.write 'RIDDL-TYPE: complex' + EOL
|
97
97
|
tmp.write "Content-Disposition: #{mode == :input ? 'form-data' : 'riddl-data'}; name=\"#{r.name}\""
|
98
|
-
tmp.write r.filename.nil? ? '; filename=""' + EOL : "; filename=\"#{r.filename}\"" + EOL
|
98
|
+
#tmp.write r.filename.nil? ? '; filename=""' + EOL : "; filename=\"#{r.filename}\"" + EOL
|
99
|
+
tmp.write r.filename.nil? ? EOL : "; filename=\"#{r.filename}\"" + EOL
|
99
100
|
tmp.write 'Content-Transfer-Encoding: binary' + EOL
|
100
101
|
tmp.write 'Content-Type: ' + r.mimetype + r.mimextra + EOL
|
101
102
|
tmp.write EOL
|
@@ -11,14 +11,14 @@ module Riddl
|
|
11
11
|
@status = 404
|
12
12
|
return []
|
13
13
|
end
|
14
|
-
if File.
|
14
|
+
if File.exist?(path)
|
15
15
|
__ERB_FILE__ = path
|
16
16
|
rval = ERB.new(File.read(path), 0, "%<>")
|
17
17
|
return Riddl::Parameter::Complex.new("data",MIME::Types.type_for(path)[0].to_s,rval.result(binding))
|
18
18
|
end
|
19
19
|
@status = 404
|
20
20
|
[]
|
21
|
-
end
|
21
|
+
end
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end
|
24
24
|
end
|
@@ -12,7 +12,7 @@ module Riddl
|
|
12
12
|
@status = 404
|
13
13
|
return []
|
14
14
|
end
|
15
|
-
if File.
|
15
|
+
if File.exist?(path)
|
16
16
|
mtime = File.mtime(path)
|
17
17
|
@headers << Riddl::Header.new("Last-Modified",mtime.httpdate)
|
18
18
|
@headers << Riddl::Header.new("ETag",Digest::MD5.hexdigest(mtime.httpdate))
|
@@ -87,18 +87,18 @@ module Riddl
|
|
87
87
|
def each(&block)
|
88
88
|
keys.each do |key|
|
89
89
|
f = @target + '/' + key + '/subscription.xml'
|
90
|
-
block.call Sub.new(f), key if File.
|
90
|
+
block.call Sub.new(f), key if File.exist? f
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
def include?(key)
|
95
95
|
f = @target + '/' + key + '/subscription.xml'
|
96
|
-
File.
|
96
|
+
File.exist?(f)
|
97
97
|
end
|
98
98
|
|
99
99
|
def [](key)
|
100
100
|
f = @target + '/' + key + '/subscription.xml'
|
101
|
-
File.
|
101
|
+
File.exist?(f) ? Sub.new(f) : nil
|
102
102
|
end
|
103
103
|
|
104
104
|
def create(&block)
|
@@ -133,7 +133,7 @@ module Riddl
|
|
133
133
|
def initialize(topics,target,init=nil)
|
134
134
|
@target = target.gsub(/^\/+/,'/')
|
135
135
|
|
136
|
-
unless File.
|
136
|
+
unless File.exist?(@target)
|
137
137
|
if init
|
138
138
|
FileUtils::cp_r init, @target
|
139
139
|
else
|
@@ -141,7 +141,7 @@ module Riddl
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
raise "topics file not found" unless File.
|
144
|
+
raise "topics file not found" unless File.exist?(topics)
|
145
145
|
@topics = XML::Smart.open_unprotected(topics.gsub(/^\/+/,'/'))
|
146
146
|
@topics.register_namespace 'n', 'http://riddl.org/ns/common-patterns/notifications-producer/1.0'
|
147
147
|
|
@@ -18,7 +18,7 @@ module Riddl
|
|
18
18
|
|
19
19
|
def [](key)
|
20
20
|
get(key)
|
21
|
-
end
|
21
|
+
end
|
22
22
|
|
23
23
|
def get(key)
|
24
24
|
@redis.get key
|
@@ -30,7 +30,7 @@ module Riddl
|
|
30
30
|
|
31
31
|
def each
|
32
32
|
if block_given?
|
33
|
-
@redis.keys.each do |e|
|
33
|
+
@redis.keys.each do |e|
|
34
34
|
yield e, get(e)
|
35
35
|
end
|
36
36
|
else
|
@@ -63,7 +63,7 @@ module Riddl
|
|
63
63
|
|
64
64
|
def [](key)
|
65
65
|
get(key)
|
66
|
-
end
|
66
|
+
end
|
67
67
|
|
68
68
|
def get(key)
|
69
69
|
read if changed != @changed
|
@@ -72,7 +72,7 @@ module Riddl
|
|
72
72
|
|
73
73
|
def each
|
74
74
|
if block_given?
|
75
|
-
@tokens.each do |k,v|
|
75
|
+
@tokens.each do |k,v|
|
76
76
|
yield k,v
|
77
77
|
end
|
78
78
|
else
|
@@ -91,7 +91,7 @@ module Riddl
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def changed
|
94
|
-
if ::File.
|
94
|
+
if ::File.exist?(@tfile)
|
95
95
|
::File.stat(@tfile).mtime
|
96
96
|
else
|
97
97
|
@tokens = {}
|
@@ -119,7 +119,7 @@ module Riddl
|
|
119
119
|
deleted
|
120
120
|
end
|
121
121
|
end #}}}
|
122
|
-
|
122
|
+
|
123
123
|
end #}}}
|
124
124
|
|
125
125
|
def self::header #{{{
|
@@ -75,10 +75,10 @@ module Riddl
|
|
75
75
|
@schema = @schemas.first[1]
|
76
76
|
@rng = @rngs.first[1]
|
77
77
|
|
78
|
-
FileUtils::mkdir_p(File::dirname(@target)) unless File.
|
79
|
-
FileUtils::cp init, @target if init and not File.
|
78
|
+
FileUtils::mkdir_p(File::dirname(@target)) unless File.exist?(@target)
|
79
|
+
FileUtils::cp init, @target if init and not File.exist?(@target)
|
80
80
|
|
81
|
-
raise "properties file not found" unless File.
|
81
|
+
raise "properties file not found" unless File.exist?(@target)
|
82
82
|
@data = XML::Smart.open_unprotected(@target)
|
83
83
|
@data.register_namespace 'p', 'http://riddl.org/ns/common-patterns/properties/1.0'
|
84
84
|
@mutex = Mutex.new
|
@@ -95,10 +95,10 @@ module Riddl
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def add_schema(key,name)
|
98
|
-
raise "schema file not found" unless File.
|
98
|
+
raise "schema file not found" unless File.exist?(name)
|
99
99
|
@schemas[key] = XML::Smart.open_unprotected(name.gsub(/^\/+/,'/'))
|
100
100
|
@schemas[key].register_namespace 'p', 'http://riddl.org/ns/common-patterns/properties/1.0'
|
101
|
-
if !File::
|
101
|
+
if !File::exist?(Riddl::Utils::Properties::PROPERTIES_SCHEMA_XSL_RNG)
|
102
102
|
raise "properties schema transformation file not found"
|
103
103
|
end
|
104
104
|
@rngs[key] = @schemas[key].transform_with(XML::Smart.open_unprotected(Riddl::Utils::Properties::PROPERTIES_SCHEMA_XSL_RNG))
|
@@ -14,7 +14,7 @@ module Riddl
|
|
14
14
|
@status = 404
|
15
15
|
return []
|
16
16
|
end
|
17
|
-
if File.
|
17
|
+
if File.exist?(path)
|
18
18
|
mtime = File.mtime(path)
|
19
19
|
@headers << Riddl::Header.new("Last-Modified",mtime.httpdate)
|
20
20
|
@headers << Riddl::Header.new("Cache-Control","max-age=15552000, public")
|
@@ -24,17 +24,17 @@ module Riddl
|
|
24
24
|
@headers << Riddl::Header.new("Connection","close")
|
25
25
|
@status = 304 # Not modified
|
26
26
|
return []
|
27
|
-
else
|
28
|
-
if xpath
|
27
|
+
else
|
28
|
+
if xpath
|
29
29
|
res = XML::Smart.open(path).find(xpath)
|
30
30
|
return Riddl::Parameter::Complex.new('file','text/xml',res.any? ? res.first.dump : '<empty/>')
|
31
31
|
else
|
32
32
|
return Riddl::Parameter::Complex.new('file','text/xml',File.open(path,'r'))
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
35
35
|
end
|
36
36
|
@status = 404
|
37
|
-
end
|
37
|
+
end
|
38
38
|
end
|
39
|
-
end
|
40
|
-
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/ruby/riddl/wrapper.rb
CHANGED
@@ -103,7 +103,7 @@ module Riddl
|
|
103
103
|
@doc.find('//x:include/@href').each do |i|
|
104
104
|
if i.value =~ /^http:\/\/(www\.)?riddl\.org(\/ns\/common-patterns\/.*)/
|
105
105
|
t = File.expand_path(File.dirname(__FILE__)) + $2
|
106
|
-
i.value = t if File.
|
106
|
+
i.value = t if File.exist?(t)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
fpath.nil? ? @doc.xinclude! : @doc.xinclude!(fpath)
|
@@ -275,7 +275,7 @@ module Riddl
|
|
275
275
|
#{{{
|
276
276
|
@doc.find("//des:resource/@role").map{|h|h.to_s}.uniq.each do |h|
|
277
277
|
h = Protocols::Utils::escape(h)
|
278
|
-
if File.
|
278
|
+
if File.exist?(File.dirname(__FILE__) + '/roles/' + h + '.rb')
|
279
279
|
require File.expand_path(File.dirname(__FILE__) + '/roles/' + h)
|
280
280
|
end
|
281
281
|
end
|
data/riddl.gemspec
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "riddl"
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.129"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.license = "LGPL-3.0"
|
6
|
-
s.summary = "
|
6
|
+
s.summary = "Restful Interface Description and Declaration Language: tools and client/server libs"
|
7
7
|
|
8
|
-
s.description = "
|
8
|
+
s.description = "REST service interface definition, mixing, and evolution. Supports mixed http and xmpp servers."
|
9
9
|
|
10
|
-
s.files = Dir['{lib/ruby/riddl/ns/**/*,tools/**/*,ns/**/*,contrib/**/*,lib/ruby/riddl/**/*,examples/**/*}'] + %w(COPYING Rakefile riddl.gemspec README.
|
10
|
+
s.files = Dir['{lib/ruby/riddl/ns/**/*,tools/**/*,ns/**/*,contrib/**/*,lib/ruby/riddl/**/*,examples/**/*}'] + %w(COPYING Rakefile riddl.gemspec README.md TODO AUTHORS INSTALL)
|
11
11
|
|
12
12
|
s.require_path = 'lib/ruby'
|
13
|
-
s.extra_rdoc_files = ['README.
|
13
|
+
s.extra_rdoc_files = ['README.md']
|
14
14
|
s.bindir = 'tools'
|
15
15
|
s.executables = ['riddlcheck','riddlprocess']
|
16
16
|
s.test_files = Dir['test/tc_*.rb','test/smartrunner.rb']
|
17
17
|
|
18
18
|
s.email = 'juergen.mangler@gmail.com'
|
19
|
-
s.authors = ['Juergen \'eTM\' Mangler','Florian \'Solo\' Stertz','Sonja Biedermann']
|
19
|
+
s.authors = ['Juergen \'eTM\' Mangler','Florian \'Solo\' Stertz','Sonja Biedermann','Matthias Ehrendorfer']
|
20
20
|
s.email = 'juergen.mangler@gmail.com'
|
21
|
-
s.homepage = 'http://
|
21
|
+
s.homepage = 'http://github.com/etm/riddl/'
|
22
22
|
|
23
23
|
s.required_ruby_version = '>=2.2.0'
|
24
24
|
|
data/tools/riddlcheck
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/ruby
|
2
2
|
curpath = __FILE__
|
3
3
|
while ::File::symlink?(curpath)
|
4
4
|
curpath = ::File::dirname(curpath) + '/' + ::File::readlink(curpath)
|
5
|
-
end
|
5
|
+
end
|
6
6
|
require 'rubygems'
|
7
7
|
require ::File::dirname(curpath) + "/../lib/ruby/riddl/wrapper"
|
8
8
|
require 'optparse'
|
@@ -15,7 +15,7 @@ ARGV.options { |opt|
|
|
15
15
|
opt.on("Filename is either a description or a declaration.")
|
16
16
|
opt.parse!
|
17
17
|
}
|
18
|
-
if ARGV.length == 0 || !File.
|
18
|
+
if ARGV.length == 0 || !File.exist?(ARGV[0])
|
19
19
|
puts ARGV.options
|
20
20
|
exit
|
21
21
|
end
|
@@ -27,7 +27,7 @@ if riddl.description?
|
|
27
27
|
puts 'RIDDL description found.'
|
28
28
|
elsif riddl.declaration?
|
29
29
|
puts 'RIDDL declaration found.'
|
30
|
-
else
|
30
|
+
else
|
31
31
|
puts 'Neither a RIDDL description, nor a RIDDL declaration.'
|
32
32
|
exit
|
33
33
|
end
|
data/tools/riddlprocess
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/ruby
|
2
2
|
curpath = __FILE__
|
3
3
|
while ::File::symlink?(curpath)
|
4
4
|
curpath = ::File::dirname(curpath) + '/' + ::File::readlink(curpath)
|
5
|
-
end
|
5
|
+
end
|
6
6
|
require 'rubygems'
|
7
7
|
require ::File::dirname(curpath) + "/../lib/ruby/riddl/wrapper"
|
8
8
|
require 'optparse'
|
@@ -21,7 +21,7 @@ ARGV.options { |opt|
|
|
21
21
|
opt.on("Filename has to be a declaration.")
|
22
22
|
opt.parse!
|
23
23
|
}
|
24
|
-
if ARGV.length == 0 || !File.
|
24
|
+
if ARGV.length == 0 || !File.exist?(ARGV[0]) || dowhat.nil?
|
25
25
|
puts ARGV.options
|
26
26
|
exit
|
27
27
|
end
|
@@ -30,7 +30,7 @@ fname = ARGV[0]
|
|
30
30
|
riddl = Riddl::Wrapper.new(fname)
|
31
31
|
|
32
32
|
unless riddl.declaration?
|
33
|
-
puts 'Not a RIDDL declaration.'
|
33
|
+
puts 'Not a RIDDL declaration.'
|
34
34
|
exit
|
35
35
|
end
|
36
36
|
unless riddl.validate!
|
@@ -48,4 +48,4 @@ case dowhat
|
|
48
48
|
d.visualize_facade
|
49
49
|
when 'description'
|
50
50
|
puts d.description_xml
|
51
|
-
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riddl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.129'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen 'eTM' Mangler
|
8
8
|
- Florian 'Solo' Stertz
|
9
9
|
- Sonja Biedermann
|
10
|
+
- Matthias Ehrendorfer
|
10
11
|
autorequire:
|
11
12
|
bindir: tools
|
12
13
|
cert_chain: []
|
13
|
-
date: 2023-03-
|
14
|
+
date: 2023-03-16 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: daemonite
|
@@ -248,7 +249,7 @@ dependencies:
|
|
248
249
|
- - "~>"
|
249
250
|
- !ruby/object:Gem::Version
|
250
251
|
version: '5.0'
|
251
|
-
description:
|
252
|
+
description: REST service interface definition, mixing, and evolution. Supports mixed
|
252
253
|
http and xmpp servers.
|
253
254
|
email: juergen.mangler@gmail.com
|
254
255
|
executables:
|
@@ -256,12 +257,12 @@ executables:
|
|
256
257
|
- riddlprocess
|
257
258
|
extensions: []
|
258
259
|
extra_rdoc_files:
|
259
|
-
- README.
|
260
|
+
- README.md
|
260
261
|
files:
|
261
262
|
- AUTHORS
|
262
263
|
- COPYING
|
263
264
|
- INSTALL
|
264
|
-
- README.
|
265
|
+
- README.md
|
265
266
|
- Rakefile
|
266
267
|
- TODO
|
267
268
|
- contrib/riddl.jpg
|
@@ -459,10 +460,8 @@ files:
|
|
459
460
|
- lib/ruby/riddl/ns/description/1.0/description.rng
|
460
461
|
- lib/ruby/riddl/option.rb
|
461
462
|
- lib/ruby/riddl/parameter.rb
|
462
|
-
- lib/ruby/riddl/protocols/generator.rb
|
463
463
|
- lib/ruby/riddl/protocols/http/generator.rb
|
464
464
|
- lib/ruby/riddl/protocols/http/parser.rb
|
465
|
-
- lib/ruby/riddl/protocols/parser.rb
|
466
465
|
- lib/ruby/riddl/protocols/sse.rb
|
467
466
|
- lib/ruby/riddl/protocols/utils.rb
|
468
467
|
- lib/ruby/riddl/protocols/websocket.rb
|
@@ -533,7 +532,7 @@ files:
|
|
533
532
|
- tools/flash-policy-server.rb
|
534
533
|
- tools/riddlcheck
|
535
534
|
- tools/riddlprocess
|
536
|
-
homepage: http://
|
535
|
+
homepage: http://github.com/etm/riddl/
|
537
536
|
licenses:
|
538
537
|
- LGPL-3.0
|
539
538
|
metadata: {}
|
@@ -552,10 +551,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
552
551
|
- !ruby/object:Gem::Version
|
553
552
|
version: '0'
|
554
553
|
requirements: []
|
555
|
-
rubygems_version: 3.
|
554
|
+
rubygems_version: 3.4.6
|
556
555
|
signing_key:
|
557
556
|
specification_version: 4
|
558
|
-
summary: '
|
557
|
+
summary: 'Restful Interface Description and Declaration Language: tools and client/server
|
559
558
|
libs'
|
560
559
|
test_files:
|
561
560
|
- test/tc_declaration-distributed.rb
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../constants')
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../utils')
|
3
|
-
require 'stringio'
|
4
|
-
|
5
|
-
module Riddl
|
6
|
-
module Protocols
|
7
|
-
module HTTP
|
8
|
-
class Generator
|
9
|
-
def initialize(params,headers)
|
10
|
-
@params = params
|
11
|
-
@headers = headers
|
12
|
-
end
|
13
|
-
|
14
|
-
def generate(mode=:output)
|
15
|
-
if @params.is_a?(Array) && @params.length == 1
|
16
|
-
body(@params[0],mode)
|
17
|
-
elsif @params.class == Riddl::Parameter::Simple || @params.class == Riddl::Parameter::Complex
|
18
|
-
body(@params,mode)
|
19
|
-
elsif @params.is_a?(Array) && @params.length > 1
|
20
|
-
multipart(mode)
|
21
|
-
else
|
22
|
-
if mode == :output
|
23
|
-
@headers['Content-Type'] = 'text/plain'
|
24
|
-
StringIO.new('','r+b')
|
25
|
-
else
|
26
|
-
StringIO.new('','r+b')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def body(r,mode)
|
32
|
-
tmp = StringIO.new('','r+b')
|
33
|
-
case r
|
34
|
-
when Riddl::Parameter::Simple
|
35
|
-
if mode == :output
|
36
|
-
tmp.write r.value
|
37
|
-
@headers['Content-Type'] = 'text/plain'
|
38
|
-
@headers['Content-ID'] = r.name
|
39
|
-
@headers['RIDDL-TYPE'] = 'simple'
|
40
|
-
end
|
41
|
-
if mode == :input
|
42
|
-
@headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
43
|
-
tmp.write Riddl::Protocols::Utils::escape(r.name) + '=' + Riddl::Protocols::Utils::escape(r.value)
|
44
|
-
end
|
45
|
-
when Riddl::Parameter::Complex
|
46
|
-
tmp.write(r.value.respond_to?(:read) ? r.value.read : r.value)
|
47
|
-
@headers['Content-Type'] = r.mimetype + r.mimextra
|
48
|
-
@headers['RIDDL-TYPE'] = 'complex'
|
49
|
-
if r.filename.nil?
|
50
|
-
@headers['Content-ID'] = r.name
|
51
|
-
else
|
52
|
-
@headers['Content-Disposition'] = "riddl-data; name=\"#{r.name}\"; filename=\"#{r.filename}\""
|
53
|
-
end
|
54
|
-
end
|
55
|
-
tmp.flush
|
56
|
-
tmp.rewind
|
57
|
-
tmp
|
58
|
-
end
|
59
|
-
private :body
|
60
|
-
|
61
|
-
def multipart(mode)
|
62
|
-
tmp = StringIO.new('','r+b')
|
63
|
-
scount = ccount = 0
|
64
|
-
@params.each do |r|
|
65
|
-
case r
|
66
|
-
when Riddl::Parameter::Simple
|
67
|
-
scount += 1
|
68
|
-
when Riddl::Parameter::Complex
|
69
|
-
ccount += 1
|
70
|
-
end
|
71
|
-
end
|
72
|
-
if scount > 0 && ccount == 0
|
73
|
-
@headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
74
|
-
res = []
|
75
|
-
@params.each do |r|
|
76
|
-
case r
|
77
|
-
when Riddl::Parameter::Simple
|
78
|
-
res << Riddl::Protocols::Utils::escape(r.name) + '=' + Riddl::Protocols::Utils::escape(r.value)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
tmp.write res.join('&')
|
82
|
-
else
|
83
|
-
if scount + ccount > 0
|
84
|
-
@headers['Content-Type'] = "multipart/#{mode == :input ? 'form-data' : 'mixed'}; boundary=\"#{BOUNDARY}\""
|
85
|
-
@params.each do |r|
|
86
|
-
case r
|
87
|
-
when Riddl::Parameter::Simple
|
88
|
-
tmp.write '--' + BOUNDARY + EOL
|
89
|
-
tmp.write 'RIDDL-TYPE: simple' + EOL
|
90
|
-
tmp.write "Content-Disposition: #{mode == :input ? 'form-data' : 'riddl-data'}; name=\"#{r.name}\"" + EOL
|
91
|
-
tmp.write EOL
|
92
|
-
tmp.write r.value
|
93
|
-
tmp.write EOL
|
94
|
-
when Riddl::Parameter::Complex
|
95
|
-
tmp.write '--' + BOUNDARY + EOL
|
96
|
-
tmp.write 'RIDDL-TYPE: complex' + EOL
|
97
|
-
tmp.write "Content-Disposition: #{mode == :input ? 'form-data' : 'riddl-data'}; name=\"#{r.name}\""
|
98
|
-
tmp.write r.filename.nil? ? '; filename=""' + EOL : "; filename=\"#{r.filename}\"" + EOL
|
99
|
-
tmp.write 'Content-Transfer-Encoding: binary' + EOL
|
100
|
-
tmp.write 'Content-Type: ' + r.mimetype + r.mimextra + EOL
|
101
|
-
tmp.write EOL
|
102
|
-
tmp.write(r.value.respond_to?(:read) ? r.value.read : r.value)
|
103
|
-
tmp.write EOL
|
104
|
-
end
|
105
|
-
end
|
106
|
-
tmp.write '--' + BOUNDARY + EOL
|
107
|
-
end
|
108
|
-
end
|
109
|
-
tmp.flush
|
110
|
-
tmp.rewind
|
111
|
-
tmp
|
112
|
-
end
|
113
|
-
private :multipart
|
114
|
-
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,205 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../constants')
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../parameter')
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../utils')
|
4
|
-
|
5
|
-
module Riddl
|
6
|
-
module Protocols
|
7
|
-
module HTTP
|
8
|
-
class Parser
|
9
|
-
MULTIPART_CONTENT_TYPES = [
|
10
|
-
#{{{
|
11
|
-
'multipart/form-data',
|
12
|
-
'multipart/related',
|
13
|
-
'multipart/mixed'
|
14
|
-
#}}}
|
15
|
-
].freeze
|
16
|
-
FORM_CONTENT_TYPES = [
|
17
|
-
#{{{
|
18
|
-
'application/x-www-form-urlencoded'
|
19
|
-
#}}}
|
20
|
-
].freeze
|
21
|
-
|
22
|
-
def parse_content(input,ctype,content_length,content_disposition,content_id,riddl_type)
|
23
|
-
#{{{
|
24
|
-
# fixing for chunked?
|
25
|
-
|
26
|
-
ctype = nil if riddl_type == 'simple'
|
27
|
-
filename = content_disposition[/ filename="?([^\";]*)"?/ni, 1]
|
28
|
-
name = content_disposition[/ name="?([^\";]*)"?/ni, 1] || content_id
|
29
|
-
|
30
|
-
if ctype || filename
|
31
|
-
body = Parameter::Tempfile.new("RiddlMultipart")
|
32
|
-
body.binmode if body.respond_to?(:binmode)
|
33
|
-
else
|
34
|
-
body = ''
|
35
|
-
end
|
36
|
-
|
37
|
-
if content_length == 0
|
38
|
-
bufsize = 16384
|
39
|
-
until input.eof?
|
40
|
-
c = input.read(bufsize)
|
41
|
-
raise EOFError, "bad content body" if c.nil? || c.empty?
|
42
|
-
body << c
|
43
|
-
content_length -= c.size
|
44
|
-
end
|
45
|
-
body << input.read
|
46
|
-
else
|
47
|
-
bufsize = 16384
|
48
|
-
until content_length <= 0
|
49
|
-
c = input.read(bufsize < content_length ? bufsize : content_length)
|
50
|
-
raise EOFError, "bad content body" if c.nil? || c.empty?
|
51
|
-
body << c
|
52
|
-
content_length -= c.size
|
53
|
-
end
|
54
|
-
end
|
55
|
-
body.rewind if body.respond_to?(:binmode)
|
56
|
-
|
57
|
-
add_to_params(name,body,filename,ctype,nil) if body.length > 0
|
58
|
-
#}}}
|
59
|
-
end
|
60
|
-
private :parse_content
|
61
|
-
|
62
|
-
def parse_multipart(input,content_type,content_length)
|
63
|
-
#{{{
|
64
|
-
content_type =~ %r|\Amultipart/.*boundary=\"?([^\";,]+)\"?|n
|
65
|
-
boundary = "--#{$1}"
|
66
|
-
|
67
|
-
boundary_size = boundary.size + EOL.size
|
68
|
-
content_length -= boundary_size
|
69
|
-
status = input.read(boundary_size)
|
70
|
-
raise EOFError, "bad content body" unless status == boundary + EOL
|
71
|
-
|
72
|
-
rx = /(?:#{EOL})?#{Regexp.quote boundary}(#{EOL}|--)/n
|
73
|
-
|
74
|
-
buf = ""
|
75
|
-
bufsize = 16384
|
76
|
-
loop do
|
77
|
-
head = nil
|
78
|
-
body = ''
|
79
|
-
filename = ctype = name = nil
|
80
|
-
|
81
|
-
until head && buf =~ rx
|
82
|
-
if !head && i = buf.index(EOL+EOL)
|
83
|
-
head = buf.slice!(0, i+2) # First \r\n
|
84
|
-
buf.slice!(0, 2) # Second \r\n
|
85
|
-
|
86
|
-
filename = head[/Content-Disposition:.* filename="?([^\";]*)"?/ni, 1]
|
87
|
-
ctype = head[/Content-Type: (.*)#{EOL}/ni, 1]
|
88
|
-
name = head[/Content-Disposition:.*\s+name="?([^\";]*)"?/ni, 1] || head[/Content-ID:\s*([^#{EOL}]*)/ni, 1]
|
89
|
-
|
90
|
-
if ctype || filename
|
91
|
-
body = Parameter::Tempfile.new("RiddlMultipart")
|
92
|
-
body.binmode if body.respond_to?(:binmode)
|
93
|
-
end
|
94
|
-
|
95
|
-
next
|
96
|
-
end
|
97
|
-
|
98
|
-
# Save the read body part.
|
99
|
-
if head && (boundary_size+4 < buf.size)
|
100
|
-
body << buf.slice!(0, buf.size - (boundary_size+4))
|
101
|
-
end
|
102
|
-
|
103
|
-
c = input.read(bufsize < content_length ? bufsize : content_length)
|
104
|
-
raise EOFError, "bad content body" if c.nil? || c.empty?
|
105
|
-
content_length -= c.size
|
106
|
-
|
107
|
-
buf << c
|
108
|
-
end
|
109
|
-
|
110
|
-
# Save the rest.
|
111
|
-
if i = buf.index(rx)
|
112
|
-
body << buf.slice!(0, i)
|
113
|
-
buf.slice!(0, boundary_size+2)
|
114
|
-
content_length = -1 if $1 == "--"
|
115
|
-
end
|
116
|
-
|
117
|
-
p name
|
118
|
-
p body
|
119
|
-
p filename
|
120
|
-
p ctype
|
121
|
-
p head
|
122
|
-
p '----'
|
123
|
-
|
124
|
-
add_to_params(name,body,filename == '' ? nil : filename,ctype,head)
|
125
|
-
|
126
|
-
break if buf.empty? || content_length == -1
|
127
|
-
end
|
128
|
-
#}}}
|
129
|
-
end
|
130
|
-
private :parse_multipart
|
131
|
-
|
132
|
-
def add_to_params(name,body,filename,ctype,head)
|
133
|
-
#{{{
|
134
|
-
if filename == ""
|
135
|
-
# filename is blank which means no file has been selected
|
136
|
-
elsif filename && ctype
|
137
|
-
body.rewind
|
138
|
-
|
139
|
-
# Take the basename of the upload's original filename.
|
140
|
-
# This handles the full Windows paths given by Internet Explorer
|
141
|
-
# (and perhaps other broken user agents) without affecting
|
142
|
-
# those which give the lone filename.
|
143
|
-
filename =~ /^(?:.*[:\\\/])?(.*)/m
|
144
|
-
filename = $1
|
145
|
-
|
146
|
-
@params << Parameter::Complex.new(name, ctype, body, filename, head)
|
147
|
-
elsif !filename && ctype
|
148
|
-
body.rewind
|
149
|
-
|
150
|
-
# Generic multipart cases, not coming from a form
|
151
|
-
@params << Parameter::Complex.new(name, ctype, body, nil, head)
|
152
|
-
else
|
153
|
-
@params << Parameter::Simple.new(name, body, :body)
|
154
|
-
end
|
155
|
-
#}}}
|
156
|
-
end
|
157
|
-
private :add_to_params
|
158
|
-
|
159
|
-
def parse_nested_query(qs, type)
|
160
|
-
#{{{
|
161
|
-
(qs || '').split(/[#{D}] */n).each do |p|
|
162
|
-
k, v = Riddl::Protocols::Utils::unescape(p).split('=', 2)
|
163
|
-
@params << Parameter::Simple.new(k,v,type)
|
164
|
-
end
|
165
|
-
#}}}
|
166
|
-
end
|
167
|
-
private :parse_nested_query
|
168
|
-
|
169
|
-
def initialize(query_string,input,content_type,content_length,content_disposition,content_id,riddl_type)
|
170
|
-
#{{{
|
171
|
-
# rewind because in some cases it is not at start (when multipart without length)
|
172
|
-
|
173
|
-
begin
|
174
|
-
input.rewind if input.respond_to?(:rewind)
|
175
|
-
rescue Errno::ESPIPE
|
176
|
-
# Handles exceptions raised by input streams that cannot be rewound
|
177
|
-
# such as when using plain CGI under Apache
|
178
|
-
end
|
179
|
-
|
180
|
-
media_type = content_type && content_type.split(/\s*[;,]\s*/, 2).first.downcase
|
181
|
-
@params = Riddl::Parameter::Array.new
|
182
|
-
parse_nested_query(query_string,:query)
|
183
|
-
if MULTIPART_CONTENT_TYPES.include?(media_type)
|
184
|
-
parse_multipart(input,content_type,content_length.to_i)
|
185
|
-
elsif FORM_CONTENT_TYPES.include?(media_type)
|
186
|
-
# sub is a fix for Safari Ajax postings that always append \0
|
187
|
-
parse_nested_query(input.read.sub(/\0\z/, ''),:body)
|
188
|
-
else
|
189
|
-
parse_content(input,content_type,content_length.to_i,content_disposition||'',content_id||'',riddl_type||'')
|
190
|
-
end
|
191
|
-
|
192
|
-
begin
|
193
|
-
input.rewind if input.respond_to?(:rewind)
|
194
|
-
rescue Errno::ESPIPE
|
195
|
-
# Handles exceptions raised by input streams that cannot be rewound
|
196
|
-
# such as when using plain CGI under Apache
|
197
|
-
end
|
198
|
-
#}}}
|
199
|
-
end
|
200
|
-
|
201
|
-
attr_reader :params
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
/data/{README.rdoc → README.md}
RENAMED
File without changes
|