qa 5.7.0 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fb01e5ca2c9435b8c22af76ace78a1486d2ad22ee54f0a8e1a40ba24b64e218
4
- data.tar.gz: '0825479f37ac4eb299c944981fff9b670e8efd86eb8b05c3341f7d2a9300361c'
3
+ metadata.gz: 1f4e4d8c917617e8cba95cd8bc8e0f06ebb60c9b580672b3736c717ef1ce3746
4
+ data.tar.gz: bd9624a47e0c513d8b7fdf7a278d2c904867b3331217faaf7951321326f7549d
5
5
  SHA512:
6
- metadata.gz: 80792bf55b1f8cf6f7401657d7b7844fbeff0dbc4e4597e16869a63a65a6cf1e271d88d631bd0dd9f4f8dbcdda2caadac47974d8d282f21ee1696308022bb201
7
- data.tar.gz: 7d700e24566d6047cb061731e941affa72d3c260eb7822c421421986127ddfd819f2d6d4cd1c968cd9e527b3276c392a7403564ebce8e5ee4210fb86863072d0
6
+ metadata.gz: a6f568c19f5aad67ca850bf0d666afd63f971b7bbab83e51b4299791b52c94e93fcae9e49a9ff6aec4d2e8329cf1b41ab39131fa8dc3e0eb0baec5725934499b
7
+ data.tar.gz: 69d1bed451753f68ae20551aa1ac2a77e8acbfffeb2600e42d50726d113f28300c01faaf74af9b65dcfc5a168410019fb99bc84b09928b9846b466fd20fc9e63
data/README.md CHANGED
@@ -152,9 +152,14 @@ If you're working on PR for this project, create a feature branch off of `main`.
152
152
  This repository follows the [Samvera Community Code of Conduct](https://samvera.atlassian.net/wiki/spaces/samvera/pages/405212316/Code+of+Conduct) and [language recommendations](https://github.com/samvera/maintenance/blob/main/templates/CONTRIBUTING.md#language). Please ***do not*** create a branch called `master` for this repository or as part of your pull request; the branch will either need to be removed or renamed before it can be considered for inclusion in the code base and history of this repository.
153
153
 
154
154
  ## Compatibility
155
-
156
- - Ruby 2.5 or the latest 2.4 version is recommended. Later versions may also work.
157
- - Rails 5 is required. We recommend the latest Rails 5.2 release.
155
+ This gem works with Rails 5.0-6.1 and Ruby 2.5-3.1, provided the version of Rails supports the version of Ruby.
156
+ - Consult `.circleci/config.yml` for a list of supported combinations.
157
+ - The combination of Ruby 3.1 and Rails 6.0 comes with three caveats:
158
+ - your app will not be able to use `psych 4` (which ordinarily comes with 3.1). See https://bugs.ruby-lang.org/issues/17866 and https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias/71192990#71192990 for an explanation. One workaround is to modify your app's `Gemfile` to hold back `psych`: `gem 'psych', '< 4'`.
159
+ - likewise, you want to add gem 'net-smtp', require: false to your Gemfile to get around the bug described in https://stackoverflow.com/questions/70500220/rails-7-ruby-3-1-loaderror-cannot-load-such-file-net-smtp .
160
+ - finally, you may want to opt in to the latest version of "mail". Again, add to your Gemfile the line `gem "mail", ">= 2.8.0.rc1"`.
161
+
162
+ See also `.circleci/config.yml` and `spec/test_app_templates/Gemfile.extra`.
158
163
 
159
164
  ## Product Owner & Maintenance
160
165
 
@@ -4,6 +4,9 @@
4
4
  # same methods.
5
5
 
6
6
  class Qa::TermsController < ::ApplicationController
7
+ class_attribute :pagination_service_class
8
+ self.pagination_service_class = Qa::PaginationService
9
+
7
10
  before_action :check_vocab_param, :init_authority
8
11
  before_action :check_query_param, only: :search
9
12
 
@@ -23,7 +26,11 @@ class Qa::TermsController < ::ApplicationController
23
26
  def search
24
27
  terms = @authority.method(:search).arity == 2 ? @authority.search(url_search, self) : @authority.search(url_search)
25
28
  cors_allow_origin_header(response)
26
- render json: terms
29
+ respond_to do |wants|
30
+ wants.json { render json: pagination_service(format: :json, results: terms).build_response }
31
+ wants.jsonapi { render json: pagination_service(format: :jsonapi, results: terms).build_response }
32
+ wants.any { render json: pagination_service(format: :json, results: terms).build_response, content_type: json_content_type }
33
+ end
27
34
  end
28
35
 
29
36
  # If the subauthority supports it, return all the information for a given term
@@ -31,7 +38,13 @@ class Qa::TermsController < ::ApplicationController
31
38
  def show
32
39
  term = @authority.method(:find).arity == 2 ? @authority.find(params[:id], self) : @authority.find(params[:id])
33
40
  cors_allow_origin_header(response)
34
- render json: term, content_type: content_type_for_format
41
+ respond_to do |wants|
42
+ wants.json { render json: term }
43
+ wants.n3 { render json: term }
44
+ wants.jsonld { render json: term }
45
+ wants.ntriples { render json: term }
46
+ wants.any { render json: term, content_type: json_content_type }
47
+ end
35
48
  end
36
49
 
37
50
  # If the subauthority supports it, return all the information for a given term
@@ -39,7 +52,13 @@ class Qa::TermsController < ::ApplicationController
39
52
  def fetch
40
53
  term = @authority.method(:find).arity == 2 ? @authority.find(params[:uri], self) : @authority.find(params[:uri])
41
54
  cors_allow_origin_header(response)
42
- render json: term, content_type: content_type_for_format
55
+ respond_to do |wants|
56
+ wants.json { render json: term }
57
+ wants.n3 { render json: term }
58
+ wants.jsonld { render json: term }
59
+ wants.ntriples { render json: term }
60
+ wants.any { render json: term, content_type: json_content_type }
61
+ end
43
62
  end
44
63
 
45
64
  def check_vocab_param
@@ -90,28 +109,11 @@ class Qa::TermsController < ::ApplicationController
90
109
  params[:q].gsub("*", "%2A")
91
110
  end
92
111
 
93
- def format
94
- return 'json' unless params.key?(:format)
95
- return 'json' if params[:format].blank?
96
- params[:format]
97
- end
98
-
99
- def jsonld?
100
- format.casecmp?('jsonld')
101
- end
102
-
103
- def n3?
104
- format.casecmp?('n3')
105
- end
106
-
107
- def ntriples?
108
- format.casecmp?('ntriples')
112
+ def json_content_type
113
+ Mime::Type.lookup_by_extension(:json).to_str
109
114
  end
110
115
 
111
- def content_type_for_format
112
- return 'application/ld+json' if jsonld?
113
- return 'text/n3' if n3?
114
- return 'application/n-triples' if ntriples?
115
- 'application/json'
116
+ def pagination_service(results:, format:)
117
+ pagination_service_class.new(request: request, results: results, format: format)
116
118
  end
117
119
  end
@@ -57,7 +57,7 @@ module Qa
57
57
  def deep_copy(graph:)
58
58
  new_graph = RDF::Graph.new
59
59
  graph.statements.each do |st|
60
- new_graph.insert(st.dup)
60
+ new_graph << st.dup
61
61
  end
62
62
  new_graph
63
63
  end