ruby-vips 2.0.15 → 2.0.16

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: f840e3348f61c24e35a7edaf8110e04c80d554ca0941e1a2657e42a5e7d9c585
4
- data.tar.gz: 914ae65523b71d0703e0dadcb0a864d89dbf15c4177fd98b3d440e84023b31ec
3
+ metadata.gz: d671129c93cfb4105aec4736c4caf7898c93f1ab088ee4a97b4a5189a924501e
4
+ data.tar.gz: 8c34c01cbb010805fced2d1677c814055c2856708d9e2175bbe4a016d2c32993
5
5
  SHA512:
6
- metadata.gz: 173ff890370fb1a4fdc70f5ab6ecb4622995a855494c5b46ff3aa2b1ef74415e1c39d9b20773e42b2e01dd520cdb6d59a00abc2a54d34a670b503d811cee8aa8
7
- data.tar.gz: fdc9235e39d693067d4e2ac3f327bce3b71d98ed170a8946ec12626599f274485d4ebd71fdacf837122d34b6da08cabe1b0f31e530a36e3cf548e7b498179880
6
+ metadata.gz: 70ccc45f4aa940db1e5959a50ae1e998415e9ad0ed7e8cd92726fc905a5a1ad22d530739fdd2192957464e3e96242400db29c644dbe815a741d1047211348cad
7
+ data.tar.gz: 0ce3050e2fc3ef1d4729881087b29eaa88c53960195a4b45e50fab4f618d50a2b9d50ac22ce72e433d0cad33f913f378f664a392faa7913a68db844549ed7412
@@ -1,12 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-06-12 17:59:17 +0100 using RuboCop version 0.71.0.
3
+ # on 2019-10-02 15:42:13 +0100 using RuboCop version 0.75.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 43
9
+ # Offense count: 42
10
10
  # Cop supports --auto-correct.
11
11
  # Configuration parameters: EnforcedStyle, IndentationWidth.
12
12
  # SupportedStyles: with_first_argument, with_fixed_indentation
@@ -39,7 +39,7 @@ Lint/UselessComparison:
39
39
 
40
40
  # Offense count: 7
41
41
  Metrics/AbcSize:
42
- Max: 114
42
+ Max: 113
43
43
 
44
44
  # Offense count: 6
45
45
  # Configuration parameters: CountComments, ExcludedMethods.
@@ -50,25 +50,25 @@ Metrics/BlockLength:
50
50
  # Offense count: 3
51
51
  # Configuration parameters: CountComments.
52
52
  Metrics/ClassLength:
53
- Max: 518
53
+ Max: 515
54
54
 
55
55
  # Offense count: 6
56
56
  Metrics/CyclomaticComplexity:
57
- Max: 28
57
+ Max: 27
58
58
 
59
- # Offense count: 12
59
+ # Offense count: 11
60
60
  # Configuration parameters: CountComments, ExcludedMethods.
61
61
  Metrics/MethodLength:
62
- Max: 150
62
+ Max: 128
63
63
 
64
64
  # Offense count: 1
65
65
  # Configuration parameters: CountComments.
66
66
  Metrics/ModuleLength:
67
- Max: 150
67
+ Max: 131
68
68
 
69
69
  # Offense count: 4
70
70
  Metrics/PerceivedComplexity:
71
- Max: 32
71
+ Max: 31
72
72
 
73
73
  # Offense count: 9
74
74
  Naming/AccessorMethodName:
@@ -133,48 +133,17 @@ Style/BlockDelimiters:
133
133
  - 'lib/vips.rb'
134
134
  - 'lib/vips/operation.rb'
135
135
 
136
- # Offense count: 6
137
- # Cop supports --auto-correct.
138
- # Configuration parameters: EnforcedStyle.
139
- # SupportedStyles: braces, no_braces, context_dependent
140
- Style/BracesAroundHashParameters:
141
- Exclude:
142
- - 'spec/vips_spec.rb'
143
-
144
136
  # Offense count: 5
145
137
  Style/ClassVars:
146
138
  Exclude:
147
139
  - 'lib/vips/image.rb'
148
140
 
149
- # Offense count: 168
141
+ # Offense count: 173
150
142
  # Cop supports --auto-correct.
151
143
  Style/ColonMethodCall:
152
- Exclude:
153
- - 'example/example1.rb'
154
- - 'example/example2.rb'
155
- - 'example/example3.rb'
156
- - 'example/example4.rb'
157
- - 'example/inheritance_with_refcount.rb'
158
- - 'lib/vips.rb'
159
- - 'lib/vips/gobject.rb'
160
- - 'lib/vips/gvalue.rb'
161
- - 'lib/vips/image.rb'
162
- - 'lib/vips/interpolate.rb'
163
- - 'lib/vips/object.rb'
164
- - 'lib/vips/operation.rb'
165
- - 'spec/image_spec.rb'
166
- - 'spec/spec_helper.rb'
167
- - 'spec/vips_spec.rb'
168
-
169
- # Offense count: 3
170
- # Cop supports --auto-correct.
171
- # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
172
- # SupportedStyles: assign_to_condition, assign_inside_condition
173
- Style/ConditionalAssignment:
174
- Exclude:
175
- - 'lib/vips.rb'
144
+ Enabled: false
176
145
 
177
- # Offense count: 44
146
+ # Offense count: 47
178
147
  Style/Documentation:
179
148
  Exclude:
180
149
  - 'spec/**/*'
@@ -188,6 +157,7 @@ Style/Documentation:
188
157
  - 'lib/vips/interpolate.rb'
189
158
  - 'lib/vips/object.rb'
190
159
  - 'lib/vips/operation.rb'
160
+ - 'lib/vips/region.rb'
191
161
 
192
162
  # Offense count: 2
193
163
  # Cop supports --auto-correct.
@@ -209,7 +179,7 @@ Style/ExpandPathArguments:
209
179
  - 'ruby-vips.gemspec'
210
180
  - 'spec/spec_helper.rb'
211
181
 
212
- # Offense count: 50
182
+ # Offense count: 51
213
183
  # Cop supports --auto-correct.
214
184
  # Configuration parameters: EnforcedStyle.
215
185
  # SupportedStyles: always, never
@@ -229,7 +199,7 @@ Style/GuardClause:
229
199
  - 'example/inheritance_with_refcount.rb'
230
200
  - 'lib/vips.rb'
231
201
 
232
- # Offense count: 53
202
+ # Offense count: 21
233
203
  # Cop supports --auto-correct.
234
204
  # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
235
205
  # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
@@ -240,12 +210,8 @@ Style/HashSyntax:
240
210
  - 'example/daltonize8.rb'
241
211
  - 'example/example3.rb'
242
212
  - 'example/example5.rb'
243
- - 'lib/vips/image.rb'
244
- - 'lib/vips/object.rb'
245
- - 'lib/vips/operation.rb'
246
213
  - 'spec/image_spec.rb'
247
214
  - 'spec/spec_helper.rb'
248
- - 'spec/vips_spec.rb'
249
215
 
250
216
  # Offense count: 30
251
217
  # Cop supports --auto-correct.
@@ -269,7 +235,7 @@ Style/LambdaCall:
269
235
  Exclude:
270
236
  - 'lib/vips/image.rb'
271
237
 
272
- # Offense count: 11
238
+ # Offense count: 9
273
239
  # Cop supports --auto-correct.
274
240
  Style/LineEndConcatenation:
275
241
  Exclude:
@@ -340,7 +306,7 @@ Style/NestedParenthesizedCalls:
340
306
  Exclude:
341
307
  - 'lib/vips/image.rb'
342
308
 
343
- # Offense count: 3
309
+ # Offense count: 2
344
310
  # Cop supports --auto-correct.
345
311
  # Configuration parameters: EnforcedStyle, MinBodyLength.
346
312
  # SupportedStyles: skip_modifier_ifs, always
@@ -421,14 +387,6 @@ Style/RedundantSelf:
421
387
  - 'example/inheritance_with_refcount.rb'
422
388
  - 'lib/vips/gobject.rb'
423
389
 
424
- # Offense count: 1
425
- # Cop supports --auto-correct.
426
- # Configuration parameters: EnforcedStyle.
427
- # SupportedStyles: implicit, explicit
428
- Style/RescueStandardError:
429
- Exclude:
430
- - 'lib/vips/image.rb'
431
-
432
390
  # Offense count: 1
433
391
  # Cop supports --auto-correct.
434
392
  Style/SelfAssignment:
@@ -487,7 +445,7 @@ Style/TrailingCommaInHashLiteral:
487
445
  Exclude:
488
446
  - 'lib/vips/image.rb'
489
447
 
490
- # Offense count: 2
448
+ # Offense count: 1
491
449
  # Cop supports --auto-correct.
492
450
  Style/UnneededInterpolation:
493
451
  Exclude:
@@ -507,7 +465,7 @@ Style/ZeroLengthPredicate:
507
465
  - 'lib/vips/image.rb'
508
466
  - 'lib/vips/operation.rb'
509
467
 
510
- # Offense count: 105
468
+ # Offense count: 107
511
469
  # Cop supports --auto-correct.
512
470
  # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
513
471
  # URISchemes: http, https
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## Version 2.0.16 (2019-9-21)
6
+
7
+ * better library name generation [renchap]
8
+ * allow `_` as a separator in enum names [D-W-L]
9
+ * add `Vips::Region` and `Region#fetch` [jcupitt]
10
+
5
11
  ## Version 2.0.15 (2019-6-12)
6
12
 
7
13
  * better error messages from `write_to_memory` [linkyndy]
data/TODO CHANGED
@@ -1,44 +1,48 @@
1
1
  # Notes
2
2
 
3
- - support complex constants, eg.
3
+ - We should support complex constants, eg:
4
4
 
5
5
  Complex(1, 2)
6
6
  => (1+2i)
7
7
 
8
8
  # Common operations
9
9
 
10
- - lint
10
+ - Lint.
11
11
 
12
12
  bundle exec rake rubocop
13
13
 
14
- - reinstall local copy of gem after a change
14
+ - Reinstall local copy of gem after a change.
15
15
 
16
16
  bundle exec rake install
17
17
 
18
- - run test suite
18
+ - Run test suite.
19
19
 
20
20
  bundle exec rake
21
21
 
22
- - version bump
22
+ - Version bump.
23
23
 
24
24
  edit lib/vips/version.rb
25
25
  edit VERSION
26
26
 
27
- - regenerate autodocs
27
+ - Regenerate autodocs.
28
28
 
29
29
  cd lib/vips
30
30
  ruby > methods.rb
31
31
  require 'vips'; Vips::generate_yard
32
32
  ^D
33
33
 
34
- - regenerate .rubocop_todo.yml
34
+ - Regenerate `.rubocop_todo.yml`.
35
35
 
36
36
  bundle exec rubocop --auto-gen-config
37
37
 
38
- - regenerate docs
38
+ - Regenerate docs.
39
39
 
40
40
  bundle exec rake yard
41
41
 
42
- - push new gem to rubygems, tag repository with version
42
+ - Push new gem to rubygems, tag repository with version.
43
43
 
44
44
  bundle exec rake release
45
+
46
+ There's an invisible prompt for the authenticator code. Enter eg. 123456,
47
+ press return and the upload should work.
48
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.15
1
+ 2.0.16
@@ -10,6 +10,29 @@ require 'logger'
10
10
  # This module uses FFI to make a simple layer over the glib and gobject
11
11
  # libraries.
12
12
 
13
+ # Generate a library name for ffi.
14
+ #
15
+ # Platform notes:
16
+ # linux:
17
+ # Some distros allow "libvips.so", but only if the -dev headers have been
18
+ # installed. To work everywhere, you must include the ABI number.
19
+ # Confusingly, the file extension is not at the end. ffi adds the "lib"
20
+ # prefix.
21
+ # mac:
22
+ # As linux, but the extension is at the end and is added by ffi.
23
+ # windows:
24
+ # The ABI number must be included, but with a hyphen. ffi does not add a
25
+ # "lib" prefix or a ".dll" suffix.
26
+ def library_name(name, abi_number)
27
+ if FFI::Platform.windows?
28
+ "lib#{name}-#{abi_number}.dll"
29
+ elsif FFI::Platform.mac?
30
+ "#{name}.#{abi_number}"
31
+ else
32
+ "#{name}.so.#{abi_number}"
33
+ end
34
+ end
35
+
13
36
  module GLib
14
37
  class << self
15
38
  attr_accessor :logger
@@ -19,13 +42,7 @@ module GLib
19
42
 
20
43
  extend FFI::Library
21
44
 
22
- if FFI::Platform.windows?
23
- glib_libname = 'libglib-2.0-0.dll'
24
- else
25
- glib_libname = 'glib-2.0'
26
- end
27
-
28
- ffi_lib glib_libname
45
+ ffi_lib library_name('glib-2.0', 0)
29
46
 
30
47
  attach_function :g_malloc, [:size_t], :pointer
31
48
 
@@ -117,13 +134,7 @@ end
117
134
  module GObject
118
135
  extend FFI::Library
119
136
 
120
- if FFI::Platform.windows?
121
- gobject_libname = 'libgobject-2.0-0.dll'
122
- else
123
- gobject_libname = 'gobject-2.0'
124
- end
125
-
126
- ffi_lib gobject_libname
137
+ ffi_lib library_name('gobject-2.0', 0)
127
138
 
128
139
  # we can't just use ulong, windows has different int sizing rules
129
140
  if FFI::Platform::ADDRESS_SIZE == 64
@@ -459,13 +470,7 @@ require 'vips/gvalue'
459
470
  module Vips
460
471
  extend FFI::Library
461
472
 
462
- if FFI::Platform.windows?
463
- vips_libname = 'libvips-42.dll'
464
- else
465
- vips_libname = 'vips'
466
- end
467
-
468
- ffi_lib vips_libname
473
+ ffi_lib library_name('vips', 42)
469
474
 
470
475
  LOG_DOMAIN = "VIPS"
471
476
  GLib::set_log_domain LOG_DOMAIN
@@ -617,4 +622,5 @@ require 'vips/object'
617
622
  require 'vips/operation'
618
623
  require 'vips/image'
619
624
  require 'vips/interpolate'
625
+ require 'vips/region'
620
626
  require 'vips/version'
@@ -25,6 +25,9 @@ module GObject
25
25
  # convert an enum value (str/symb/int) into an int ready for libvips
26
26
  def self.from_nick(gtype, value)
27
27
  value = value.to_s if value.is_a? Symbol
28
+ # libvips expects "-" as a separator in enum names, but "_" is more
29
+ # convenient for ruby, eg. :b_w
30
+ value = value.tr("_", "-")
28
31
 
29
32
  if value.is_a? String
30
33
  value = Vips::vips_enum_from_nick "ruby-vips", gtype, value
@@ -29,20 +29,14 @@ module Vips
29
29
  attach_function :vips_image_get,
30
30
  [:pointer, :string, GObject::GValue.ptr], :int
31
31
 
32
- # vips_image_get_fields was added in libvips 8.5
33
- begin
32
+ if Vips::at_least_libvips?(8, 5)
34
33
  attach_function :vips_image_get_fields, [:pointer], :pointer
35
- rescue FFI::NotFoundError
36
- nil
34
+ attach_function :vips_image_hasalpha, [:pointer], :int
37
35
  end
38
36
 
39
- # vips_addalpha was added in libvips 8.6
40
37
  if Vips::at_least_libvips?(8, 6)
41
38
  attach_function :vips_addalpha, [:pointer, :pointer, :varargs], :int
42
39
  end
43
- if Vips::at_least_libvips?(8, 5)
44
- attach_function :vips_image_hasalpha, [:pointer], :int
45
- end
46
40
 
47
41
  attach_function :vips_image_set,
48
42
  [:pointer, :string, GObject::GValue.ptr], :void
@@ -219,13 +213,13 @@ module Vips
219
213
  # load options, for example:
220
214
  #
221
215
  # ```
222
- # image = Vips::new_from_file "fred.jpg[shrink=2]"
216
+ # image = Vips::Image.new_from_file "fred.jpg[shrink=2]"
223
217
  # ```
224
218
  #
225
219
  # You can also supply options as a hash, for example:
226
220
  #
227
221
  # ```
228
- # image = Vips::new_from_file "fred.jpg", shrink: 2
222
+ # image = Vips::Image.new_from_file "fred.jpg", shrink: 2
229
223
  # ```
230
224
  #
231
225
  # The full set of options available depend upon the load operation that
@@ -317,13 +311,13 @@ module Vips
317
311
  # For example:
318
312
  #
319
313
  # ```
320
- # image = Vips::new_from_array [1, 2, 3]
314
+ # image = Vips::Image.new_from_array [1, 2, 3]
321
315
  # ```
322
316
  #
323
317
  # or
324
318
  #
325
319
  # ```
326
- # image = Vips::new_from_array [
320
+ # image = Vips::Image.new_from_array [
327
321
  # [-1, -1, -1],
328
322
  # [-1, 16, -1],
329
323
  # [-1, -1, -1]], 8
@@ -0,0 +1,73 @@
1
+ # This module provides an interface to the top level bits of libvips
2
+ # via ruby-ffi.
3
+ #
4
+ # Author:: John Cupitt (mailto:jcupitt@gmail.com)
5
+ # License:: MIT
6
+
7
+ require 'ffi'
8
+
9
+ module Vips
10
+ attach_function :vips_region_new, [:pointer], :pointer
11
+
12
+ if Vips::at_least_libvips?(8, 8)
13
+ attach_function :vips_region_fetch, [:pointer, :int, :int, :int, :int, SizeStruct.ptr], :pointer
14
+ attach_function :vips_region_width, [:pointer], :int
15
+ attach_function :vips_region_height, [:pointer], :int
16
+ end
17
+
18
+ # A region on an image. Create one, then use `fetch` to quickly get a region
19
+ # of pixels.
20
+ #
21
+ # For example:
22
+ #
23
+ # ```ruby
24
+ # region = Vips::Region.new(image)
25
+ # pixels = region.fetch(10, 10, 100, 100)
26
+ # ```
27
+ class Region < Vips::Object
28
+ # The layout of the VipsRegion struct.
29
+ module RegionLayout
30
+ def self.included(base)
31
+ base.class_eval do
32
+ layout :parent, Vips::Object::Struct
33
+ # rest opaque
34
+ end
35
+ end
36
+ end
37
+
38
+ class Struct < Vips::Object::Struct
39
+ include RegionLayout
40
+ end
41
+
42
+ class ManagedStruct < Vips::Object::ManagedStruct
43
+ include RegionLayout
44
+ end
45
+
46
+ def initialize(name)
47
+ ptr = Vips::vips_region_new name
48
+ raise Vips::Error if ptr.nil?
49
+
50
+ super ptr
51
+ end
52
+
53
+ def width
54
+ Vips::vips_region_width self
55
+ end
56
+
57
+ def height
58
+ Vips::vips_region_height self
59
+ end
60
+
61
+ # Fetch a region filled with pixel data.
62
+ def fetch(left, top, width, height)
63
+ len = Vips::SizeStruct.new
64
+ ptr = Vips::vips_region_fetch self, left, top, width, height, len
65
+ raise Vips::Error if ptr.nil?
66
+
67
+ # wrap up as an autopointer
68
+ ptr = FFI::AutoPointer.new(ptr, GLib::G_FREE)
69
+
70
+ ptr.get_bytes 0, len[:value]
71
+ end
72
+ end
73
+ end
@@ -1,3 +1,3 @@
1
1
  module Vips
2
- VERSION = "2.0.15"
2
+ VERSION = "2.0.16"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-vips
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.15
4
+ version: 2.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Cupitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-08 00:00:00.000000000 Z
11
+ date: 2019-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -193,6 +193,7 @@ files:
193
193
  - lib/vips/operationmath2.rb
194
194
  - lib/vips/operationrelational.rb
195
195
  - lib/vips/operationround.rb
196
+ - lib/vips/region.rb
196
197
  - lib/vips/size.rb
197
198
  - lib/vips/version.rb
198
199
  - ruby-vips.gemspec