tramway-core 1.17.7.2 → 1.17.8

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: ea351fe0ccc735e8df8c11efd9136b6f5d3287b0bd9d7d0e98fe94bd74c9b070
4
- data.tar.gz: 11ea49c81f3ace9ffc97f4b3396ba52ce7d61135dbc50eb621e2ccbca342d05a
3
+ metadata.gz: eeac1ff8281b7c5e6dd665fbe2916cd3f2bc917d90a203ac361729c305016711
4
+ data.tar.gz: ef749f395fb09fccba8acc35a842a1f390ae62274d345c108966aa1ea1f024b6
5
5
  SHA512:
6
- metadata.gz: 26bd97b39c3494f4d7356905397f5ec68d3fce0cecb839a4d731efdbe81a80da6e48f1bd8bb50528cd530cc500a580c1752df3991f992f807963aa51c77482c2
7
- data.tar.gz: 435a9723200273b1c857c668c144b26d07183f422c97f2c1aead5134ab38ae660fe09042de475b77b937b76ac2f8498fe0cdf09f04b64a44c7765c5b96b52fb8
6
+ metadata.gz: 86ce9b156c732ecdab742176ffe56af75c2fbc80f3d84bad3c50ac6c30491d0ff190118b6a64b58f732f17f673ffb060c9eff70bb7cd28589bd2be0cd082bf3b
7
+ data.tar.gz: ed9043ffbe86655297870364278f43e54680bdfbc34f860827189e0f365c8268b032ec6936dcefe3cbf2491dc56d66bf672700c08d9f565c58e5d1a4f4f6e43f
@@ -42,6 +42,15 @@ class Tramway::Core::ApplicationRecord < ActiveRecord::Base
42
42
  def search_by(*attributes, **associations)
43
43
  pg_search_scope :full_text_search, against: attributes, associated_against: associations
44
44
  end
45
+
46
+ def uploader(attribute_name, uploader_name, **options)
47
+ mount_uploader attribute_name, "#{uploader_name.to_s.camelize}Uploader".constantize
48
+ @versions = options[:versions] if uploader_name == :photo
49
+ end
50
+
51
+ def photo_versions
52
+ @versions
53
+ end
45
54
  end
46
55
 
47
56
  # FIXME: detect inhertited locales
@@ -20,29 +20,14 @@ class PhotoUploader < ApplicationUploader
20
20
  super && width.present? && height.present?
21
21
  end
22
22
 
23
- version :medium do
23
+ version :medium, if: :medium_version_is_needed? do
24
24
  process resize_to_fill: [400, 400]
25
25
  end
26
26
 
27
- version :small do
27
+ version :small, if: :small_version_is_needed? do
28
28
  process resize_to_fill: [100, 100]
29
29
  end
30
30
 
31
- # FIXME: move to tramway-landing uploader
32
- version :card do
33
- process resize_to_fill: [400, 400, 'North']
34
- end
35
-
36
- # FIXME: move to tramway-landing uploader
37
- version :horizontal do
38
- process resize_to_fill: [800, 350, 'North']
39
- end
40
-
41
- # FIXME: move to tramway-landing uploader
42
- version :mini do
43
- process resize_to_limit: [300, nil]
44
- end
45
-
46
31
  attr_reader :width, :height
47
32
 
48
33
  before :cache, :capture_size
@@ -58,4 +43,16 @@ class PhotoUploader < ApplicationUploader
58
43
  @width, @height = `identify -format "%wx %h" #{file.path}`.split(/x/).map(&:to_i)
59
44
  end
60
45
  end
46
+
47
+ def medium_version_is_needed?(_new_file)
48
+ version_is_needed? :medium
49
+ end
50
+
51
+ def small_version_is_needed?(_new_file)
52
+ version_is_needed? :small
53
+ end
54
+
55
+ def version_is_needed?(version)
56
+ model.class.photo_versions.include? version
57
+ end
61
58
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Core
5
- VERSION = '1.17.7.2'
5
+ VERSION = '1.17.8'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.7.2
4
+ version: 1.17.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-19 00:00:00.000000000 Z
12
+ date: 2020-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: audited