paperclip-vips 1.0.1 → 1.1.0

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: 63602051cfbe3b16594382670e89a02c80556e81c2c784c347b2f5aac8a249a8
4
- data.tar.gz: a474e9c00ec8505915ed84e9d2221e2a63ebef2b18a7c56042f3066d971abbf5
3
+ metadata.gz: 25b4601f012a9e1916a415fb83af8ea29e4f5d0a1a961bdd2a8780fb9eb09891
4
+ data.tar.gz: 07e04b8e2b8de1bdef06679ccfd759a1e13d88ad7c5a739710c9903e857297e4
5
5
  SHA512:
6
- metadata.gz: eeaed4e84227d859bfc7fa599aa3cad2ec60fec4dded3fb5cc0eb7f23e45d57211d8ed4b42f7bfd6b7fd55647d0ec5c994ada9185bd10d66da680e67936412fd
7
- data.tar.gz: 598322f555a1545a3eb8ff1a0c8eaaaedb741313deee6fa05f0469562d7eab09c33864156d0f639d7ab5e643b0c3779125b77cbf43fcc57edac39b1d0bc50e6d
6
+ metadata.gz: 78c286fd9428cee69a9c9e87edf2808e45eebd611f1e87e2cb48bb0f554548d82c1ddfd78dcaffc6de621cae4095bbdf257327cf0dc7330dc741169f36d2d16e
7
+ data.tar.gz: 8e1349c141065d91940c6ef4b504ea9bfd8e11dcf139f73b92304e9f8ca55436e43346bc8301e24f1d63a00e34590b48a881d799ce4740d0bf8e27808204f2fe
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .byebug_history
13
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paperclip-vips (1.0.0)
5
- paperclip (>= 5.2.1)
4
+ paperclip-vips (1.1.0)
5
+ paperclip (>= 5.0.0)
6
6
  ruby-vips (~> 2.0.13)
7
7
 
8
8
  GEM
@@ -15,6 +15,7 @@ GEM
15
15
  i18n (>= 0.7, < 2)
16
16
  minitest (~> 5.1)
17
17
  tzinfo (~> 1.1)
18
+ byebug (11.0.1)
18
19
  climate_control (0.2.0)
19
20
  concurrent-ruby (1.1.5)
20
21
  diff-lcs (1.3)
@@ -59,6 +60,7 @@ PLATFORMS
59
60
 
60
61
  DEPENDENCIES
61
62
  bundler (~> 2.0)
63
+ byebug (~> 11.0)
62
64
  paperclip-vips!
63
65
  rake (~> 10.0)
64
66
  rspec (~> 3.0)
@@ -12,20 +12,12 @@ module Paperclip
12
12
  @current_geometry = options.fetch(:file_geometry_parser, Geometry).from_file(@file)
13
13
  @whiny = options.fetch(:whiny, true)
14
14
 
15
- @current_format = File.extname(@file.path)&.downcase
15
+ @current_format = current_format(file).downcase
16
16
  @format = options[:format] || @current_format
17
17
 
18
18
  @basename = File.basename(@file.path, @current_format)
19
19
  end
20
20
 
21
- def crop
22
- if @should_crop
23
- return @options[:crop] || :centre
24
- end
25
-
26
- nil
27
- end
28
-
29
21
  def make
30
22
  source = @file
31
23
  filename = [@basename, @format ? ".#{@format}" : ""].join
@@ -47,46 +39,65 @@ module Paperclip
47
39
  return destination
48
40
  end
49
41
 
50
- def width
51
- @target_geometry&.width || @current_geometry.width
52
- end
53
-
54
- def height
55
- @target_geometry&.height || @current_geometry.height
56
- end
57
-
58
- def process_convert_options(image)
59
- if image && @options[:convert_options].present?
60
- commands = JSON.parse(@options[:convert_options], symbolize_names: true)
61
- commands.each do |cmd|
62
- image = ::Vips::Operation.call(cmd[:cmd], [image, *cmd[:args]], cmd[:optional] || {})
42
+ private
43
+ def crop
44
+ if @should_crop
45
+ return @options[:crop] || :centre
63
46
  end
47
+
48
+ nil
64
49
  end
65
50
 
66
- return image
67
- end
51
+ def current_format(file)
52
+ extension = File.extname(file.path)
53
+ return extension if extension.present?
68
54
 
69
- def save_thumbnail(thumbnail, path)
70
- case @current_format
71
- when ".jpeg", ".jpg"
72
- save_jpg(thumbnail, path)
73
- when ".gif"
74
- save_gif(thumbnail, path)
75
- when ".png"
76
- save_png(thumbnail, path)
55
+ extension = File.extname(file.original_filename)
56
+ return extension if extension.present?
57
+
58
+ return ""
77
59
  end
78
- end
79
60
 
80
- def save_jpg(thumbnail, path)
81
- thumbnail.jpegsave(path)
82
- end
61
+ def width
62
+ @target_geometry&.width || @current_geometry.width
63
+ end
83
64
 
84
- def save_gif(thumbnail, path)
85
- thumbnail.magicksave(path)
86
- end
65
+ def height
66
+ @target_geometry&.height || @current_geometry.height
67
+ end
68
+
69
+ def process_convert_options(image)
70
+ if image && @options[:convert_options].present?
71
+ commands = JSON.parse(@options[:convert_options], symbolize_names: true)
72
+ commands.each do |cmd|
73
+ image = ::Vips::Operation.call(cmd[:cmd], [image, *cmd[:args]], cmd[:optional] || {})
74
+ end
75
+ end
87
76
 
88
- def save_png(thumbnail, path)
89
- thumbnail.pngsave(path)
90
- end
77
+ return image
78
+ end
79
+
80
+ def save_thumbnail(thumbnail, path)
81
+ case @current_format
82
+ when ".jpeg", ".jpg"
83
+ save_jpg(thumbnail, path)
84
+ when ".gif"
85
+ save_gif(thumbnail, path)
86
+ when ".png"
87
+ save_png(thumbnail, path)
88
+ end
89
+ end
90
+
91
+ def save_jpg(thumbnail, path)
92
+ thumbnail.jpegsave(path)
93
+ end
94
+
95
+ def save_gif(thumbnail, path)
96
+ thumbnail.magicksave(path)
97
+ end
98
+
99
+ def save_png(thumbnail, path)
100
+ thumbnail.pngsave(path)
101
+ end
91
102
  end
92
103
  end
@@ -1,3 +1,3 @@
1
1
  module PaperclipVips
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "bundler", "~> 2.0"
29
29
  spec.add_development_dependency "rake", "~> 10.0"
30
30
  spec.add_development_dependency "rspec", "~> 3.0"
31
+ spec.add_development_dependency "byebug", "~> 11.0"
31
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-vips
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Greeff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-31 00:00:00.000000000 Z
11
+ date: 2019-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paperclip
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '11.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '11.0'
83
97
  description:
84
98
  email:
85
99
  - ken@kengreeff.com
@@ -101,7 +115,6 @@ files:
101
115
  - lib/paperclip-vips.rb
102
116
  - lib/paperclip-vips/paperclip/vips.rb
103
117
  - lib/paperclip-vips/version.rb
104
- - paperclip-vips-1.0.0.gem
105
118
  - paperclip-vips.gemspec
106
119
  homepage: https://github.com/realhub/paperclip-vips
107
120
  licenses:
Binary file