qa 5.5.2 → 5.8.1

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: 427d2d24aab8a8c5a9453dd96aa0f677143ec993f98efb098fdb772c5b5ba429
4
- data.tar.gz: 7d71a7cfa524b2d12a7b657e11fc0144db1795b48c65690391fc81a5ec2f93af
3
+ metadata.gz: a7529be1fa8e0db065216d3fd303c3db02c739ede3ffed6ca0d56cda3b0d8bc5
4
+ data.tar.gz: ae2e1179e435d2cc82f6c8e068c413cfb6cf0e3fdee0a478fff4eccfff82b64c
5
5
  SHA512:
6
- metadata.gz: c5c375b7b54a7e08f7eff73a473542d36a748ebb0298bad65a91b06177479861d762cdf79d08c72a453fa44df8b94094524bd94a03105bbeb3975873e4a299bc
7
- data.tar.gz: 205775aa62254267b41f07f6bb3ec5b7f5d5a5f684a70742182b6edc3e77eb406066d6ce829b61f24780d624b7d609fe75832b844bca7e9bf8d2051cfa00517e
6
+ metadata.gz: 05b1ea7d2611b2fd349d070171a9856059ae0c0a5ea8dfab12fcdddab55e76b6a0939c6e451e3c7852f6bdf782e3aff8f2dda0c2f8c043a2a61c9407c7a76fce
7
+ data.tar.gz: 0454fd9d3ce8663f9cc3e00e4a922cca3b33c6657213448f40de9b7601fb553b236dd822f1b8e5fb196ca91b1e7973134950003f52f4d33153c1e8e6c36b0517
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Questioning Authority
2
2
 
3
- Code: [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa) [![Build Status](https://circleci.com/gh/samvera/questioning_authority.svg?style=svg)](https://circleci.com/gh/samvera/questioning_authority) [![Coverage Status](https://coveralls.io/repos/github/samvera/questioning_authority/badge.svg?branch=master)](https://coveralls.io/github/samvera/questioning_authority?branch=master)
3
+ Code: [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa) [![Build Status](https://circleci.com/gh/samvera/questioning_authority.svg?style=svg)](https://circleci.com/gh/samvera/questioning_authority) [![Coverage Status](https://coveralls.io/repos/github/samvera/questioning_authority/badge.svg?branch=main)](https://coveralls.io/github/samvera/questioning_authority?branch=main)
4
4
 
5
5
  Docs: [![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md) [![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE)
6
6
 
@@ -145,6 +145,12 @@ rake ci
145
145
 
146
146
  Commit your features into a new branch and submit a pull request.
147
147
 
148
+ ## Contributing
149
+
150
+ If you're working on PR for this project, create a feature branch off of `main`.
151
+
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
+
148
154
  ## Compatibility
149
155
 
150
156
  - Ruby 2.5 or the latest 2.4 version is recommended. Later versions may also work.
@@ -169,7 +175,7 @@ Questioning Authority is a Core Component of the Samvera community. The document
169
175
  github_changelog_generator --user samvera --project questioning_authority --token YOUR_GITHUB_TOKEN_HERE
170
176
  ```
171
177
 
172
- 5. Commit these changes to the master branch
178
+ 5. Commit these changes to the main branch
173
179
 
174
180
  6. Run `rake release`
175
181
 
@@ -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,14 +26,39 @@ 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
37
+ # Expects id to be part of the request path (e.g. http://my.app/qa/show/auth/subauth/{:id})
30
38
  def show
31
39
  term = @authority.method(:find).arity == 2 ? @authority.find(params[:id], self) : @authority.find(params[:id])
32
40
  cors_allow_origin_header(response)
33
- 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
48
+ end
49
+
50
+ # If the subauthority supports it, return all the information for a given term
51
+ # Expects uri to be a request parameter (e.g. http://my.app/qa/show/auth/subauth?uri={:uri})
52
+ def fetch
53
+ term = @authority.method(:find).arity == 2 ? @authority.find(params[:uri], self) : @authority.find(params[:uri])
54
+ cors_allow_origin_header(response)
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
34
62
  end
35
63
 
36
64
  def check_vocab_param
@@ -81,28 +109,11 @@ class Qa::TermsController < ::ApplicationController
81
109
  params[:q].gsub("*", "%2A")
82
110
  end
83
111
 
84
- def format
85
- return 'json' unless params.key?(:format)
86
- return 'json' if params[:format].blank?
87
- params[:format]
88
- end
89
-
90
- def jsonld?
91
- format.casecmp?('jsonld')
92
- end
93
-
94
- def n3?
95
- format.casecmp?('n3')
96
- end
97
-
98
- def ntriples?
99
- format.casecmp?('ntriples')
112
+ def json_content_type
113
+ Mime::Type.lookup_by_extension(:json).to_str
100
114
  end
101
115
 
102
- def content_type_for_format
103
- return 'application/ld+json' if jsonld?
104
- return 'text/n3' if n3?
105
- return 'application/n-triples' if ntriples?
106
- 'application/json'
116
+ def pagination_service(results:, format:)
117
+ pagination_service_class.new(request: request, results: results, format: format)
107
118
  end
108
119
  end