rack-linkeddata 2.2.2 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b1c9a0ddbc3a23ee37f6aefc9ba4adde4671181e
4
- data.tar.gz: 14c2fbc74dfc76f243292eb7763b30ec4e3b23cb
2
+ SHA256:
3
+ metadata.gz: 68f16f0a49372e98436fb911d7d889e99738567d346c315198fa518f192df451
4
+ data.tar.gz: 35e426422a220ff1959ce91cf579a9451e4c8b9d10cf09deec17250f929b9c4e
5
5
  SHA512:
6
- metadata.gz: 6270b177a3a3c72b8a28208c23ee207cd350da68cdff0ba3e5a0824df80bfcd0ed549a271ef4a845522f964396c136e4e2584dc5f3ab62253105557135ecec1e
7
- data.tar.gz: 699e48429e41637e23cdea4d532ba6b8cb933755c80550465bbb69de5a276e2884e984dc67385c004d8e8123b55a5d02976565e8eea2b039b4d79ad3ca61fc3f
6
+ metadata.gz: 90531f8be5814fcd18a0df8e634060340c6a16cd0e7a6fde8c7489c7c6159c6d27b3ac726799f7bcdcbb65bbc21cb289a20656ef023190b2f904acfd5f8f62e8
7
+ data.tar.gz: 5b9e85337e9d52946e544e1c48e4c1a5ed9bf0cfecbddaf4ec12cb28dd7914100a2be6c95455b31ccf756c67d2275017fedbdc858dfcfdd3cee49a78f96a3e60
data/AUTHORS CHANGED
@@ -1 +1,2 @@
1
1
  * Arto Bendiken <arto.bendiken@gmail.com>
2
+ * Gregg Kellogg <gregg@greggkellogg.net>
data/README.md CHANGED
@@ -5,15 +5,16 @@ negotiation for Rack applications. You can use `Rack::LinkedData` with any
5
5
  Ruby web framework based on Rack, including with Ruby on Rails 3.0 and with
6
6
  Sinatra.
7
7
 
8
- * <http://github.com/datagraph/rack-linkeddata>
8
+ * <https://github.com/ruby-rdf/rack-linkeddata>
9
9
 
10
- [![Gem Version](https://badge.fury.io/rb/rack-linkeddata.png)](http://badge.fury.io/rb/rack-linkeddata)
11
- [![Build Status](https://travis-ci.org/ruby-rdf/rack-linkeddata.png?branch=master)](http://travis-ci.org/ruby-rdf/rack-linkeddata)
10
+ [![Gem Version](https://badge.fury.io/rb/rack-linkeddata.png)](https://badge.fury.io/rb/rack-linkeddata)
11
+ [![Build Status](https://github.com/ruby-rdf/rack-linkeddata/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/rack-linkeddata/actions?query=workflow%3ACI)
12
+ [![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf)
12
13
 
13
14
  ## Features
14
15
 
15
16
  * Implements [HTTP content negotiation][conneg] for RDF content types.
16
- * Supports all [RDF.rb][]-compatible serialization formats.
17
+ * Supports all [RDF.rb][] compatible serialization formats.
17
18
  * Compatible with any Rack application and any Rack-based framework.
18
19
 
19
20
  ## Examples
@@ -91,19 +92,19 @@ for N-Triples, N-Quads, Turtle, RDF/XML, RDF/JSON, JSON-LD, RDFa, TriG and TriX.
91
92
 
92
93
  ##Documentation
93
94
 
94
- <http://http://rubydoc.info/github/ruby-rdf/rack-linkeddata/>
95
+ <https://rubydoc.info/github/ruby-rdf/rack-linkeddata/>
95
96
 
96
97
  * {Rack::LinkedData}
97
98
  * {Rack::LinkedData::ContentNegotiation}
98
99
 
99
100
  ## Dependencies
100
101
 
101
- * [Rack](http://rubygems.org/gems/rack) (~> 1.6)
102
- * [Linked Data](http://rubygems.org/gems/linkeddata) (~> 2.0)
102
+ * [Rack](https://rubygems.org/gems/rack) (~> 2.0)
103
+ * [Linked Data](https://rubygems.org/gems/linkeddata) (~> 3.1)
103
104
 
104
105
  ## Installation
105
106
 
106
- The recommended installation method is via [RubyGems](http://rubygems.org/).
107
+ The recommended installation method is via [RubyGems](https://rubygems.org/).
107
108
  To install the latest official release of the gem, do:
108
109
 
109
110
  % [sudo] gem install rack-linkeddata
@@ -117,7 +118,7 @@ To get a local working copy of the development repository, do:
117
118
  Alternatively, download the latest development version as a tarball as
118
119
  follows:
119
120
 
120
- % wget http://github.com/ruby-rdf/rack-linkeddata/tarball/master
121
+ % wget https://github.com/ruby-rdf/rack-linkeddata/tarball/master
121
122
 
122
123
  ## Contributing
123
124
  This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration.
@@ -132,31 +133,33 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
132
133
  list in the the `README`. Alphabetical order applies.
133
134
  * Do note that in order for us to merge any non-trivial changes (as a rule
134
135
  of thumb, additions larger than about 15 lines of code), we need an
135
- explicit [public domain dedication][PDD] on record from you.
136
+ explicit [public domain dedication][PDD] on record from you,
137
+ which you will be asked to agree to on the first commit to a repo within the organization.
138
+ Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.
136
139
 
137
140
  ## References
138
141
 
139
- * <http://www.w3.org/DesignIssues/LinkedData.html>
140
- * <http://linkeddata.org/docs/how-to-publish>
141
- * <http://linkeddata.org/conneg-303-redirect-code-samples>
142
- * <http://www.w3.org/TR/cooluris/>
143
- * <http://www.w3.org/TR/swbp-vocab-pub/>
144
- * <http://patterns.dataincubator.org/book/publishing-patterns.html>
142
+ * <https://www.w3.org/DesignIssues/LinkedData.html>
143
+ * <https://linkeddata.org/docs/how-to-publish>
144
+ * <https://linkeddata.org/conneg-303-redirect-code-samples>
145
+ * <https://www.w3.org/TR/cooluris/>
146
+ * <https://www.w3.org/TR/swbp-vocab-pub/>
147
+ * <https://patterns.dataincubator.org/book/publishing-patterns.html>
145
148
 
146
149
  ## Authors
147
150
 
148
- * [Arto Bendiken](http://github.com/bendiken) - <http://ar.to/>
149
- * [Gregg Kellogg](http://github.com/gkellogg) - <http://greggkellogg.net/>
151
+ * [Arto Bendiken](https://github.com/artob) - <https://ar.to/>
152
+ * [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
150
153
 
151
154
  ## License
152
155
 
153
156
  This is free and unencumbered public domain software. For more information,
154
- see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
155
-
156
- [Rack]: http://rack.github.com/
157
- [RDF.rb]: http://ruby-rdf.github.com/rdf/
158
- [Linked Data]: http://linkeddata.org/
159
- [conneg]: http://en.wikipedia.org/wiki/Content_negotiation
160
- [YARD]: http://yardoc.org/
161
- [YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
162
- [PDD]: http://unlicense.org/#unlicensing-contributions
157
+ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
158
+
159
+ [Rack]: https://rack.github.com/
160
+ [RDF.rb]: https://ruby-rdf.github.com/rdf/
161
+ [Linked Data]: https://linkeddata.org/
162
+ [conneg]: https://en.wikipedia.org/wiki/Content_negotiation
163
+ [YARD]: https://yardoc.org/
164
+ [YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
165
+ [PDD]: https://unlicense.org/#unlicensing-contributions
data/UNLICENSE CHANGED
@@ -21,4 +21,4 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
21
  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
22
  OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
- For more information, please refer to <http://unlicense.org/>
24
+ For more information, please refer to <https://unlicense.org/>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.2
1
+ 3.1.2
@@ -1,4 +1,4 @@
1
- require 'rack'
1
+ require 'rack/rdf'
2
2
  require 'linkeddata'
3
3
 
4
4
  module Rack
@@ -9,22 +9,11 @@ module Rack
9
9
  ##
10
10
  # Registers all known RDF formats with Rack's MIME types registry.
11
11
  #
12
+ # @param [Boolean] overwrite (false)
12
13
  # @param [Hash{Symbol => Object}] options
13
- # @option options [Boolean] :overwrite (false)
14
14
  # @return [void]
15
- def self.register_mime_types!(options = {})
16
- if defined?(Rack::Mime::MIME_TYPES)
17
- RDF::Format.each do |format|
18
- if !Rack::Mime::MIME_TYPES.has_key?(file_ext = ".#{format.to_sym}") || options[:overwrite]
19
- Rack::Mime::MIME_TYPES.merge!(file_ext => format.content_type.first)
20
- end
21
- end
22
- RDF::Format.file_extensions.each do |file_ext, formats|
23
- if !Rack::Mime::MIME_TYPES.has_key?(file_ext = ".#{file_ext}") || options[:overwrite]
24
- Rack::Mime::MIME_TYPES.merge!(file_ext => formats.first.content_type.first)
25
- end
26
- end
27
- end
15
+ def self.register_mime_types!(overwrite: false, **options)
16
+ Rack::RDF.register_mime_types!(overwrite: overwrite, **options)
28
17
  end
29
18
  end
30
19
  end
@@ -6,7 +6,7 @@ module Rack; module LinkedData
6
6
  # format to serialize any result with a body being `RDF::Enumerable`.
7
7
  #
8
8
  # Override content negotiation by setting the :format option to
9
- # {#initialize}.
9
+ # `#initialize`.
10
10
  #
11
11
  # Add a :default option to set a content type to use when nothing else
12
12
  # is found.
@@ -17,188 +17,7 @@ module Rack; module LinkedData
17
17
  # use Rack::LinkedData::ContentNegotiation, :default => 'application/rdf+xml'
18
18
  #
19
19
  # @see http://www4.wiwiss.fu-berlin.de/bizer/pub/LinkedDataTutorial/
20
- class ContentNegotiation
21
- DEFAULT_CONTENT_TYPE = "application/n-triples" # N-Triples
22
- VARY = {'Vary' => 'Accept'}.freeze
23
-
24
- # @return [#call]
25
- attr_reader :app
26
-
27
- # @return [Hash{Symbol => Object}]
28
- attr_reader :options
29
-
30
- ##
31
- # @param [#call] app
32
- # @param [Hash{Symbol => Object}] options
33
- # Other options passed to writer.
34
- # @option options [String] :default (DEFAULT_CONTENT_TYPE) Specific content type
35
- # @option options [RDF::Format, #to_sym] :format Specific RDF writer format to use
36
- def initialize(app, options = {})
37
- @app, @options = app, options
38
- @options[:default] = (@options[:default] || DEFAULT_CONTENT_TYPE).to_s
39
- end
40
-
41
- ##
42
- # Handles a Rack protocol request.
43
- # Parses Accept header to find appropriate mime-type and sets content_type accordingly.
44
- #
45
- # Inserts ordered content types into the environment as `ORDERED_CONTENT_TYPES` if an Accept header is present
46
- #
47
- # @param [Hash{String => String}] env
48
- # @return [Array(Integer, Hash, #each)]
49
- # @see http://rack.rubyforge.org/doc/SPEC.html
50
- def call(env)
51
- env['ORDERED_CONTENT_TYPES'] = parse_accept_header(env['HTTP_ACCEPT']) if env.has_key?('HTTP_ACCEPT')
52
- response = app.call(env)
53
- body = response[2].respond_to?(:body) ? response[2].body : response[2]
54
- case body
55
- when RDF::Enumerable
56
- response[2] = body # Put it back in the response, it might have been a proxy
57
- serialize(env, *response)
58
- else response
59
- end
60
- end
61
-
62
- ##
63
- # Serializes an `RDF::Enumerable` response into a Rack protocol
64
- # response using HTTP content negotiation rules or a specified Content-Type.
65
- #
66
- # @param [Hash{String => String}] env
67
- # @param [Integer] status
68
- # @param [Hash{String => Object}] headers
69
- # @param [RDF::Enumerable] body
70
- # @return [Array(Integer, Hash, #each)]
71
- def serialize(env, status, headers, body)
72
- begin
73
- writer, content_type = find_writer(env, headers)
74
- if writer
75
- # FIXME: don't overwrite existing Vary headers
76
- headers = headers.merge(VARY).merge('Content-Type' => content_type)
77
- [status, headers, [writer.dump(body, nil, @options)]]
78
- else
79
- not_acceptable
80
- end
81
- rescue RDF::WriterError => e
82
- not_acceptable
83
- end
84
- end
85
-
86
- ##
87
- # Returns an `RDF::Writer` class for the given `env`.
88
- #
89
- # If options contain a `:format` key, it identifies the specific format to use;
90
- # otherwise, if the environment has an HTTP_ACCEPT header, use it to find a writer;
91
- # otherwise, use the default content type
92
- #
93
- # @param [Hash{String => String}] env
94
- # @param [Hash{String => Object}] headers
95
- # @return [Array(Class, String)]
96
- # @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
97
- def find_writer(env, headers)
98
- if @options[:format]
99
- format = @options[:format]
100
- writer = RDF::Writer.for(format.to_sym) unless format.is_a?(RDF::Format)
101
- return [writer, writer.format.content_type.first] if writer
102
- elsif env.has_key?('HTTP_ACCEPT')
103
- content_types = parse_accept_header(env['HTTP_ACCEPT'])
104
- content_types.each do |content_type|
105
- writer, content_type = find_writer_for_content_type(content_type)
106
- return [writer, content_type] if writer
107
- end
108
- return nil
109
- else
110
- # HTTP/1.1 §14.1: "If no Accept header field is present, then it is
111
- # assumed that the client accepts all media types"
112
- find_writer_for_content_type(options[:default])
113
- end
114
- end
115
-
116
- ##
117
- # Returns an `RDF::Writer` class for the given `content_type`.
118
- #
119
- # @param [String, #to_s] content_type
120
- # @return [Array(Class, String)]
121
- def find_writer_for_content_type(content_type)
122
- writer = RDF::Writer.for(content_type: content_type) if content_type
123
- writer ? [writer, content_type] : nil
124
- end
125
-
126
- protected
127
-
128
- ##
129
- # Parses an HTTP `Accept` header, returning an array of MIME content
130
- # types ordered by the precedence rules defined in HTTP/1.1 §14.1.
131
- #
132
- # @param [String, #to_s] header
133
- # @return [Array<String>]
134
- # @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
135
- def parse_accept_header(header)
136
- entries = header.to_s.split(',')
137
- entries = entries.map { |e| accept_entry(e) }.sort_by(&:last).map(&:first)
138
- entries.map { |e| find_content_type_for_media_range(e) }
139
- end
140
-
141
- def accept_entry(entry)
142
- type, *options = entry.delete(' ').split(';')
143
- quality = 0 # we sort smallest first
144
- options.delete_if { |e| quality = 1 - e[2..-1].to_f if e.start_with? 'q=' }
145
- [type, [quality, type.count('*'), 1 - options.size]]
146
- end
147
-
148
- ##
149
- # Returns a content type appropriate for the given `media_range`,
150
- # returns `nil` if `media_range` contains a wildcard subtype
151
- # that is not mapped.
152
- #
153
- # @param [String, #to_s] media_range
154
- # @return [String, nil]
155
- def find_content_type_for_media_range(media_range)
156
- case media_range.to_s
157
- when '*/*'
158
- options[:default]
159
- when 'text/*'
160
- 'text/turtle'
161
- when 'application/*'
162
- 'application/ld+json'
163
- when 'application/json'
164
- 'application/ld+json'
165
- when 'application/xml'
166
- 'application/rdf+xml'
167
- when /^([^\/]+)\/\*$/
168
- nil
169
- else
170
- media_range.to_s
171
- end
172
- end
173
-
174
- ##
175
- # Outputs an HTTP `406 Not Acceptable` response.
176
- #
177
- # @param [String, #to_s] message
178
- # @return [Array(Integer, Hash, #each)]
179
- def not_acceptable(message = nil)
180
- http_error(406, message, VARY)
181
- end
182
-
183
- ##
184
- # Outputs an HTTP `4xx` or `5xx` response.
185
- #
186
- # @param [Integer, #to_i] code
187
- # @param [String, #to_s] message
188
- # @param [Hash{String => String}] headers
189
- # @return [Array(Integer, Hash, #each)]
190
- def http_error(code, message = nil, headers = {})
191
- message = http_status(code) + (message.nil? ? "\n" : " (#{message})\n")
192
- [code, {'Content-Type' => "#{DEFAULT_CONTENT_TYPE}; charset=utf-8"}.merge(headers), [message]]
193
- end
194
-
195
- ##
196
- # Returns the standard HTTP status message for the given status `code`.
197
- #
198
- # @param [Integer, #to_i] code
199
- # @return [String]
200
- def http_status(code)
201
- [code, Rack::Utils::HTTP_STATUS_CODES[code]].join(' ')
202
- end
20
+ # @see https://www.rubydoc.info/github/rack/rack/master/file/SPEC
21
+ class ContentNegotiation < Rack::RDF::ContentNegotiation
203
22
  end # class ContentNegotiation
204
23
  end; end # module Rack::LinkedData
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-linkeddata
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
8
- autorequire:
8
+ - Gregg Kellogg
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-07-31 00:00:00.000000000 Z
12
+ date: 2020-12-26 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: linkeddata
@@ -16,76 +17,96 @@ dependencies:
16
17
  requirements:
17
18
  - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: '2.2'
20
+ version: '3.1'
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 3.1.3
20
24
  type: :runtime
21
25
  prerelease: false
22
26
  version_requirements: !ruby/object:Gem::Requirement
23
27
  requirements:
24
28
  - - "~>"
25
29
  - !ruby/object:Gem::Version
26
- version: '2.2'
30
+ version: '3.1'
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.3
27
34
  - !ruby/object:Gem::Dependency
28
- name: rack
35
+ name: rack-rdf
29
36
  requirement: !ruby/object:Gem::Requirement
30
37
  requirements:
31
- - - ">="
38
+ - - "~>"
32
39
  - !ruby/object:Gem::Version
33
- version: '1.6'
34
- - - "<"
40
+ version: '3.1'
41
+ - - ">="
35
42
  - !ruby/object:Gem::Version
36
- version: '3.0'
43
+ version: 3.1.1
37
44
  type: :runtime
38
45
  prerelease: false
39
46
  version_requirements: !ruby/object:Gem::Requirement
40
47
  requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '3.1'
41
51
  - - ">="
42
52
  - !ruby/object:Gem::Version
43
- version: '1.6'
44
- - - "<"
53
+ version: 3.1.1
54
+ - !ruby/object:Gem::Dependency
55
+ name: rack
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '2.1'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
45
66
  - !ruby/object:Gem::Version
46
- version: '3.0'
67
+ version: '2.1'
47
68
  - !ruby/object:Gem::Dependency
48
69
  name: yard
49
70
  requirement: !ruby/object:Gem::Requirement
50
71
  requirements:
51
72
  - - "~>"
52
73
  - !ruby/object:Gem::Version
53
- version: '0.8'
74
+ version: '0.9'
54
75
  type: :development
55
76
  prerelease: false
56
77
  version_requirements: !ruby/object:Gem::Requirement
57
78
  requirements:
58
79
  - - "~>"
59
80
  - !ruby/object:Gem::Version
60
- version: '0.8'
81
+ version: '0.9'
61
82
  - !ruby/object:Gem::Dependency
62
83
  name: rspec
63
84
  requirement: !ruby/object:Gem::Requirement
64
85
  requirements:
65
86
  - - "~>"
66
87
  - !ruby/object:Gem::Version
67
- version: '3.5'
88
+ version: '3.10'
68
89
  type: :development
69
90
  prerelease: false
70
91
  version_requirements: !ruby/object:Gem::Requirement
71
92
  requirements:
72
93
  - - "~>"
73
94
  - !ruby/object:Gem::Version
74
- version: '3.5'
95
+ version: '3.10'
75
96
  - !ruby/object:Gem::Dependency
76
97
  name: rack-test
77
98
  requirement: !ruby/object:Gem::Requirement
78
99
  requirements:
79
100
  - - "~>"
80
101
  - !ruby/object:Gem::Version
81
- version: '0.6'
102
+ version: '1.1'
82
103
  type: :development
83
104
  prerelease: false
84
105
  version_requirements: !ruby/object:Gem::Requirement
85
106
  requirements:
86
107
  - - "~>"
87
108
  - !ruby/object:Gem::Version
88
- version: '0.6'
109
+ version: '1.1'
89
110
  description: Rack middleware for Linked Data content negotiation.
90
111
  email: public-rdf-ruby@w3.org
91
112
  executables: []
@@ -100,11 +121,11 @@ files:
100
121
  - lib/rack/linkeddata.rb
101
122
  - lib/rack/linkeddata/conneg.rb
102
123
  - lib/rack/linkeddata/version.rb
103
- homepage: http://ruby-rdf.github.com/rack-linkeddata
124
+ homepage: https://github.com/ruby-rdf/rack-linkeddata
104
125
  licenses:
105
126
  - Unlicense
106
127
  metadata: {}
107
- post_install_message:
128
+ post_install_message:
108
129
  rdoc_options: []
109
130
  require_paths:
110
131
  - lib
@@ -112,16 +133,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
133
  requirements:
113
134
  - - ">="
114
135
  - !ruby/object:Gem::Version
115
- version: 2.2.2
136
+ version: '2.4'
116
137
  required_rubygems_version: !ruby/object:Gem::Requirement
117
138
  requirements:
118
139
  - - ">="
119
140
  - !ruby/object:Gem::Version
120
141
  version: '0'
121
142
  requirements: []
122
- rubyforge_project: datagraph
123
- rubygems_version: 2.6.12
124
- signing_key:
143
+ rubygems_version: 3.1.4
144
+ signing_key:
125
145
  specification_version: 4
126
146
  summary: Linked Data content negotiation for Rack applications.
127
147
  test_files: []