next_gen_images 0.1.0 → 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: d036a649a224dfa3fd151e5e245f5810e1e25d99f98777ae9b3db696d3022392
4
- data.tar.gz: aae969d7879faa41ea7e47f1107866d204ad0937ec07236e28ebbf45a86ede8b
3
+ metadata.gz: 1d9ba63a5eb1dc12bfbdd8e5604144dff1ed7c93c9643401b9d144847b5ffb01
4
+ data.tar.gz: ceada02f709811e4e9cb87c6014e1c6dcd1d8a049ac6e861b19441651e020f49
5
5
  SHA512:
6
- metadata.gz: 51a469c51f54459115a8358665bae628e11a0a8fc97b781484a7197e21636768d0fce2310f3ae101145d3a6607eeaf24c51c8b915ba6d740f77188cd45c2a16c
7
- data.tar.gz: dab440a1384baa2a02512e1922b8450e400d0489ccc1c27683574e74f25227ec9af1121b7bab56a04678f0d5591dc772c4e9fb2cf71e6ac6154d0d4dcdefbd55
6
+ metadata.gz: 1ff61bf7de48a53620dfce5146f6df612078981c769622601040ca4a2af288cd4d6b1700eac74cb91e5e41297b7886a9331a45ed39d6127f64362ce307c9260a
7
+ data.tar.gz: 68645e21ab7e37e1b766f0e914c679732791c6db9474b8bfd82b4609f48b92952e761e2426f5157264b52bac4a50163995eff5340467d782d0ac99f2d2bc5bca
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- next_gen_images (0.1.0)
4
+ next_gen_images (1.1.0)
5
5
  rails (>= 3.1)
6
6
  webp-ffi (~> 0.3.1)
7
7
 
@@ -87,13 +87,14 @@ GEM
87
87
  ssrf_filter (~> 1.0)
88
88
  concurrent-ruby (1.1.10)
89
89
  crass (1.0.6)
90
+ date (3.3.3)
90
91
  diff-lcs (1.5.0)
91
- erubi (1.11.0)
92
+ erubi (1.12.0)
92
93
  ffi (1.15.5)
93
94
  ffi-compiler (1.0.1)
94
95
  ffi (>= 1.0.0)
95
96
  rake
96
- globalid (1.0.0)
97
+ globalid (1.1.0)
97
98
  activesupport (>= 5.0)
98
99
  i18n (1.12.0)
99
100
  concurrent-ruby (~> 1.0)
@@ -101,36 +102,38 @@ GEM
101
102
  mini_magick (>= 4.9.5, < 5)
102
103
  ruby-vips (>= 2.0.17, < 3)
103
104
  json (2.6.2)
104
- loofah (2.19.0)
105
+ loofah (2.21.3)
105
106
  crass (~> 1.0.2)
106
- nokogiri (>= 1.5.9)
107
- mail (2.7.1)
107
+ nokogiri (>= 1.12.0)
108
+ mail (2.8.1)
108
109
  mini_mime (>= 0.1.1)
110
+ net-imap
111
+ net-pop
112
+ net-smtp
109
113
  marcel (1.0.2)
110
114
  method_source (1.0.0)
111
115
  mini_magick (4.12.0)
112
116
  mini_mime (1.1.2)
113
117
  minitest (5.16.3)
114
- net-imap (0.3.1)
118
+ net-imap (0.3.4)
119
+ date
115
120
  net-protocol
116
121
  net-pop (0.1.2)
117
122
  net-protocol
118
- net-protocol (0.1.3)
123
+ net-protocol (0.2.1)
119
124
  timeout
120
- net-smtp (0.3.2)
125
+ net-smtp (0.3.3)
121
126
  net-protocol
122
- nio4r (2.5.8)
123
- nokogiri (1.13.8-arm64-darwin)
124
- racc (~> 1.4)
125
- nokogiri (1.13.8-x86_64-linux)
127
+ nio4r (2.5.9)
128
+ nokogiri (1.15.2-arm64-darwin)
126
129
  racc (~> 1.4)
127
130
  parallel (1.22.1)
128
131
  parser (3.1.2.1)
129
132
  ast (~> 2.4.1)
130
133
  public_suffix (5.0.1)
131
- racc (1.6.0)
132
- rack (2.2.4)
133
- rack-test (2.0.2)
134
+ racc (1.6.2)
135
+ rack (2.2.7)
136
+ rack-test (2.1.0)
134
137
  rack (>= 1.3)
135
138
  rails (7.0.4)
136
139
  actioncable (= 7.0.4)
@@ -149,8 +152,8 @@ GEM
149
152
  rails-dom-testing (2.0.3)
150
153
  activesupport (>= 4.2.0)
151
154
  nokogiri (>= 1.6)
152
- rails-html-sanitizer (1.4.3)
153
- loofah (~> 2.3)
155
+ rails-html-sanitizer (1.5.0)
156
+ loofah (~> 2.19, >= 2.19.1)
154
157
  railties (7.0.4)
155
158
  actionpack (= 7.0.4)
156
159
  activesupport (= 7.0.4)
@@ -193,8 +196,8 @@ GEM
193
196
  ruby-vips (2.1.4)
194
197
  ffi (~> 1.12)
195
198
  ssrf_filter (1.1.1)
196
- thor (1.2.1)
197
- timeout (0.3.0)
199
+ thor (1.2.2)
200
+ timeout (0.3.2)
198
201
  tzinfo (2.0.5)
199
202
  concurrent-ruby (~> 1.0)
200
203
  unicode-display_width (2.3.0)
@@ -204,7 +207,7 @@ GEM
204
207
  websocket-driver (0.7.5)
205
208
  websocket-extensions (>= 0.1.0)
206
209
  websocket-extensions (0.1.5)
207
- zeitwerk (2.6.1)
210
+ zeitwerk (2.6.8)
208
211
 
209
212
  PLATFORMS
210
213
  arm64-darwin-21
data/README.md CHANGED
@@ -105,6 +105,43 @@ rake assets:webp
105
105
  Assets will be compiled to `public/assets/` or the path that you specifed in `Rails.application.config.assets.prefix`.
106
106
  The file names of the generated image assets will be in the format:`OLD_IMAGE.OLD_EXTENSION.webp`
107
107
 
108
+ ### ActiveStorage integration
109
+
110
+ If you are using ActiveStorage you will need to first enable the `image_processing` gem. Usually, uncommenting this from your Gemfile:
111
+ ```
112
+ gem "image_processing", "~> 1.2"
113
+ ```
114
+
115
+ Then, you will need to install the VIPS image processing library binaries. Check the [VIPS Ruby wrapper gem](https://github.com/libvips/ruby-vips) for installation instructions for your OS.
116
+
117
+ Finally, in `application.rb` configure ActiveStorage to use VIPS:
118
+
119
+ ```ruby
120
+ config.active_storage.variant_processor = :vips
121
+ ```
122
+
123
+ You are ready to start using WebP variants in your models like this:
124
+
125
+ ```ruby
126
+ class User < ApplicationRecord
127
+ has_one_attached :avatar do |attachable|
128
+ attachable.variant :small, resize_to_limit: [400, 400]
129
+ attachable.variant :webp, {
130
+ convert: :webp,
131
+ format: :webp,
132
+ saver: { quality: 80 }
133
+ }
134
+ attachable.variant :webp_small, {
135
+ resize_to_limit: [400, 400],
136
+ convert: :webp,
137
+ format: :webp,
138
+ saver: { quality: 80 }
139
+ }
140
+ end
141
+ end
142
+ ```
143
+
144
+
108
145
  ### Carrierwave integration
109
146
 
110
147
  A `convert_to_webp` method that converts images to WebP is provided. You can send any encoding option available to [webp-ffi](https://github.com/le0pard/webp-ffi#encode-webp-image).
@@ -115,7 +152,7 @@ Example Uploader class:
115
152
  class ImageUploader < CarrierWave::Uploader::Base
116
153
  include NextGenImages::CarrierwaveHelpers
117
154
 
118
- version :small, from_version: :medium do
155
+ version :small do
119
156
  process resize_to_fit: [400, 400]
120
157
  end
121
158
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NextGenImages
4
- VERSION = '0.1.0'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -31,13 +31,13 @@ module NextGenImages
31
31
 
32
32
  content = ''.html_safe
33
33
  if block.present?
34
- content += capture(&block).html_safe
34
+ content << capture(&block).html_safe
35
35
  else
36
36
  [source].flatten.each do |img_src|
37
- content += build_source_from_img(image_path(img_src), add_webp)
37
+ content << build_source_from_img(image_path(img_src), add_webp)
38
38
  end
39
39
  end
40
- content += tag('img', image_options)
40
+ content << tag('img', image_options)
41
41
  end
42
42
 
43
43
  def build_img_src(source)
@@ -56,7 +56,7 @@ module NextGenImages
56
56
  webp_path = "#{img_path}.webp"
57
57
  # order of source tags matters
58
58
  if add_webp && file_exist_in_public_path?(webp_path)
59
- source_tags += source_tag(srcset: webp_path, type: 'image/webp')
59
+ source_tags << source_tag(srcset: webp_path, type: 'image/webp')
60
60
  end
61
61
  source_tags + source_tag(
62
62
  srcset: img_path,
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require 'webp-ffi'
2
3
 
3
4
  require_relative 'next_gen_images/version'
4
5
  require_relative 'next_gen_images/railtie' if defined?(Rails)
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/next_gen_images/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'next_gen_images'
7
+ spec.version = NextGenImages::VERSION
8
+ spec.authors = ['JP Balarini']
9
+ spec.email = ['jp@eagerworks.com']
10
+
11
+ spec.summary = 'Handle next-gen image formats in your Ruby on Rails project. WebP is currently supported'
12
+ spec.description = 'Adds support for a picture_tag and several utilities to automatically convert images to WebP'
13
+ spec.homepage = 'https://eagerworks.com'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 2.6.0'
16
+
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/eagerworks/next_gen_images'
21
+ spec.metadata['rubygems_mfa_required'] = 'true'
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = 'exe'
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ['lib']
33
+
34
+ spec.add_runtime_dependency 'rails', '>= 3.1'
35
+ spec.add_runtime_dependency 'webp-ffi', '~> 0.3.1'
36
+ spec.add_development_dependency 'bundler'
37
+ spec.add_development_dependency 'carrierwave', '>= 2.0'
38
+ spec.add_development_dependency 'rspec', '~> 3.12.0'
39
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.17.1'
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: next_gen_images
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Balarini
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-19 00:00:00.000000000 Z
11
+ date: 2023-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -116,6 +116,7 @@ files:
116
116
  - lib/next_gen_images/tasks/assets/webp.rake
117
117
  - lib/next_gen_images/version.rb
118
118
  - lib/next_gen_images/view_helpers.rb
119
+ - next_gen_images.gemspec
119
120
  - sig/next_gen_images.rbs
120
121
  homepage: https://eagerworks.com
121
122
  licenses: