ruby-vips 2.0.1 → 2.0.2

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
  SHA1:
3
- metadata.gz: 4678e6b9ab0569b528f25f1ad9eaaa01c40d9142
4
- data.tar.gz: 5e7cfa1695d8cc2e75bbb944c0c6b71bcf030d64
3
+ metadata.gz: bc07fdb1e2def0cb74571c3662c1a7cc568505c8
4
+ data.tar.gz: 2302be93ac930c25b90eacade712c8fbe685abeb
5
5
  SHA512:
6
- metadata.gz: f93eaaa519c4b6e5c1089d4e2a22c5901cd3bd5f818ee72f8c064633dbe772939381e78482db1d8521faea53bb70624274d29e8c47c76a6637cfaaf9c0d7549b
7
- data.tar.gz: abccdf5bd42c8e8a2b3bf3bfdac36805d461edc1d38d84ceb6805e754f2f25b1cc76f6004785169468478de697c75706c8ebcb5af4a020514043fb8b4b90d664
6
+ metadata.gz: 59b7246675bb70923a0df56fe3ea1a2f5d9de71040377c74851d911e982555961bd3fc280f290f5714666479726e766b8c63c30a58b0c3146280ffe972ef266b
7
+ data.tar.gz: f325a99c620ca792ff0380292312020edbfc7faf5e6f7ee6436646fc6fe89d2acf7e2fbd3ef7c624bcc08c0ed6d6ada149d894ba2a15662fb02e8ef08197a45a
data/CHANGELOG.md CHANGED
@@ -1,20 +1,28 @@
1
- # master
1
+ # Changelog
2
2
 
3
- # Version 2.0.1
3
+ ## master
4
4
 
5
- * add support for VipsRefStr in gvalue, thanks tomasc
5
+ ## Version 2.0.2 (2017-08-26)
6
6
 
7
- # Version 2.0.0
7
+ * switch to `logger` for all logging output
8
+ * add libvips cache control functions `Vips::cache_set_max()` etc.
9
+ * fix a ref leak
10
+
11
+ ## Version 2.0.1 (2017-08-23)
12
+
13
+ * add support for `VipsRefStr` in gvalue, thanks tomasc
14
+
15
+ ## Version 2.0.0 (2017-08-22)
8
16
 
9
17
  * rewrite on top of 'ffi' [John Cupitt, Kleis Auke Wolthuizen]
10
18
 
11
- # Version 1.0.6
19
+ ## Version 1.0.6 (2017-07-17)
12
20
 
13
21
  * remove lazy load, fixing a race with multi-threading [felixbuenemann]
14
22
  * make `Image#to_a` much faster [John Cupitt]
15
23
  * remove the `at_exit` handler [John Cupitt]
16
24
 
17
- # Version 1.0.5
25
+ ## Version 1.0.5 (2017-04-29)
18
26
 
19
27
  * fix `_const` for libvips 8.5 [John Cupitt]
20
28
  * add `scaleimage`, the scale operation renamed to avoid a clash with the
@@ -24,7 +32,7 @@
24
32
  * update generated docs for libvips 8.5 [John Cupitt]
25
33
  * added docs for new libvips 8.5 enums [John Cupitt]
26
34
 
27
- # Version 1.0.4
35
+ ## Version 1.0.4 (2017-02-07)
28
36
 
29
37
  * remove stray comma from some docs lines [John Cupitt]
30
38
  * update generated docs for libvips 8.5 [John Cupitt]
@@ -32,52 +40,52 @@
32
40
  * update for gobject-introspection 3.1 [John Cupitt]
33
41
  * support ruby 2.4 [John Cupitt]
34
42
 
35
- # Version 1.0.3
43
+ ## Version 1.0.3 (2016-08-18)
36
44
 
37
45
  * doc improvements [John Cupitt]
38
- * add #size to get [width, height] [John Cupitt]
39
- * only ask for ruby 2.0 to help OS X [John Cupitt]
40
- * break up Image.call to make it easier to understand [John Cupitt]
46
+ * add `Image#size` to get `[width, height]` [John Cupitt]
47
+ * only ask for ruby 2.0 to help OS X [John Cupitt]
48
+ * break up `Image.call` to make it easier to understand [John Cupitt]
41
49
  * detect operation build fail correctly [John Cupitt]
42
50
  * lock gobject-introspection at 3.0.8 to avoid breakage [John Cupitt]
43
51
 
44
- # Version 1.0.2
52
+ ## Version 1.0.2 (2016-07-07)
45
53
 
46
- * add .yardopts to fix ruby-gems docs [John Cupitt]
54
+ * add `.yardopts` to fix ruby-gems docs [John Cupitt]
47
55
 
48
- # Version 1.0.1
56
+ ## Version 1.0.1 (2016-07-07)
49
57
 
50
58
  * simplify gemspec [sandstrom]
51
59
  * remove jeweler dependency [John Cupitt]
52
60
  * add `.to_a` to Image [John Cupitt]
53
61
 
54
- # Version 1.0.0
62
+ ## Version 1.0.0 (2016-06-07)
55
63
 
56
64
  * complete rewrite, API break [John Cupitt]
57
65
 
58
- # Version 0.3.14
66
+ ## Version 0.3.14 (2016-01-25)
59
67
 
60
68
  * more GC tuning [felixbuenemann]
61
69
  * add `write.rb` example program [felixbuenemann]
62
70
 
63
- # Version 0.3.13
71
+ ## Version 0.3.13 (2016-01-18)
64
72
 
65
73
  * don't use generational GC options on old Rubys [John Cupitt]
66
74
 
67
- # Version 0.3.12
75
+ ## Version 0.3.12 (2016-01-17)
68
76
 
69
77
  * incremental GC every 10 writes [felixbuenemann]
70
78
  * updated bundle [John Cupitt]
71
79
 
72
- # Version 0.3.11
80
+ ## Version 0.3.11 (2015-10-15)
73
81
 
74
82
  * added magick load from buffer [John Cupitt]
75
83
 
76
- # Version 0.3.10
84
+ ## Version 0.3.10 (2015-06-24)
77
85
 
78
86
  * added webp write [John Cupitt]
79
87
 
80
- # Version 0.3.9
88
+ ## Version 0.3.9 (2014-07-17)
81
89
 
82
90
  * removed a stray file from gemspec [Alessandro Tagliapietra]
83
91
  * updated bundle [John Cupitt]
@@ -89,16 +97,16 @@
89
97
  * add .size, see issue #58 [John Cupitt]
90
98
  * add rdoc-data dep, maybe it will help ruby-gems docs [John Cupitt]
91
99
 
92
- # Version 0.3.8
100
+ ## Version 0.3.8 (2014-05-11)
93
101
 
94
102
  * add VIPS::thread_shutdown(), must be called on foreign thread exit [John Cupitt]
95
103
 
96
- # Version 0.3.7
104
+ ## Version 0.3.7 (2014-02-04)
97
105
 
98
106
  * update build dependencies [John Cupitt]
99
107
  * README updated [John Cupitt]
100
108
 
101
- # Version 0.3.6
109
+ ## Version 0.3.6 (2013-06-25)
102
110
 
103
111
  * add png and jpg load from memory buffer [John Cupitt]
104
112
  * README updated to include buffer read/write example [John Cupitt]
@@ -107,30 +115,30 @@
107
115
  * fix rdoc build to include C sources [John Cupitt]
108
116
  * better compat with older libvips [John Cupitt]
109
117
 
110
- # Version 0.3.5
118
+ ## Version 0.3.5 (2013-01-15)
111
119
 
112
120
  * rb_raise() in mask.c no longer passes a string pointer as the fmt arg, stopping gcc bailing out on some platforms [John Cupitt]
113
121
  * Image.magick() now calls im_magick2vips() directly rather than relying on libvips file type sniffing [John Cupitt]
114
122
 
115
- # Version 0.3.4
123
+ ## Version 0.3.4 (2012-09-11)
116
124
 
117
125
  * Update specs for lcms changes, thanks Stanislaw [John Cupitt]
118
126
  * VIPS::Reader supports .exif() / .exif?() methods for better back compat, thanks Jeremy [John Cupitt]
119
127
  * VIPS::Reader fallbacks load the image if its not been loaded [John Cupitt]
120
128
  * VIPS::Reader no longer allows VIPS::Header methods [John Cupitt]
121
129
 
122
- # Version 0.3.3
130
+ ## Version 0.3.3 (2012-08-31)
123
131
 
124
132
  * Typo in workaround in 0.3.2 [John Cupitt]
125
133
 
126
- # Version 0.3.2
134
+ ## Version 0.3.2 (2012-08-31)
127
135
 
128
136
  ### Fixed
129
137
 
130
138
  * Workaround helps ruby-vips compile (and run) against 7.26.3 [John Cupitt and
131
139
  James Harrison]
132
140
 
133
- # Version 0.3.1
141
+ ## Version 0.3.1 (2012-08-30)
134
142
 
135
143
  ### Fixed
136
144
 
@@ -139,9 +147,7 @@ James Harrison]
139
147
  * Image read now runs GC and retries on fail [John Cupitt]
140
148
  * Image write GCs every 100 images [John Cupitt]
141
149
 
142
- # Version 0.3.0
143
-
144
- Release date: 2012-07-20
150
+ ## Version 0.3.0 (2012-07-20)
145
151
 
146
152
  ### Added
147
153
 
@@ -161,9 +167,7 @@ Release date: 2012-07-20
161
167
  * Now passes rspec test suite cleanly in valgrind [John Cupitt]
162
168
  * Fixed check of sequential mode support [Stanislaw Pankevich]
163
169
 
164
- # Version 0.2.0
165
-
166
- Release date: 2012-06-29
170
+ ## Version 0.2.0 (2012-06-29)
167
171
 
168
172
  ### Added
169
173
 
@@ -183,9 +187,7 @@ Release date: 2012-06-29
183
187
 
184
188
  * #8: Memory allocation-free issues [Grigoriy Chudnov]
185
189
 
186
- # Version 0.1.1
187
-
188
- Release date: 2012-06-22
190
+ ## Version 0.1.1 (2012-06-22)
189
191
 
190
192
  ### Changed
191
193
 
@@ -197,6 +199,6 @@ Release date: 2012-06-22
197
199
  * Added Gemfile with the only 'rspec' dependency. [Stanislaw Pankevich]
198
200
  * Added Jeweler Rakefile contents to release ruby-vips as a gem. [Stanislaw Pankevich]
199
201
 
200
- # Before (initial unreleased version 0.1.0)
202
+ ## Before (initial unreleased version 0.1.0)
201
203
 
202
204
  Long-long history here undocumented...
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.0.2
data/example/example1.rb CHANGED
@@ -1,84 +1,12 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
+ require 'logger'
3
4
  require 'vips'
4
- $vips_debug = true
5
5
 
6
- puts ""
7
- puts "starting up:"
6
+ GLib::logger.level = Logger::DEBUG
8
7
 
9
- # this makes vips keep a list of all active objects which we can print out
10
- Vips::leak_set true
11
-
12
- # disable the operation cache
13
- Vips::cache_set_max 0
14
-
15
- puts ""
16
- puts "creating object:"
17
- x = Vips::Image.new
18
- Vips::Object::print_all
19
-
20
- puts ""
21
- puts "freeing object:"
22
- x = nil
23
- GC.start
24
- Vips::Object::print_all
25
-
26
- puts ""
27
- puts "creating operation:"
28
8
  op = Vips::Operation.new "black"
29
- Vips::Object::print_all
30
- op.set_property "width", 200
31
- op.set_property "height", 300
32
9
 
33
- puts ""
34
- puts "after operation init:"
35
- GC.start
36
- Vips::Object::print_all
37
-
38
- puts ""
39
- puts "operation lookup:"
40
- op2 = Vips::cache_operation_lookup op
41
- if op2
42
- puts "cache hit"
43
- op = op2
44
- op2 = nil
45
- else
46
- puts "cache miss ... building"
47
- if not op.build
48
- puts "*** build error"
49
- end
50
- Vips::cache_operation_add op
51
- end
52
-
53
- puts ""
54
- puts "after build:"
55
- GC.start
56
- Vips::Object::print_all
57
-
58
- puts ""
59
- puts "fetching output:"
60
- im = op.get_property "out"
61
- GC.start
62
- Vips::Object::print_all
63
-
64
- puts ""
65
- puts "fetching output again:"
66
- im2 = op.get_property "out"
67
- GC.start
68
- Vips::Object::print_all
69
-
70
- puts ""
71
- puts "freeing operation:"
72
- op.unref_outputs
73
10
  op = nil
74
- op2 = nil
75
- GC.start
76
- Vips::Object::print_all
77
-
78
- puts ""
79
- puts "shutting down:"
80
- im = nil
81
- im2 = nil
82
- GC.start
83
- Vips::shutdown
84
11
  GC.start
12
+ Vips::Operation.print_all
data/example/example2.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
+ require 'logger'
3
4
  require 'vips'
4
5
 
5
6
  puts ""
@@ -11,12 +12,14 @@ Vips::leak_set true
11
12
  # disable the operation cache
12
13
  Vips::cache_set_max 0
13
14
 
14
- n = 100
15
+ # GLib::logger.level = Logger::DEBUG
16
+
17
+ n = 10000
15
18
 
16
19
  n.times do |i|
17
20
  puts ""
18
21
  puts "call #{i} ..."
19
- out = Vips::call "black", 200, 300
22
+ out = Vips::Operation.call "black", [200, 300]
20
23
  if out.width != 200 or out.height != 300
21
24
  puts "bad image result from black"
22
25
  end
data/example/example3.rb CHANGED
@@ -3,15 +3,15 @@
3
3
  require 'vips'
4
4
 
5
5
  # this makes vips keep a list of all active objects
6
- # Vips::leak_set true
6
+ Vips::leak_set true
7
7
 
8
8
  # disable the operation cache
9
9
  # Vips::cache_set_max 0
10
10
 
11
11
  # turn on debug logging
12
- #Vips.set_debug true
12
+ GLib::logger.level = Logger::DEBUG
13
13
 
14
- 10000.times do |i|
14
+ 1.times do |i|
15
15
  puts "loop #{i} ..."
16
16
  im = Vips::Image.new_from_file ARGV[0]
17
17
  im = im.embed 100, 100, 3000, 3000, :extend => :mirror
data/lib/vips/gobject.rb CHANGED
@@ -54,9 +54,10 @@ module GObject
54
54
  include GObjectLayout
55
55
 
56
56
  def self.release ptr
57
- # Vips::log "GObject::GObject::ManagedStruct.release: " +
57
+ # GLib::logger.debug("GObject::GObject::ManagedStruct.release") {
58
58
  # "unreffing #{ptr}"
59
- GObject::g_object_unref ptr
59
+ # }
60
+ ::GObject::g_object_unref ptr
60
61
  end
61
62
  end
62
63
 
@@ -72,7 +73,7 @@ module GObject
72
73
  # here we use ManagedStruct, not Struct, since this is the ref that will
73
74
  # need the unref
74
75
  def initialize ptr
75
- # Vips::log "GObject::GObject.initialize: ptr = #{ptr}"
76
+ # GLib::logger.debug("GObject::GObject.initialize") {"ptr = #{ptr}"}
76
77
  @struct = ffi_managed_struct.new ptr
77
78
  end
78
79
 
@@ -109,13 +110,13 @@ module GObject
109
110
  :owner_type, :GType
110
111
  end
111
112
 
113
+ class GParamSpecPtr < FFI::Struct
114
+ layout :value, GParamSpec.ptr
115
+ end
116
+
112
117
  attach_function :g_param_spec_get_blurb, [GParamSpec.ptr], :string
113
118
 
114
119
  attach_function :g_object_ref, [:pointer], :void
115
120
  attach_function :g_object_unref, [:pointer], :void
116
121
 
117
- class GParamSpecPtr < FFI::Struct
118
- layout :value, GParamSpec.ptr
119
- end
120
-
121
122
  end
data/lib/vips/gvalue.rb CHANGED
@@ -24,7 +24,7 @@ module GObject
24
24
  :data, [:ulong_long, 2]
25
25
 
26
26
  def self.release ptr
27
- # Vips::log "GObject::GValue::release ptr = #{ptr}"
27
+ # GLib::logger.debug("GObject::GValue::release") {"ptr = #{ptr}"}
28
28
  ::GObject::g_value_unset ptr
29
29
  end
30
30
 
@@ -58,7 +58,9 @@ module GObject
58
58
  #
59
59
  # @param value [Any] The value to set
60
60
  def set value
61
- # Vips::log "GObject::GValue.set: value = #{value.inspect[0..50]}"
61
+ # GLib::logger.debug("GObject::GValue.set") {
62
+ # "value = #{value.inspect[0..50]}"
63
+ # }
62
64
 
63
65
  gtype = self[:gtype]
64
66
  fundamental = ::GObject::g_type_fundamental gtype
@@ -221,7 +223,9 @@ module GObject
221
223
  end
222
224
  end
223
225
 
224
- # Vips::log "GObject::GValue.get: result = #{result.inspect[0..50]}"
226
+ # GLib::logger.debug("GObject::GValue.get") {
227
+ # "result = #{result.inspect[0..50]}"
228
+ # }
225
229
 
226
230
  return result
227
231
 
data/lib/vips/object.rb CHANGED
@@ -9,6 +9,9 @@ require 'ffi'
9
9
  module Vips
10
10
  private
11
11
 
12
+ # debugging support
13
+ attach_function :vips_object_print_all, [], :void
14
+
12
15
  # we must init these by hand, since they are usually made on first image
13
16
  # create
14
17
  attach_function :vips_band_format_get_type, [], :GType
@@ -69,6 +72,13 @@ module Vips
69
72
 
70
73
  class Object < GObject::GObject
71
74
 
75
+ # print all active VipsObjects, with their reference counts. Handy for
76
+ # debugging ruby-vips.
77
+ def self.print_all
78
+ GC.start
79
+ Vips::vips_object_print_all
80
+ end
81
+
72
82
  # the layout of the VipsObject struct
73
83
  module ObjectLayout
74
84
  def self.included base
@@ -117,13 +127,13 @@ module Vips
117
127
  GObject::g_object_get_property self, name, gvalue
118
128
  result = gvalue.get
119
129
 
120
- # Vips::log "Vips::Object.get(\"#{name}\"): result = #{result}"
130
+ GLib::logger.debug("Vips::Object.get") {"#{name} == #{result}"}
121
131
 
122
132
  return result
123
133
  end
124
134
 
125
135
  def set name, value
126
- # Vips::log "Vips::Object.set: #{name} = #{value}"
136
+ GLib::logger.debug("Vips::Object.set") {"#{name} = #{value}"}
127
137
 
128
138
  gtype = get_typeof name
129
139
  gvalue = GObject::GValue.alloc
@@ -223,9 +223,10 @@ module Vips
223
223
  # the constant value 255.
224
224
 
225
225
  def self.call name, supplied, optional = {}, option_string = ""
226
- #Vips::log "Vips::VipsOperation.call: name = #{name}, " +
227
- # "supplied = #{supplied} optional = #{optional} " +
228
- # "option_string = #{option_string}"
226
+ GLib::logger.debug("Vips::VipsOperation.call") {
227
+ "name = #{name}, supplied = #{supplied}, " +
228
+ "optional = #{optional}, option_string = #{option_string}"
229
+ }
229
230
 
230
231
  op = Operation.new name
231
232
 
@@ -351,7 +352,7 @@ module Vips
351
352
  result = nil
352
353
  end
353
354
 
354
- # Vips::log "Vips::Operation.call: result = #{result}"
355
+ GLib::logger.debug("Vips::Operation.call") {"result = #{result}"}
355
356
 
356
357
  Vips::vips_object_unref_outputs op
357
358
 
data/lib/vips/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Vips
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
4
4
 
data/lib/vips.rb CHANGED
@@ -5,11 +5,18 @@
5
5
  # License:: MIT
6
6
 
7
7
  require 'ffi'
8
+ require 'logger'
8
9
 
9
10
  # This module uses FFI to make a simple layer over the glib and gobject
10
11
  # libraries.
11
12
 
12
13
  module GLib
14
+ class << self
15
+ attr_accessor :logger
16
+ end
17
+ @logger = Logger.new(STDOUT)
18
+ @logger.level = Logger::WARN
19
+
13
20
  extend FFI::Library
14
21
 
15
22
  if FFI::Platform.windows?
@@ -20,19 +27,83 @@ module GLib
20
27
 
21
28
  ffi_lib glib_libname
22
29
 
23
- # nil being the default
24
- glib_log_domain = nil
25
-
26
- def self.set_log_domain domain
27
- glib_log_domain = domain
28
- end
29
-
30
30
  attach_function :g_malloc, [:size_t], :pointer
31
31
 
32
32
  # save the FFI::Function that attach will return ... we can use it directly
33
33
  # as a param for callbacks
34
34
  G_FREE = attach_function :g_free, [:pointer], :void
35
35
 
36
+ callback :g_log_func, [:string, :int, :string, :pointer], :void
37
+ attach_function :g_log_set_handler,
38
+ [:string, :int, :g_log_func, :pointer], :int
39
+ attach_function :g_log_remove_handler, [:string, :int], :void
40
+
41
+ # log flags
42
+ LOG_FLAG_RECURSION = 1 << 0
43
+ LOG_FLAG_FATAL = 1 << 1
44
+
45
+ # GLib log levels
46
+ LOG_LEVEL_ERROR = 1 << 2 # always fatal
47
+ LOG_LEVEL_CRITICAL = 1 << 3
48
+ LOG_LEVEL_WARNING = 1 << 4
49
+ LOG_LEVEL_MESSAGE = 1 << 5
50
+ LOG_LEVEL_INFO = 1 << 6
51
+ LOG_LEVEL_DEBUG = 1 << 7
52
+
53
+ # map glib levels to Logger::Severity
54
+ GLIB_TO_SEVERITY = {
55
+ LOG_LEVEL_ERROR => Logger::ERROR,
56
+ LOG_LEVEL_CRITICAL => Logger::FATAL,
57
+ LOG_LEVEL_WARNING => Logger::WARN,
58
+ LOG_LEVEL_MESSAGE => Logger::UNKNOWN,
59
+ LOG_LEVEL_INFO => Logger::INFO,
60
+ LOG_LEVEL_DEBUG => Logger::DEBUG
61
+ }
62
+ GLIB_TO_SEVERITY.default = Logger::UNKNOWN
63
+
64
+ # nil being the default
65
+ @glib_log_domain = nil
66
+ @glib_log_handler_id = 0
67
+
68
+ # module-level, so it's not GCd away
69
+ LOG_HANDLER = Proc.new do |domain, level, message, user_data|
70
+ @logger.log(GLIB_TO_SEVERITY[level], message, domain)
71
+ end
72
+
73
+ def self.remove_log_handler
74
+ if @glib_log_handler_id and @glib_log_domain
75
+ g_log_remove_handler @glib_log_domain, @glib_log_handler_id
76
+ @glib_log_handler_id = nil
77
+ end
78
+ end
79
+
80
+ def self.set_log_domain domain
81
+ GLib::remove_log_handler
82
+
83
+ @glib_log_domain = domain
84
+
85
+ # forward all glib logging output from this domain to a Ruby logger
86
+ if @glib_log_domain
87
+ @glib_log_handler_id = g_log_set_handler @glib_log_domain,
88
+ LOG_LEVEL_DEBUG |
89
+ LOG_LEVEL_INFO |
90
+ LOG_LEVEL_MESSAGE |
91
+ LOG_LEVEL_WARNING |
92
+ LOG_LEVEL_ERROR |
93
+ LOG_LEVEL_CRITICAL |
94
+ LOG_FLAG_FATAL | LOG_FLAG_RECURSION,
95
+ LOG_HANDLER, nil
96
+
97
+ # we must remove any handlers on exit, since libvips may log stuff
98
+ # on shutdown and we don't want LOG_HANDLER to be invoked
99
+ # after Ruby has gone
100
+ at_exit {
101
+ GLib::remove_log_handler
102
+ }
103
+ end
104
+
105
+ end
106
+
36
107
  end
37
108
 
38
109
  module GObject
@@ -292,6 +363,19 @@ require 'vips/gvalue'
292
363
  # ```
293
364
  #
294
365
  # and so on.
366
+ #
367
+ # # Logging
368
+ #
369
+ # The wrapper uses `logger` to log debug, info, warning, and error messages. By
370
+ # default, it will send messages of level `Logger::WARN` and above to `STDOUT`.
371
+ #
372
+ # You can use the {GLib::logger} accessor to change the log level, or to
373
+ # redirect logging somewhere else. For example:
374
+ #
375
+ # ```ruby
376
+ # GLib.logger.level = Logger::ERROR
377
+ # GLib.logger = Rails.logger
378
+ # ```
295
379
  #
296
380
  # # Automatic YARD documentation
297
381
  #
@@ -378,22 +462,6 @@ module Vips
378
462
  LOG_DOMAIN = "VIPS"
379
463
  GLib::set_log_domain LOG_DOMAIN
380
464
 
381
- @@debug = false
382
-
383
- # Turn debug logging on and off.
384
- #
385
- # @param dbg [Boolean] Set true to print debug log messages
386
- def self.set_debug dbg
387
- @@debug = dbg
388
- end
389
-
390
- # Print a log message to the output. See {Vips::set_debug}.
391
- def self.log str
392
- if @@debug
393
- puts str
394
- end
395
- end
396
-
397
465
  typedef :ulong, :GType
398
466
 
399
467
  attach_function :vips_error_buffer, [], :string
@@ -435,18 +503,44 @@ module Vips
435
503
  # don't use at_exit to call vips_shutdown, it causes problems with fork, and
436
504
  # in any case libvips does this for us
437
505
 
438
- attach_function :vips_object_print_all, [], :void
439
506
  attach_function :vips_leak_set, [:int], :void
440
507
 
441
- def self.showall
442
- if @@debug
443
- GC.start
444
- vips_object_print_all
445
- end
508
+ # Turn libvips leak testing on and off. Handy for debugging ruby-vips, not
509
+ # very useful for user code.
510
+ def self.leak_set leak
511
+ vips_leak_set (leak ? 1 : 0)
512
+ end
513
+
514
+ attach_function :vips_cache_set_max, [:int], :void
515
+ attach_function :vips_cache_set_max_mem, [:int], :void
516
+ attach_function :vips_cache_set_max_files, [:int], :void
517
+
518
+ # Set the maximum number of operations that libvips should cache. Set 0 to
519
+ # disable the operation cache. The default is 1000.
520
+ def self.cache_set_max size
521
+ vips_cache_set_max size
522
+ end
523
+
524
+ # Set the maximum amount of memory that libvips should use for the operation
525
+ # cache. Set 0 to disable the operation cache. The default is 100mb.
526
+ def self.cache_set_max_mem size
527
+ vips_cache_set_max_mem size
528
+ end
529
+
530
+ # Set the maximum number of files libvips should keep open in the
531
+ # operation cache. Set 0 to disable the operation cache. The default is
532
+ # 100.
533
+ def self.cache_set_max_files size
534
+ vips_cache_set_max_files size
446
535
  end
447
536
 
448
- if @@debug
449
- vips_leak_set 1
537
+ # Deprecated compatibility function.
538
+ #
539
+ # Don't use this, instead change {GLib::logger.level}.
540
+ def self.set_debug debug
541
+ if debug
542
+ GLib::logger.level = Logger::DEBUG
543
+ end
450
544
  end
451
545
 
452
546
  attach_function :version, :vips_version, [:int], :int
data/ruby-vips.gemspec CHANGED
@@ -8,7 +8,6 @@ Gem::Specification.new do |spec|
8
8
  spec.name = "ruby-vips"
9
9
  spec.version = Vips::VERSION
10
10
  spec.authors = ["John Cupitt"]
11
- spec.date = "2017-07-15"
12
11
  spec.email = "jcupitt@gmail.com"
13
12
 
14
13
  spec.summary = "Ruby extension for the vips image processing library."
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.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Cupitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-15 00:00:00.000000000 Z
11
+ date: 2017-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi