rack-linkeddata 2.2.1 → 3.1.1

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: c6f256b9f4c6c2ca900800412440bfe3c4fe2109
4
- data.tar.gz: 42dddfa7e2be4edfc3e023bcdffcdd4949dcee40
2
+ SHA256:
3
+ metadata.gz: f4916ce1f8a73781907fee891b1a7ea31a1c1ff950a79087df54a7aa01abdf9a
4
+ data.tar.gz: 5c4bd1edde8f839fa980abc2d55050727587b2525fe870434b47d500c82dd74c
5
5
  SHA512:
6
- metadata.gz: a309c4379b535569527cfd056707b93a37f42dbbeb82f1a78e18d3d05e105bffa7007b9a2b09147d84df6f34d4f4d476b6e8adc04ee74083bbfe1a6614ef23e7
7
- data.tar.gz: 2cd8c4237b8068a5ba950b9681d7f5860da93e588e0f3424711b3e293300ae1d72ecad835e6ede5ba9ebb1c79a167a1209ef038e7b103f89f801523c5c505da5
6
+ metadata.gz: 7b879aaf4e1dde88deae05cf38d8f775673274e9a90ba314fba2b686215ce2fce8efdecbab3ad7fd47e51673b38204202b04c13b3e8e401eeb3ad5b3751464f0
7
+ data.tar.gz: ba38a8c789cdb8e266e6319a406cbb83ba1900292aabed3e1e08056a9f0dceac83e3585a90c0f485e1b86c04775a24dac8f48eff10b05cf2c99e7c37c066fdef
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,15 @@ 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://travis-ci.org/ruby-rdf/rack-linkeddata.png?branch=master)](https://travis-ci.org/ruby-rdf/rack-linkeddata)
12
12
 
13
13
  ## Features
14
14
 
15
15
  * Implements [HTTP content negotiation][conneg] for RDF content types.
16
- * Supports all [RDF.rb][]-compatible serialization formats.
16
+ * Supports all [RDF.rb][] compatible serialization formats.
17
17
  * Compatible with any Rack application and any Rack-based framework.
18
18
 
19
19
  ## Examples
@@ -91,19 +91,19 @@ for N-Triples, N-Quads, Turtle, RDF/XML, RDF/JSON, JSON-LD, RDFa, TriG and TriX.
91
91
 
92
92
  ##Documentation
93
93
 
94
- <http://http://rubydoc.info/github/ruby-rdf/rack-linkeddata/>
94
+ <https://rubydoc.info/github/ruby-rdf/rack-linkeddata/>
95
95
 
96
96
  * {Rack::LinkedData}
97
97
  * {Rack::LinkedData::ContentNegotiation}
98
98
 
99
99
  ## Dependencies
100
100
 
101
- * [Rack](http://rubygems.org/gems/rack) (~> 1.6)
102
- * [Linked Data](http://rubygems.org/gems/linkeddata) (~> 2.0)
101
+ * [Rack](https://rubygems.org/gems/rack) (~> 2.0)
102
+ * [Linked Data](https://rubygems.org/gems/linkeddata) (~> 3.1)
103
103
 
104
104
  ## Installation
105
105
 
106
- The recommended installation method is via [RubyGems](http://rubygems.org/).
106
+ The recommended installation method is via [RubyGems](https://rubygems.org/).
107
107
  To install the latest official release of the gem, do:
108
108
 
109
109
  % [sudo] gem install rack-linkeddata
@@ -117,7 +117,7 @@ To get a local working copy of the development repository, do:
117
117
  Alternatively, download the latest development version as a tarball as
118
118
  follows:
119
119
 
120
- % wget http://github.com/ruby-rdf/rack-linkeddata/tarball/master
120
+ % wget https://github.com/ruby-rdf/rack-linkeddata/tarball/master
121
121
 
122
122
  ## Contributing
123
123
  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.
@@ -136,27 +136,27 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
136
136
 
137
137
  ## References
138
138
 
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>
139
+ * <https://www.w3.org/DesignIssues/LinkedData.html>
140
+ * <https://linkeddata.org/docs/how-to-publish>
141
+ * <https://linkeddata.org/conneg-303-redirect-code-samples>
142
+ * <https://www.w3.org/TR/cooluris/>
143
+ * <https://www.w3.org/TR/swbp-vocab-pub/>
144
+ * <https://patterns.dataincubator.org/book/publishing-patterns.html>
145
145
 
146
146
  ## Authors
147
147
 
148
- * [Arto Bendiken](http://github.com/bendiken) - <http://ar.to/>
149
- * [Gregg Kellogg](http://github.com/gkellogg) - <http://greggkellogg.net/>
148
+ * [Arto Bendiken](https://github.com/artob) - <https://ar.to/>
149
+ * [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
150
150
 
151
151
  ## License
152
152
 
153
153
  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
154
+ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
155
+
156
+ [Rack]: https://rack.github.com/
157
+ [RDF.rb]: https://ruby-rdf.github.com/rdf/
158
+ [Linked Data]: https://linkeddata.org/
159
+ [conneg]: https://en.wikipedia.org/wiki/Content_negotiation
160
+ [YARD]: https://yardoc.org/
161
+ [YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
162
+ [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.1
1
+ 3.1.1
@@ -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,168 +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 = case content_type.to_s
123
- when '*/*'
124
- RDF::Writer.for(:content_type => (content_type = options[:default]))
125
- when /^([^\/]+)\/\*$/
126
- nil # TODO: match subtype wildcards
127
- else
128
- RDF::Writer.for(:content_type => content_type)
129
- end
130
- writer ? [writer, content_type] : nil
131
- end
132
-
133
- protected
134
-
135
- ##
136
- # Parses an HTTP `Accept` header, returning an array of MIME content
137
- # types ordered by the precedence rules defined in HTTP/1.1 §14.1.
138
- #
139
- # @param [String, #to_s] header
140
- # @return [Array<String>]
141
- # @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
142
- def parse_accept_header(header)
143
- entries = header.to_s.split(',')
144
- entries.map { |e| accept_entry(e) }.sort_by(&:last).map(&:first)
145
- end
146
-
147
- def accept_entry(entry)
148
- type, *options = entry.delete(' ').split(';')
149
- quality = 0 # we sort smallest first
150
- options.delete_if { |e| quality = 1 - e[2..-1].to_f if e.start_with? 'q=' }
151
- [type, [quality, type.count('*'), 1 - options.size]]
152
- end
153
-
154
- ##
155
- # Outputs an HTTP `406 Not Acceptable` response.
156
- #
157
- # @param [String, #to_s] message
158
- # @return [Array(Integer, Hash, #each)]
159
- def not_acceptable(message = nil)
160
- http_error(406, message, VARY)
161
- end
162
-
163
- ##
164
- # Outputs an HTTP `4xx` or `5xx` response.
165
- #
166
- # @param [Integer, #to_i] code
167
- # @param [String, #to_s] message
168
- # @param [Hash{String => String}] headers
169
- # @return [Array(Integer, Hash, #each)]
170
- def http_error(code, message = nil, headers = {})
171
- message = http_status(code) + (message.nil? ? "\n" : " (#{message})\n")
172
- [code, {'Content-Type' => "#{DEFAULT_CONTENT_TYPE}; charset=utf-8"}.merge(headers), [message]]
173
- end
174
-
175
- ##
176
- # Returns the standard HTTP status message for the given status `code`.
177
- #
178
- # @param [Integer, #to_i] code
179
- # @return [String]
180
- def http_status(code)
181
- [code, Rack::Utils::HTTP_STATUS_CODES[code]].join(' ')
182
- end
20
+ # @see https://www.rubydoc.info/github/rack/rack/master/file/SPEC
21
+ class ContentNegotiation < Rack::RDF::ContentNegotiation
183
22
  end # class ContentNegotiation
184
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.1
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
8
+ - Gregg Kellogg
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-06-24 00:00:00.000000000 Z
12
+ date: 2020-05-30 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: linkeddata
@@ -16,76 +17,90 @@ dependencies:
16
17
  requirements:
17
18
  - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: '2.0'
20
+ version: '3.1'
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 3.1.2
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.0'
30
+ version: '3.1'
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.2
27
34
  - !ruby/object:Gem::Dependency
28
- name: rack
35
+ name: rack-rdf
29
36
  requirement: !ruby/object:Gem::Requirement
30
37
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '1.6'
34
- - - "<"
38
+ - - "~>"
35
39
  - !ruby/object:Gem::Version
36
- version: '3.0'
40
+ version: '3.1'
37
41
  type: :runtime
38
42
  prerelease: false
39
43
  version_requirements: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ">="
45
+ - - "~>"
42
46
  - !ruby/object:Gem::Version
43
- version: '1.6'
44
- - - "<"
47
+ version: '3.1'
48
+ - !ruby/object:Gem::Dependency
49
+ name: rack
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.1'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
45
60
  - !ruby/object:Gem::Version
46
- version: '3.0'
61
+ version: '2.1'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: yard
49
64
  requirement: !ruby/object:Gem::Requirement
50
65
  requirements:
51
66
  - - "~>"
52
67
  - !ruby/object:Gem::Version
53
- version: '0.8'
68
+ version: '0.9'
54
69
  type: :development
55
70
  prerelease: false
56
71
  version_requirements: !ruby/object:Gem::Requirement
57
72
  requirements:
58
73
  - - "~>"
59
74
  - !ruby/object:Gem::Version
60
- version: '0.8'
75
+ version: '0.9'
61
76
  - !ruby/object:Gem::Dependency
62
77
  name: rspec
63
78
  requirement: !ruby/object:Gem::Requirement
64
79
  requirements:
65
80
  - - "~>"
66
81
  - !ruby/object:Gem::Version
67
- version: '3.5'
82
+ version: '3.9'
68
83
  type: :development
69
84
  prerelease: false
70
85
  version_requirements: !ruby/object:Gem::Requirement
71
86
  requirements:
72
87
  - - "~>"
73
88
  - !ruby/object:Gem::Version
74
- version: '3.5'
89
+ version: '3.9'
75
90
  - !ruby/object:Gem::Dependency
76
91
  name: rack-test
77
92
  requirement: !ruby/object:Gem::Requirement
78
93
  requirements:
79
94
  - - "~>"
80
95
  - !ruby/object:Gem::Version
81
- version: '0.6'
96
+ version: '1.1'
82
97
  type: :development
83
98
  prerelease: false
84
99
  version_requirements: !ruby/object:Gem::Requirement
85
100
  requirements:
86
101
  - - "~>"
87
102
  - !ruby/object:Gem::Version
88
- version: '0.6'
103
+ version: '1.1'
89
104
  description: Rack middleware for Linked Data content negotiation.
90
105
  email: public-rdf-ruby@w3.org
91
106
  executables: []
@@ -100,7 +115,7 @@ files:
100
115
  - lib/rack/linkeddata.rb
101
116
  - lib/rack/linkeddata/conneg.rb
102
117
  - lib/rack/linkeddata/version.rb
103
- homepage: http://ruby-rdf.github.com/rack-linkeddata
118
+ homepage: https://github.com/ruby-rdf/rack-linkeddata
104
119
  licenses:
105
120
  - Unlicense
106
121
  metadata: {}
@@ -112,15 +127,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
127
  requirements:
113
128
  - - ">="
114
129
  - !ruby/object:Gem::Version
115
- version: 2.2.2
130
+ version: '2.4'
116
131
  required_rubygems_version: !ruby/object:Gem::Requirement
117
132
  requirements:
118
133
  - - ">="
119
134
  - !ruby/object:Gem::Version
120
135
  version: '0'
121
136
  requirements: []
122
- rubyforge_project: datagraph
123
- rubygems_version: 2.6.12
137
+ rubygems_version: 3.1.3
124
138
  signing_key:
125
139
  specification_version: 4
126
140
  summary: Linked Data content negotiation for Rack applications.