Skip to content

Commit 3062214

Browse files
committed
fix rubocop moaning
1 parent bd045b6 commit 3062214

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

example/inheritance_with_refcount.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def set_debug debug
2121

2222
module Libc
2323
extend FFI::Library
24+
2425
ffi_lib FFI::Library::LIBC
2526

2627
attach_function :malloc, [:size_t], :pointer
@@ -29,6 +30,7 @@ module Libc
2930

3031
module GLib
3132
extend FFI::Library
33+
3234
ffi_lib "gobject-2.0"
3335

3436
def self.set_log_domain(_domain)
@@ -142,6 +144,7 @@ def ffi_managed_struct
142144

143145
module Vips
144146
extend FFI::Library
147+
145148
ffi_lib "vips"
146149

147150
LOG_DOMAIN = "VIPS"

lib/vips/image.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,7 @@ def get_fields
822822
def get_gainmap
823823
if Vips.at_least_libvips?(8, 18)
824824
vi = Vips.vips_image_get_gainmap self
825-
return nil if vi.null?
826-
Image.new(vi)
827-
else
828-
nil
825+
Image.new(vi) unless vi.null?
829826
end
830827
end
831828

lib/vips/mutableimage.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module Vips
1212
# {Vips::Image#mutate}.
1313
class MutableImage < Vips::Object
1414
extend Forwardable
15+
1516
alias_method :parent_get_typeof, :get_typeof
1617
def_instance_delegators :@image, :width, :height, :bands, :format,
1718
:interpretation, :filename, :xoffset, :yoffset, :xres, :yres, :size,

spec/image_spec.rb

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -729,21 +729,26 @@
729729
# added in 8.18
730730
if Vips.respond_to? :vips_image_get_gainmap
731731
it "can modify gainmaps" do
732-
image = Vips::Image.new_from_file simg "ultra-hdr.jpg"
733732
# test the example code in image.rb doc comment for get_gainmap
734-
gainmap = image.get_gainmap
735-
unless gainmap.nil?
736-
new_gainmap = gainmap.crop 0, 0, 10, 10
737-
image = image.mutate do |x|
738-
x.set_type! Vips::IMAGE_TYPE, "gainmap", new_gainmap
733+
def modify_gainmap image
734+
gainmap = image.get_gainmap
735+
unless gainmap.nil?
736+
new_gainmap = gainmap.crop 0, 0, 10, 10
737+
image = image.mutate do |x|
738+
x.set_type! Vips::IMAGE_TYPE, "gainmap", new_gainmap
739+
end
739740
end
740-
741-
buffer = image.write_to_buffer ".jpg"
742-
image = Vips::Image.new_from_buffer buffer, ""
743-
new_gainmap2 = image.get_gainmap
744-
745-
expect(new_gainmap2.width).to eq(10)
741+
742+
image
746743
end
744+
745+
image = Vips::Image.new_from_file simg "ultra-hdr.jpg"
746+
image = modify_gainmap image
747+
buffer = image.write_to_buffer ".jpg"
748+
image2 = Vips::Image.new_from_buffer buffer, ""
749+
gainmap2 = image2.get_gainmap
750+
751+
expect(gainmap2.width).to eq(10)
747752
end
748753
end
749754

0 commit comments

Comments
 (0)