linked_rails 0.0.4.pre.gc866c1806 → 0.0.4.pre.gd8464437f

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
2
  SHA256:
3
- metadata.gz: c7b4b4fa0d60ccdcc20d5a6d8ef0349f5297df898edbe43b1e01b60ecbac0c1d
4
- data.tar.gz: 2bfa506972dcd36d90eae54db4042894b5ef93555d54a4b8e3c74182f85fbd60
3
+ metadata.gz: d0469495fc05ef96aed75db4a9a3f1cf7e1ed7dfed36760c6960d370369515c1
4
+ data.tar.gz: f3ed8428a3ca3421c43cb6e702a3353eedfb5bcc09db67a85670ebf37cbd8aaa
5
5
  SHA512:
6
- metadata.gz: 95a82ed0863b9073d1103338e6945984fb3e8743b500a3358e90b9092e394d8fad34584d0d0f86da1c8ffac25c4539544066de4c0e7adc59a8758ccf590923fc
7
- data.tar.gz: a6143d72aac114b0892e20bd22d992c823fd98d9670f3cf46000aadff007b6d95c448a1388ea8432a98146931b4962e062b41a976c0dadffa1d86d1ab34290d3
6
+ metadata.gz: 52a4634ca24036a3281671d4829ba527ccc5790c6e4c6d87bfc2b3208f88c3d00ca8db0370b4aeffc8d77da8629058999a6677923a002c5f5680a30d4cd89f1e
7
+ data.tar.gz: 4d48f8396c5a5209fbf9373362cca8efc693493ec650034359119d9a39809a9ba2511af80aa8820c3439aaf5156f143608e4361b3def860cc33119db180cb93c
@@ -98,8 +98,6 @@ module LinkedRails
98
98
  params = param.permit(:include, :iri)
99
99
  params[:iri] = URI(params[:iri])
100
100
  params
101
- rescue URI::InvalidURIError
102
- params.except(:iri)
103
101
  end
104
102
 
105
103
  def resource_response_body(iri, rack_body, status)
@@ -163,17 +161,13 @@ module LinkedRails
163
161
 
164
162
  resource_response(
165
163
  iri,
166
- body: response_from_resource_body(include, iri, resource, status),
164
+ body: include && status == 200 ? resource_body(resource) : nil,
167
165
  cache: resource_cache_control(resource.try(:cacheable?), status, resource_policy),
168
166
  language: I18n.locale,
169
167
  status: status
170
168
  )
171
169
  end
172
170
 
173
- def response_from_resource_body(include, _iri, resource, status)
174
- include && status == 200 ? resource_body(resource) : nil
175
- end
176
-
177
171
  def term_from_vocab(iri)
178
172
  vocab = Vocab.for(iri)
179
173
  tag = iri.to_s.split(vocab.to_s).last
@@ -251,7 +245,7 @@ module LinkedRails
251
245
 
252
246
  def sanitized_relative_path(iri) # rubocop:disable Metrics/AbcSize
253
247
  iri.path = "#{iri.path}/" unless iri.path&.ends_with?('/')
254
- uri = URI(LinkedRails.iri.path.chomp('/').present? ? iri.to_s.split("#{LinkedRails.iri.path}/").last : iri)
248
+ uri = URI(LinkedRails.iri.path.present? ? iri.to_s.split("#{LinkedRails.iri.path}/").last : iri)
255
249
 
256
250
  [uri.path, uri.query].compact.join('?')
257
251
  end
@@ -187,7 +187,7 @@ module LinkedRails
187
187
 
188
188
  def target_url_fallback # rubocop:disable Metrics/AbcSize
189
189
  base = (resource.try(:singular_resource?) ? resource.singular_iri : resource.iri).dup
190
- base.path = "#{base.path.chomp('/')}/#{target_path}" if target_path.present?
190
+ base.path = "#{base.path}/#{target_path}" if target_path.present?
191
191
  base.query = Rack::Utils.parse_nested_query(base.query).merge(target_query).to_param if target_query.present?
192
192
  base
193
193
  end
@@ -8,9 +8,8 @@ module LinkedRails
8
8
  include LinkedRails::Model
9
9
 
10
10
  attr_accessor :collection, :filter
11
- delegate :apply_scope, :association_base, :association_class, :child_resource, :default_page_size, :display,
12
- :include_members,:parent, :policy, :total_page_count, :unfiltered_collection, :user_context,
13
- to: :collection
11
+ delegate :apply_scope, :association_base, :association_class, :default_page_size, :display, :include_members,
12
+ :parent, :policy, :total_page_count, :unfiltered_collection, :user_context, to: :collection
14
13
  delegate :count, to: :members
15
14
 
16
15
  alias id iri
@@ -9,7 +9,7 @@ module LinkedRails
9
9
  Storage.hset(
10
10
  :persistent,
11
11
  :manifest,
12
- URL.as_href(LinkedRails.iri) => web_manifest.to_json
12
+ LinkedRails.iri.to_s => web_manifest.to_json
13
13
  )
14
14
  end
15
15
 
@@ -41,7 +41,7 @@ module LinkedRails
41
41
  def blob_preview_iri
42
42
  return unless ActiveStorage::Blob.service.present?
43
43
 
44
- "#{LinkedRails.iri(path: 'rails/active_storage/blobs/redirect')}/{signed_id}/preview"
44
+ LinkedRails.iri(path: 'rails/active_storage/blobs/redirect/{signed_id}/preview')
45
45
  end
46
46
 
47
47
  def blob_upload_iri
@@ -138,7 +138,7 @@ module LinkedRails
138
138
 
139
139
  def web_manifest_sw_section
140
140
  {
141
- src: "#{scope.chomp('/')}/sw.js",
141
+ src: "#{scope}/sw.js",
142
142
  scope: scope
143
143
  }
144
144
  end
@@ -161,19 +161,19 @@ module LinkedRails
161
161
 
162
162
  class << self
163
163
  def destroy(iri)
164
- Storage.hdel(:persistent, :manifest, URL.as_href(iri))
164
+ Storage.hdel(:persistent, :manifest, iri)
165
165
  end
166
166
 
167
167
  def move(from, to)
168
168
  Storage.hset(
169
169
  :persistent,
170
170
  :redirect_prefix,
171
- URL.as_href(from) => URL.as_href(to)
171
+ from => to
172
172
  )
173
173
 
174
- data = Storage.hget(:persistent, :manifest, URL.as_href(from))
174
+ data = Storage.hget(:persistent, :manifest, from)
175
175
 
176
- Storage.hset(:persistent, :manifest, URL.as_href(to), data) if data
176
+ Storage.hset(:persistent, :manifest, to, data) if data
177
177
 
178
178
  destroy(from)
179
179
  end
@@ -81,7 +81,7 @@ module LinkedRails
81
81
  parent = parent_from_params(params, user_context)
82
82
  return if parent.blank?
83
83
 
84
- parent.try(:menu_sequence)
84
+ parent.menu_sequence
85
85
  end
86
86
  end
87
87
  end
@@ -58,10 +58,7 @@ module LinkedRails
58
58
  end
59
59
 
60
60
  def new_resource_from_parent
61
- if requested_resource.is_a?(LinkedRails.collection_class) ||
62
- requested_resource.is_a?(LinkedRails.collection_view_class)
63
- return requested_resource.child_resource
64
- end
61
+ return requested_resource.child_resource if requested_resource.is_a?(Collection)
65
62
 
66
63
  parent_resource.build_child(
67
64
  controller_class,
@@ -38,7 +38,7 @@ module LinkedRails
38
38
  params = Rails.application.routes.recognize_path(iri.to_s, method: method)
39
39
 
40
40
  route_params_to_opts(params.merge(query), iri.to_s)
41
- rescue ActionController::RoutingError, SystemStackError
41
+ rescue ActionController::RoutingError
42
42
  EMPTY_IRI_OPTS.dup
43
43
  end
44
44
 
@@ -62,7 +62,6 @@ module LinkedRails
62
62
  iri = root_relative_iri.dup
63
63
  iri.scheme = LinkedRails.scheme
64
64
  iri.host = LinkedRails.host
65
- iri.path = iri.path.presence || '/'
66
65
  iri
67
66
  end
68
67
 
data/lib/linked_rails.rb CHANGED
@@ -54,10 +54,8 @@ module LinkedRails
54
54
  @@scheme ||= Rails.application.routes.default_url_options[:protocol] || :http # rubocop:disable Style/ClassVars
55
55
  end
56
56
 
57
- def iri(**args)
58
- opts = {scheme: LinkedRails.scheme, host: LinkedRails.host}.merge(args)
59
- opts[:path] = opts[:path].presence || '/'
60
- RDF::URI.new(**opts)
57
+ def iri(**opts)
58
+ RDF::URI.new(**{scheme: LinkedRails.scheme, host: LinkedRails.host}.merge(opts))
61
59
  end
62
60
  end
63
61
 
@@ -108,5 +106,4 @@ require 'linked_rails/routes'
108
106
  require 'linked_rails/serializer'
109
107
  require 'linked_rails/translate'
110
108
  require 'linked_rails/railtie'
111
- require 'linked_rails/url'
112
109
  require 'linked_rails/storage'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linked_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.pre.gc866c1806
4
+ version: 0.0.4.pre.gd8464437f
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Dingemans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-22 00:00:00.000000000 Z
11
+ date: 2022-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_response
@@ -429,7 +429,6 @@ files:
429
429
  - lib/linked_rails/translate.rb
430
430
  - lib/linked_rails/types/iri_type.rb
431
431
  - lib/linked_rails/uri_template.rb
432
- - lib/linked_rails/url.rb
433
432
  - lib/linked_rails/version.rb
434
433
  - lib/linked_rails/vocab.rb
435
434
  - lib/nill_class_renderer.rb
@@ -1,11 +0,0 @@
1
- module LinkedRails
2
- class URL
3
- class << self
4
- def as_href(url)
5
- uri = URI(url)
6
- uri.path = uri.path.presence || '/'
7
- uri.to_s
8
- end
9
- end
10
- end
11
- end