pura-image 0.2.1 → 0.2.3

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: e67c74a5ee27e265efd6ce9621bef2838393940e99f2e19f3a34d59d982492b6
4
- data.tar.gz: 689df3f568672052b8953b9e6bf2414be3a09323b64a8c81eb516dbed147e100
3
+ metadata.gz: a6561b3b8ec72933d8b01613638ae8e767e3948c402831bf8f401c9985525990
4
+ data.tar.gz: 386ef6ed67ed028cb82e630859826b7c4d43689c93923b96141febd65b0f0cfd
5
5
  SHA512:
6
- metadata.gz: 6b2e8ade06a4eeb25e453fc2afc11648e3037a31831c83add3ecfe52525187a5dd1c83ce34d3f386376d0e97563d2ede5de6deeac04b414401018f6b7bb759c3
7
- data.tar.gz: 41a7b2e0b035289ff632a5f85a5363b3cc5c3d8cfae51cfd5eceb306845b1caef437f4fab15816f8c04ef18a77c924ba48c786eb4412c56c42c75dac0679bd07
6
+ metadata.gz: 82d791ee984e2d7d014ac2a3f62c8cbfa9ad59135b2a06c0c10d2ca86ae401c57ac271520a1828a590f251a1f8e8bc51748dd8e09b41d766dbe9aad00c3c6b8b
7
+ data.tar.gz: 65cd7a61332dd414f53f3f12366c23844292b955ac5e032675871af36e68c5a96de54c7d84d2c40df26680768d0e794b8e8c977295fec53cf5e634c5292211b6
@@ -19,7 +19,7 @@ module Pura
19
19
  end
20
20
 
21
21
  def grayscale
22
- new_pixels = String.new(encoding: Encoding::BINARY, capacity: @pixels.bytesize)
22
+ new_pixels = String.new(encoding: Encoding::BINARY)
23
23
  i = 0
24
24
  size = @pixels.bytesize
25
25
  while i < size
@@ -98,7 +98,7 @@ module Pura
98
98
  def rotate90
99
99
  new_w = @height
100
100
  new_h = @width
101
- new_pixels = String.new(encoding: Encoding::BINARY, capacity: new_w * new_h * 3)
101
+ new_pixels = String.new(encoding: Encoding::BINARY)
102
102
 
103
103
  new_h.times do |y|
104
104
  new_w.times do |x|
@@ -111,7 +111,7 @@ module Pura
111
111
  end
112
112
 
113
113
  def rotate180
114
- new_pixels = String.new(encoding: Encoding::BINARY, capacity: @pixels.bytesize)
114
+ new_pixels = String.new(encoding: Encoding::BINARY)
115
115
  (@height - 1).downto(0) do |y|
116
116
  (@width - 1).downto(0) do |x|
117
117
  offset = ((y * @width) + x) * 3
@@ -124,7 +124,7 @@ module Pura
124
124
  def rotate270
125
125
  new_w = @height
126
126
  new_h = @width
127
- new_pixels = String.new(encoding: Encoding::BINARY, capacity: new_w * new_h * 3)
127
+ new_pixels = String.new(encoding: Encoding::BINARY)
128
128
 
129
129
  new_h.times do |y|
130
130
  new_w.times do |x|
@@ -1,42 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rails/railtie"
4
-
5
- module Pura
6
- module Image
7
- class Railtie < Rails::Railtie
8
- initializer "pura_image.set_variant_processor", before: "active_storage.configs" do |app|
9
- app.config.active_storage.variant_processor = :pura
10
- end
3
+ # Only define railtie if Rails is available
4
+ if defined?(Rails)
5
+ require "rails/railtie"
6
+
7
+ module Pura
8
+ module Image
9
+ class Railtie < Rails::Railtie
10
+ initializer "pura_image.set_variant_processor", before: "active_storage.configs" do |app|
11
+ app.config.active_storage.variant_processor = :pura
12
+ end
11
13
 
12
- initializer "pura_image.patch_active_storage_variation" do
13
- ActiveSupport.on_load(:active_storage_blob) do
14
- require "image_processing/pura"
14
+ initializer "pura_image.patch_active_storage_variation" do
15
+ ActiveSupport.on_load(:active_storage_blob) do
16
+ require "image_processing/pura"
15
17
 
16
- variation_patch = Module.new do
17
- private
18
+ variation_patch = Module.new do
19
+ private
18
20
 
19
- def transformer
20
- if ActiveStorage.variant_processor == :pura && ActiveStorage.variant_transformer.nil?
21
- @pura_transformer ||= begin
22
- klass = Class.new(ActiveStorage::Transformers::ImageProcessingTransformer) do
23
- private
21
+ def transformer
22
+ if ActiveStorage.variant_processor == :pura && ActiveStorage.variant_transformer.nil?
23
+ @pura_transformer ||= begin
24
+ klass = Class.new(ActiveStorage::Transformers::ImageProcessingTransformer) do
25
+ private
24
26
 
25
- def processor
26
- ImageProcessing::Pura
27
+ def processor
28
+ ImageProcessing::Pura
29
+ end
27
30
  end
28
- end
29
31
 
30
- klass.new(transformations.except(:format))
32
+ klass.new(transformations.except(:format))
33
+ end
34
+ else
35
+ super
31
36
  end
32
- else
33
- super
34
37
  end
35
38
  end
36
- end
37
39
 
38
- unless ActiveStorage::Variation.ancestors.include?(variation_patch)
39
- ActiveStorage::Variation.prepend(variation_patch)
40
+ unless ActiveStorage::Variation.ancestors.include?(variation_patch)
41
+ ActiveStorage::Variation.prepend(variation_patch)
42
+ end
40
43
  end
41
44
  end
42
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pura
4
4
  module Image
5
- VERSION = "0.2.1"
5
+ VERSION = "0.2.3"
6
6
  end
7
7
  end
data/pura-image.gemspec CHANGED
@@ -13,12 +13,12 @@ Gem::Specification.new do |spec|
13
13
  "with image_processing gem compatible API for Rails Active Storage."
14
14
  spec.homepage = "https://github.com/komagata/pura-image"
15
15
  spec.license = "MIT"
16
- spec.required_ruby_version = ">= 3.0.0"
16
+ spec.required_ruby_version = ">= 3.2.0"
17
17
 
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = spec.homepage
20
20
 
21
- spec.files = Dir["lib/**/*.rb"] + ["pura-image.gemspec", "Gemfile", "Rakefile", "README.md", "LICENSE"]
21
+ spec.files = Dir["lib/**/*.rb"] + ["test/fixtures/test_64x64.jpg"] + ["pura-image.gemspec", "Gemfile", "Rakefile", "README.md", "LICENSE"]
22
22
 
23
23
  spec.add_dependency "pura-jpeg", "~> 0.1"
24
24
  spec.add_dependency "pura-png", "~> 0.1"
@@ -26,8 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "pura-gif", "~> 0.1"
27
27
  spec.add_dependency "pura-tiff", "~> 0.1"
28
28
  spec.add_dependency "pura-ico", "~> 0.1"
29
-
30
- spec.add_development_dependency "image_processing", "~> 1.2"
29
+ spec.add_dependency "image_processing", "~> 1.2"
31
30
  spec.add_development_dependency "minitest", "~> 5.0"
32
31
  spec.add_development_dependency "rake", "~> 13.0"
33
32
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pura-image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - komagata
@@ -100,7 +100,7 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '1.2'
103
- type: :development
103
+ type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
@@ -154,6 +154,7 @@ files:
154
154
  - lib/pura/image/railtie.rb
155
155
  - lib/pura/image/version.rb
156
156
  - pura-image.gemspec
157
+ - test/fixtures/test_64x64.jpg
157
158
  homepage: https://github.com/komagata/pura-image
158
159
  licenses:
159
160
  - MIT
@@ -167,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
168
  requirements:
168
169
  - - ">="
169
170
  - !ruby/object:Gem::Version
170
- version: 3.0.0
171
+ version: 3.2.0
171
172
  required_rubygems_version: !ruby/object:Gem::Requirement
172
173
  requirements:
173
174
  - - ">="