sinatra-linkeddata 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/AUTHORS ADDED
@@ -0,0 +1 @@
1
+ * Arto Bendiken <arto.bendiken@gmail.com>
data/README ADDED
@@ -0,0 +1,165 @@
1
+ Linked Data Content Negotiation for Sinatra Applications
2
+ ========================================================
3
+
4
+ This is a [Sinatra][] extension that provides [Linked Data][] content
5
+ negotiation for Sinatra applications.
6
+
7
+ * <http://github.com/datagraph/sinatra-linkeddata>
8
+
9
+ Features
10
+ --------
11
+
12
+ * Implements [HTTP content negotiation][conneg] for RDF content types using
13
+ the [`Rack::LinkedData`][Rack::LinkedData] middleware.
14
+ * Supports all [RDF.rb][]-compatible serialization formats.
15
+ * Supports both classic and modular Sinatra applications.
16
+
17
+ Examples
18
+ --------
19
+
20
+ ### Adding Linked Data content negotiation to a classic Sinatra application
21
+
22
+ #!/usr/bin/env ruby -rubygems
23
+ require 'sinatra'
24
+ require 'sinatra/linkeddata'
25
+
26
+ get '/hello' do
27
+ RDF::Graph.new do |graph|
28
+ graph << [RDF::Node.new, RDF::DC.title, "Hello, world!"]
29
+ end
30
+ end
31
+
32
+ ### Adding Linked Data content negotiation to a modular Sinatra application
33
+
34
+ #!/usr/bin/env ruby -rubygems
35
+ require 'sinatra/base'
36
+ require 'sinatra/linkeddata'
37
+
38
+ module My
39
+ class Application < Sinatra::Base
40
+ register Sinatra::LinkedData
41
+
42
+ get '/hello' do
43
+ RDF::Graph.new do |graph|
44
+ graph << [RDF::Node.new, RDF::DC.title, "Hello, world!"]
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ My::Application.run! :host => '127.0.0.1', :port => 4567
51
+
52
+ ### Adding Linked Data content negotiation to a Rackup application
53
+
54
+ #!/usr/bin/env rackup
55
+ require 'sinatra/base'
56
+ require 'sinatra/linkeddata'
57
+
58
+ module My
59
+ class Application < Sinatra::Base
60
+ register Sinatra::LinkedData
61
+
62
+ get '/hello' do
63
+ RDF::Graph.new do |graph|
64
+ graph << [RDF::Node.new, RDF::DC.title, "Hello, world!"]
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ run My::Application
71
+
72
+ ### Testing Linked Data content negotiation using `rackup` and `curl`
73
+
74
+ $ rackup doc/examples/config.ru
75
+
76
+ $ curl -iH "Accept: text/plain" http://localhost:9292/hello
77
+ $ curl -iH "Accept: text/turtle" http://localhost:9292/hello
78
+ $ curl -iH "Accept: application/rdf+xml" http://localhost:9292/hello
79
+ $ curl -iH "Accept: application/json" http://localhost:9292/hello
80
+ $ curl -iH "Accept: application/trix" http://localhost:9292/hello
81
+ $ curl -iH "Accept: */*" http://localhost:9292/hello
82
+
83
+ Description
84
+ -----------
85
+
86
+ `Sinatra::LinkedData` is a thin Sinatra-specific wrapper around the
87
+ [`Rack::LinkedData`][Rack::LinkedData] middleware, which implements Linked
88
+ Data content negotiation for Rack applications.
89
+
90
+ At the moment the Sinatra extension simply corresponds
91
+ to doing the following manually in a Sinatra application:
92
+
93
+ require 'rack/linkeddata'
94
+
95
+ module My
96
+ class Application < Sinatra::Base
97
+ use Rack::LinkedData::ContentNegotiation
98
+ helpers Sinatra::LinkedData::Helpers
99
+ include RDF
100
+ include LinkedData
101
+ end
102
+ end
103
+
104
+ See the `Rack::LinkedData` documentation for more information on the
105
+ operation and details of the content negotiation.
106
+
107
+ Documentation
108
+ -------------
109
+
110
+ <http://datagraph.rubyforge.org/sinatra-linkeddata/>
111
+
112
+ * {Sinatra::LinkedData}
113
+
114
+ Dependencies
115
+ ------------
116
+
117
+ * [Sinatra](http://rubygems.org/gems/sinatra) (>= 1.0)
118
+ * [Rack::LinkedData](http://rubygems.org/gems/rack-linkeddata) (>= 0.2.0)
119
+
120
+ Installation
121
+ ------------
122
+
123
+ The recommended installation method is via [RubyGems](http://rubygems.org/).
124
+ To install the latest official release of the gem, do:
125
+
126
+ % [sudo] gem install sinatra-linkeddata
127
+
128
+ Download
129
+ --------
130
+
131
+ To get a local working copy of the development repository, do:
132
+
133
+ % git clone git://github.com/datagraph/sinatra-linkeddata.git
134
+
135
+ Alternatively, you can download the latest development version as a tarball
136
+ as follows:
137
+
138
+ % wget http://github.com/datagraph/sinatra-linkeddata/tarball/master
139
+
140
+ References
141
+ ----------
142
+
143
+ * <http://www.w3.org/DesignIssues/LinkedData.html>
144
+ * <http://linkeddata.org/docs/how-to-publish>
145
+ * <http://linkeddata.org/conneg-303-redirect-code-samples>
146
+ * <http://www.w3.org/TR/cooluris/>
147
+ * <http://www.w3.org/TR/swbp-vocab-pub/>
148
+ * <http://patterns.dataincubator.org/book/publishing-patterns.html>
149
+
150
+ Authors
151
+ -------
152
+
153
+ * [Arto Bendiken](mailto:arto.bendiken@gmail.com) - <http://ar.to/>
154
+
155
+ License
156
+ -------
157
+
158
+ `Sinatra::LinkedData` is free and unencumbered public domain software. For more
159
+ information, see <http://unlicense.org/> or the accompanying UNLICENSE file.
160
+
161
+ [Sinatra]: http://www.sinatrarb.com/
162
+ [RDF.rb]: http://rdf.rubyforge.org/
163
+ [Rack::LinkedData]: http://datagraph.rubyforge.org/rack-linkeddata/
164
+ [Linked Data]: http://linkeddata.org/
165
+ [conneg]: http://en.wikipedia.org/wiki/Content_negotiation
data/UNLICENSE ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org/>
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,28 @@
1
+ require 'sinatra/base'
2
+ require 'rack/linkeddata'
3
+
4
+ module Sinatra
5
+ ##
6
+ # @see http://www.sinatrarb.com/extensions.html
7
+ module LinkedData
8
+ autoload :VERSION, 'sinatra/linkeddata/version'
9
+
10
+ ##
11
+ # Helper methods.
12
+ module Helpers
13
+ # TODO
14
+ end
15
+
16
+ ##
17
+ # @param [Sinatra::Base] app
18
+ # @return [void]
19
+ def self.registered(app)
20
+ app.use(Rack::LinkedData::ContentNegotiation)
21
+ app.helpers(Sinatra::LinkedData::Helpers)
22
+ app.send(:include, ::RDF)
23
+ app.send(:include, ::LinkedData)
24
+ end
25
+ end
26
+ end
27
+
28
+ Sinatra.register(Sinatra::LinkedData)
@@ -0,0 +1,22 @@
1
+ module Sinatra; module LinkedData
2
+ module VERSION
3
+ MAJOR = 0
4
+ MINOR = 2
5
+ TINY = 0
6
+ EXTRA = nil
7
+
8
+ STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')
9
+
10
+ ##
11
+ # @return [String]
12
+ def self.to_s() STRING end
13
+
14
+ ##
15
+ # @return [String]
16
+ def self.to_str() STRING end
17
+
18
+ ##
19
+ # @return [Array(Integer, Integer, Integer)]
20
+ def self.to_a() [MAJOR, MINOR, TINY] end
21
+ end
22
+ end; end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-linkeddata
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
+ platform: ruby
11
+ authors:
12
+ - Datagraph
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-23 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: yard
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 5
30
+ - 8
31
+ version: 0.5.8
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rspec
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 3
44
+ - 0
45
+ version: 1.3.0
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rack-test
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 5
58
+ - 4
59
+ version: 0.5.4
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: sinatra
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 1
71
+ - 0
72
+ version: "1.0"
73
+ type: :runtime
74
+ version_requirements: *id004
75
+ - !ruby/object:Gem::Dependency
76
+ name: rack-linkeddata
77
+ prerelease: false
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ - 2
85
+ - 0
86
+ version: 0.2.0
87
+ type: :runtime
88
+ version_requirements: *id005
89
+ description: Sinatra extension for Linked Data content negotiation.
90
+ email: datagraph@googlegroups.com
91
+ executables: []
92
+
93
+ extensions: []
94
+
95
+ extra_rdoc_files: []
96
+
97
+ files:
98
+ - AUTHORS
99
+ - README
100
+ - UNLICENSE
101
+ - VERSION
102
+ - lib/sinatra/linkeddata/version.rb
103
+ - lib/sinatra/linkeddata.rb
104
+ has_rdoc: false
105
+ homepage: http://github.com/datagraph
106
+ licenses:
107
+ - Public Domain
108
+ post_install_message:
109
+ rdoc_options: []
110
+
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ segments:
118
+ - 1
119
+ - 8
120
+ - 1
121
+ version: 1.8.1
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ requirements: []
130
+
131
+ rubyforge_project: datagraph
132
+ rubygems_version: 1.3.6
133
+ signing_key:
134
+ specification_version: 3
135
+ summary: Linked Data content negotiation for Sinatra applications.
136
+ test_files: []
137
+