rhino_project_core 0.22.0.beta.6 → 0.22.0.beta.8

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: 5b642fee59635a246c0176684fafeea2361dbe9018ee49cc7de781fff41a4f32
4
- data.tar.gz: 3b458fc37810a55c6c924781d684d039c6c6365a152c3afb0abdf9cf4e82a612
3
+ metadata.gz: f54e1669b65fa817188b36995dae407ea469e2f15ed292aa6f4069c5fd18e09b
4
+ data.tar.gz: 834416790be435047018d619bdcc545e56ddedbb2ec6d41e4be99ca84bfd431e
5
5
  SHA512:
6
- metadata.gz: 4182c3a6e0fed89f86233a5438c4505e1436451a3b8f7543fc8968f114eea5f7d5ddf281214cb345daa86e88358e357cb9ecc747b65d92f416cd8052f80c3678
7
- data.tar.gz: 7ba2325b3a48ef9939e3ace9dfa4dac2e0fc471c9885533729d6e7ef808434d9267d7f698cafaa66b6d467479842dc46295a74a24137c2e15a7c9c57b557313b
6
+ metadata.gz: 0b6ed6842c45fb9e7f4f7e7448580b65d3a8b844b37358361aa94f56395d88c4d633fee067c660c625acb2a66841006dc357720566eda29f241f5885912ee56b
7
+ data.tar.gz: 1aa828bd050676ad74a9a9841d6d6209d1345010e2dbead6f134b20967c3433659b49e653ade50c8b190db9a03b107af3d8f7136dacb7089791713299aea62cf
@@ -11,15 +11,30 @@ module Rhino
11
11
  included do
12
12
  attribute :url
13
13
  attribute :url_attachment
14
+ attribute :variants, :json, default: {}
14
15
 
15
16
  rhino_policy :active_storage_attachment
16
17
 
17
- def url
18
- Rails.application.routes.url_helpers.rails_blob_url(self, only_path: false)
18
+ def url(attachment = self, **options)
19
+ Rails.application.routes.url_helpers.rails_blob_url(attachment, only_path: false, **options)
19
20
  end
20
21
 
21
- def url_attachment
22
- Rails.application.routes.url_helpers.rails_blob_url(self, only_path: false, disposition: :attachment)
22
+ def url_attachment(attachment = self)
23
+ url(attachment, disposition: :attachment)
24
+ end
25
+
26
+ def variants
27
+ # Not everything may be processed into a variant based on mime type
28
+ return unless variable?
29
+
30
+ record.attachment_reflections[self.name]&.named_variants&.keys&.index_with do |v|
31
+ variant = variant(v)
32
+
33
+ {
34
+ url: url(variant),
35
+ url_attachment: url_attachment(variant)
36
+ }
37
+ end
23
38
  end
24
39
 
25
40
  def display_name
@@ -29,7 +44,7 @@ module Rhino
29
44
 
30
45
  class_methods do
31
46
  def readable_properties
32
- super + ["signed_id"]
47
+ super + [ "variants", "signed_id"]
33
48
  end
34
49
  end
35
50
 
@@ -3,17 +3,23 @@
3
3
  module Rhino
4
4
  module Sieve
5
5
  class Limit
6
- attr_accessor :default_limit
6
+ attr_accessor :default_limit, :max_limit
7
7
 
8
- def initialize(app, default_limit: 20)
8
+ def initialize(app, default_limit: 20, max_limit: 100)
9
9
  @app = app
10
10
 
11
11
  @default_limit = default_limit
12
+ @max_limit = max_limit
12
13
  end
13
14
 
14
15
  # limit=20
15
16
  def resolve(scope, params)
16
- @app.resolve(scope.limit(params[:limit] || default_limit), params)
17
+ # If we get a non-nil limit param we try and construct it as an integer
18
+ # Otherwise we use the default
19
+ param_limit = params[:limit].nil? ? default_limit : params[:limit].to_i
20
+
21
+ # Don't allow a limit above the max_limit
22
+ @app.resolve(scope.limit([param_limit, max_limit].min), params)
17
23
  end
18
24
  end
19
25
  end
data/lib/rhino/version.rb CHANGED
@@ -10,7 +10,7 @@ module Rhino
10
10
  MAJOR = 0
11
11
  MINOR = 22
12
12
  TINY = 0
13
- PRE = "beta.6"
13
+ PRE = "beta.8"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhino_project_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0.beta.6
4
+ version: 0.22.0.beta.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Rosevear
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-06 00:00:00.000000000 Z
11
+ date: 2024-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails