riddl 0.99.218 → 0.99.219

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,72 @@
1
+ require 'rubygems'
2
+ require 'rdf/smart'
3
+ require 'json'
4
+
5
+ module Riddl
6
+ module Utils
7
+
8
+ module Turtle
9
+
10
+ class File
11
+ attr_accessor :data, :changed
12
+ attr_reader :url
13
+
14
+ def initialize(url)
15
+ @url = url
16
+ @data = ""
17
+ @changed = Time.at(0)
18
+ end
19
+ end
20
+
21
+ def self::implementation(tf)
22
+ Proc.new do
23
+ if ::File.mtime(tf.url) > tf.changed
24
+ tf.data = ""
25
+ ::File.open(tf.url,"r") do |f|
26
+ f.each_line do |line|
27
+ tf.data += line
28
+ end
29
+ end
30
+ tf.changed = ::File.mtime(tf.url)
31
+ end
32
+ run Show, tf.data, tf.changed if get
33
+ run Query, tf.url if get 'query'
34
+ on resource do
35
+ run GetQuery, tf.url if get
36
+ end
37
+ end
38
+ end
39
+ class Query < Riddl::Implementation # {{{
40
+ def response #{{{
41
+ Riddl::Parameter::Complex.new "list","application/json", JSON::pretty_generate(RDF::Smart.new(@a[0]).execute(@p[0].value))
42
+ end #}}}
43
+ end # }}}
44
+ class Show < Riddl::Implementation # {{{
45
+ def response #{{{
46
+ Riddl::Parameter::Complex.new "list", "text/plain", @a[0]
47
+ end #}}}
48
+ end # }}}
49
+ class GetQuery < Riddl::Implementation#{{{
50
+ def response #{{{
51
+ a = RDF::Smart.new(@a[0])
52
+ if a.namespaces.size > 0
53
+ ns = ""
54
+ if @r[-1].start_with?(":")
55
+ if (!(a.namespaces[nil]))
56
+ return Riddl::Parameter::Complex.new "value","text/plain", "Error parsing namespaces"
57
+ end
58
+ return Riddl::Parameter::Complex.new "value","application/json", JSON::pretty_generate(a.execute("PREFIX : <" + a.namespaces[nil] + "> SELECT * WHERE { #{@r[-1]} ?p ?o}"))
59
+ else
60
+ if (!(a.namespaces[@r[-1].partition(":")[0]]))
61
+ return Riddl::Parameter::Complex.new "value","text/plain", "Error parsing namespaces"
62
+ end
63
+ return Riddl::Parameter::Complex.new "value","application/json", JSON::pretty_generate(a.execute("PREFIX #{@r[-1].partition(":")[0]}: <" + a.namespaces[@r[-1].partition(":")[0]] + "> SELECT * WHERE { #{@r[-1]} ?p ?o}"))
64
+ end
65
+ end
66
+ Riddl::Parameter::Complex.new "list","application/json", JSON::pretty_generate(a.execute("select * where {#{@r[-1]} ?p ?o}"))
67
+ end #}}}
68
+ end#}}}
69
+
70
+ end
71
+ end
72
+ end
@@ -116,7 +116,7 @@ module Riddl
116
116
  refresh_tokens = @a[1]
117
117
 
118
118
  access_tokens.delete(token)
119
- refresh_tokens.delete_by_token(token)
119
+ refresh_tokens.delete_by_value(token)
120
120
  end
121
121
  end
122
122
 
@@ -126,8 +126,8 @@ module Riddl
126
126
  access_tokens = @a[0]
127
127
  refresh_tokens = @a[1]
128
128
 
129
- token = access_tokens.delete_by_user user_id
130
- refresh_tokens.delete_by_token token
129
+ token = access_tokens.delete_by_value user_id
130
+ refresh_tokens.delete_by_value token
131
131
  end
132
132
  end
133
133
 
@@ -0,0 +1,40 @@
1
+ require 'mime/types'
2
+ require 'charlock_holmes'
3
+ require 'digest/md5'
4
+ require 'xml/smart'
5
+
6
+ module Riddl
7
+ module Utils
8
+ class XMLServe < Riddl::Implementation
9
+ def response
10
+ path = File.file?(@a[0]) ? @a[0] : nil
11
+ xpath = @a[1]
12
+
13
+ if path.nil? || File.directory?(path)
14
+ @status = 404
15
+ return []
16
+ end
17
+ if File.exists?(path)
18
+ mtime = File.mtime(path)
19
+ @headers << Riddl::Header.new("Last-Modified",mtime.httpdate)
20
+ @headers << Riddl::Header.new("Cache-Control","max-age=15552000, public")
21
+ @headers << Riddl::Header.new("ETag",Digest::MD5.hexdigest(mtime.httpdate))
22
+ htime = @env["HTTP_IF_MODIFIED_SINCE"].nil? ? Time.at(0) : Time.parse(@env["HTTP_IF_MODIFIED_SINCE"])
23
+ if htime == mtime
24
+ @headers << Riddl::Header.new("Connection","close")
25
+ @status = 304 # Not modified
26
+ return []
27
+ else
28
+ if xpath
29
+ res = XML::Smart.open(path).find(xpath)
30
+ return Riddl::Parameter::Complex.new('file','text/xml',res.any? ? res.first.dump : '<empty/>')
31
+ else
32
+ return Riddl::Parameter::Complex.new('file','text/xml',File.open(path,'r'))
33
+ end
34
+ end
35
+ end
36
+ @status = 404
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,21 @@
1
+ module Riddl
2
+ module Utils
3
+
4
+ class XSLOverlay < Riddl::Implementation
5
+ def response
6
+ doc = if @p[0].value.class == String
7
+ XML::Smart::string(@p[0].value)
8
+ elsif @p[0].value.respond_to?(:read)
9
+ XML::Smart::string(@p[0].value.read)
10
+ else
11
+ nil
12
+ end
13
+ unless doc.nil?
14
+ doc.root.add_before "?xml-stylesheet", "href='#{@a[0]}' type='text/xsl'"
15
+ Riddl::Parameter::Complex.new("content",@p[0].mimetype,doc.to_s)
16
+ end
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "riddl"
3
- s.version = "0.99.218"
3
+ s.version = "0.99.219"
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"
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.218
4
+ version: 0.99.219
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen 'eTM' Mangler
@@ -387,7 +387,13 @@ files:
387
387
  - lib/ruby/riddl/client.rb
388
388
  - lib/ruby/riddl/commonlogger.rb
389
389
  - lib/ruby/riddl/constants.rb
390
+ - lib/ruby/riddl/description.rb
391
+ - lib/ruby/riddl/docoverlay.html
392
+ - lib/ruby/riddl/docoverlay.rb
393
+ - lib/ruby/riddl/downloadify.rb
394
+ - lib/ruby/riddl/erbserve.rb
390
395
  - lib/ruby/riddl/error.rb
396
+ - lib/ruby/riddl/fileserve.rb
391
397
  - lib/ruby/riddl/handlers.rb
392
398
  - lib/ruby/riddl/handlers/oauth.rb
393
399
  - lib/ruby/riddl/handlers/plain-type.rb
@@ -395,6 +401,7 @@ files:
395
401
  - lib/ruby/riddl/handlers/xmlschema.rb
396
402
  - lib/ruby/riddl/header.rb
397
403
  - lib/ruby/riddl/implementation.rb
404
+ - lib/ruby/riddl/notifications_producer.rb
398
405
  - lib/ruby/riddl/ns/common-patterns/addon-security/request.xml
399
406
  - lib/ruby/riddl/ns/common-patterns/addon-security/response.xml
400
407
  - lib/ruby/riddl/ns/common-patterns/downloadify/1.0/downloadify.xml
@@ -413,8 +420,11 @@ files:
413
420
  - lib/ruby/riddl/ns/common/relaxng.rng
414
421
  - lib/ruby/riddl/ns/declaration/1.0/declaration.rng
415
422
  - lib/ruby/riddl/ns/description/1.0/description.rng
423
+ - lib/ruby/riddl/oauth2-helper.rb
424
+ - lib/ruby/riddl/oauth2-univie.rb
416
425
  - lib/ruby/riddl/option.rb
417
426
  - lib/ruby/riddl/parameter.rb
427
+ - lib/ruby/riddl/properties.rb
418
428
  - lib/ruby/riddl/protocols/http/generator.rb
419
429
  - lib/ruby/riddl/protocols/http/parser.rb
420
430
  - lib/ruby/riddl/protocols/utils.rb
@@ -427,6 +437,7 @@ files:
427
437
  - lib/ruby/riddl/roles/http%3A%2F%2Foauth.net%2F1.0%2Frequest_token.rb
428
438
  - lib/ruby/riddl/roles/http%3A%2F%2Foauth.net%2F1.0/base.rb
429
439
  - lib/ruby/riddl/server.rb
440
+ - lib/ruby/riddl/turtle.rb
430
441
  - lib/ruby/riddl/utils/description.rb
431
442
  - lib/ruby/riddl/utils/docoverlay.html
432
443
  - lib/ruby/riddl/utils/docoverlay.rb
@@ -452,6 +463,8 @@ files:
452
463
  - lib/ruby/riddl/wrapper/layerchecker.rb
453
464
  - lib/ruby/riddl/wrapper/messageparser.rb
454
465
  - lib/ruby/riddl/wrapper/resourcechecker.rb
466
+ - lib/ruby/riddl/xmlserve.rb
467
+ - lib/ruby/riddl/xsloverlay.rb
455
468
  - ns/common-patterns/addon-security/request.xml
456
469
  - ns/common-patterns/addon-security/response.xml
457
470
  - ns/common-patterns/downloadify/1.0/downloadify.xml