rmagick 2.16.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rmagick might be problematic. Click here for more details.

Files changed (238) hide show
  1. checksums.yaml +5 -5
  2. data/.appveyor.yml +19 -0
  3. data/.circleci/config.yml +56 -0
  4. data/.rubocop.yml +8 -335
  5. data/.rubocop_todo.yml +255 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +6 -49
  8. data/CHANGELOG.md +23 -0
  9. data/CONTRIBUTING.md +34 -0
  10. data/Gemfile +0 -6
  11. data/README.textile +11 -3
  12. data/Rakefile +23 -15
  13. data/before_install_linux.sh +12 -15
  14. data/doc/ex/InitialCoords.rb +4 -4
  15. data/doc/ex/NewCoordSys.rb +4 -4
  16. data/doc/ex/OrigCoordSys.rb +2 -2
  17. data/doc/ex/PreserveAspectRatio.rb +34 -34
  18. data/doc/ex/RotateScale.rb +7 -7
  19. data/doc/ex/Skew.rb +7 -7
  20. data/doc/ex/Use01.rb +1 -1
  21. data/doc/ex/Use02.rb +4 -4
  22. data/doc/ex/Use03.rb +2 -2
  23. data/doc/ex/ViewBox.rb +4 -4
  24. data/doc/ex/affine.rb +5 -5
  25. data/doc/ex/affine_transform.rb +3 -3
  26. data/doc/ex/arc.rb +9 -9
  27. data/doc/ex/arcpath.rb +2 -2
  28. data/doc/ex/arcs01.rb +6 -6
  29. data/doc/ex/arcs02.rb +8 -8
  30. data/doc/ex/axes.rb +11 -11
  31. data/doc/ex/baseline_shift01.rb +5 -5
  32. data/doc/ex/bilevel_channel.rb +1 -1
  33. data/doc/ex/blur_image.rb +1 -1
  34. data/doc/ex/border.rb +1 -1
  35. data/doc/ex/bounding_box.rb +11 -11
  36. data/doc/ex/cbezier1.rb +12 -12
  37. data/doc/ex/cbezier2.rb +13 -13
  38. data/doc/ex/cbezier3.rb +13 -13
  39. data/doc/ex/cbezier4.rb +13 -13
  40. data/doc/ex/cbezier5.rb +13 -13
  41. data/doc/ex/cbezier6.rb +19 -19
  42. data/doc/ex/channel.rb +2 -2
  43. data/doc/ex/chop.rb +2 -2
  44. data/doc/ex/circle.rb +7 -7
  45. data/doc/ex/circle01.rb +2 -2
  46. data/doc/ex/clip_path.rb +6 -6
  47. data/doc/ex/coalesce.rb +6 -6
  48. data/doc/ex/color_fill_to_border.rb +8 -8
  49. data/doc/ex/color_floodfill.rb +8 -8
  50. data/doc/ex/color_histogram.rb +2 -2
  51. data/doc/ex/color_reset.rb +2 -2
  52. data/doc/ex/colors.rb +4 -4
  53. data/doc/ex/compose_mask.rb +2 -2
  54. data/doc/ex/composite.rb +39 -39
  55. data/doc/ex/composite_layers.rb +1 -2
  56. data/doc/ex/contrast.rb +3 -3
  57. data/doc/ex/crop.rb +2 -2
  58. data/doc/ex/crop_with_gravity.rb +5 -5
  59. data/doc/ex/cubic01.rb +12 -12
  60. data/doc/ex/cubic02.rb +22 -22
  61. data/doc/ex/cycle_colormap.rb +3 -3
  62. data/doc/ex/dissolve.rb +0 -0
  63. data/doc/ex/drawcomp.rb +8 -9
  64. data/doc/ex/drop_shadow.rb +4 -4
  65. data/doc/ex/ellipse.rb +9 -9
  66. data/doc/ex/ellipse01.rb +3 -3
  67. data/doc/ex/enhance.rb +2 -2
  68. data/doc/ex/evenodd.rb +19 -19
  69. data/doc/ex/fill_pattern.rb +3 -3
  70. data/doc/ex/flatten_images.rb +1 -1
  71. data/doc/ex/font_styles.rb +13 -13
  72. data/doc/ex/fonts.rb +2 -6
  73. data/doc/ex/frame.rb +1 -1
  74. data/doc/ex/get_multiline_type_metrics.rb +3 -3
  75. data/doc/ex/get_pixels.rb +4 -6
  76. data/doc/ex/get_type_metrics.rb +26 -25
  77. data/doc/ex/gradientfill.rb +2 -2
  78. data/doc/ex/grav.rb +12 -12
  79. data/doc/ex/gravity.rb +14 -16
  80. data/doc/ex/group.rb +11 -11
  81. data/doc/ex/hatchfill.rb +2 -2
  82. data/doc/ex/image.rb +9 -9
  83. data/doc/ex/implode.rb +2 -2
  84. data/doc/ex/line.rb +10 -10
  85. data/doc/ex/line01.rb +7 -7
  86. data/doc/ex/mask.rb +0 -0
  87. data/doc/ex/matte_fill_to_border.rb +3 -3
  88. data/doc/ex/matte_floodfill.rb +2 -2
  89. data/doc/ex/matte_replace.rb +3 -3
  90. data/doc/ex/median_filter.rb +2 -2
  91. data/doc/ex/mono.rb +2 -2
  92. data/doc/ex/morph.rb +1 -1
  93. data/doc/ex/mosaic.rb +7 -5
  94. data/doc/ex/motion_blur.rb +1 -1
  95. data/doc/ex/negate_channel.rb +0 -0
  96. data/doc/ex/nested_rvg.rb +2 -2
  97. data/doc/ex/nonzero.rb +19 -19
  98. data/doc/ex/opacity.rb +9 -9
  99. data/doc/ex/path.rb +17 -17
  100. data/doc/ex/pattern1.rb +4 -4
  101. data/doc/ex/pattern2.rb +2 -2
  102. data/doc/ex/polaroid.rb +0 -1
  103. data/doc/ex/polygon.rb +7 -7
  104. data/doc/ex/polygon01.rb +7 -7
  105. data/doc/ex/polyline.rb +7 -7
  106. data/doc/ex/polyline01.rb +8 -8
  107. data/doc/ex/posterize.rb +0 -0
  108. data/doc/ex/qbezierpath.rb +16 -16
  109. data/doc/ex/quad01.rb +6 -6
  110. data/doc/ex/quantize-m.rb +2 -2
  111. data/doc/ex/random_threshold_channel.rb +1 -1
  112. data/doc/ex/rect01.rb +2 -2
  113. data/doc/ex/rect02.rb +3 -3
  114. data/doc/ex/rectangle.rb +6 -6
  115. data/doc/ex/reduce_noise.rb +2 -2
  116. data/doc/ex/remap.rb +0 -0
  117. data/doc/ex/resize_to_fill.rb +0 -0
  118. data/doc/ex/resize_to_fit.rb +0 -0
  119. data/doc/ex/roll.rb +1 -1
  120. data/doc/ex/rotate.rb +8 -8
  121. data/doc/ex/rotate_f.rb +1 -1
  122. data/doc/ex/roundrect.rb +6 -6
  123. data/doc/ex/rubyname.rb +4 -4
  124. data/doc/ex/rvg_clippath.rb +3 -3
  125. data/doc/ex/rvg_linecap.rb +7 -7
  126. data/doc/ex/rvg_linejoin.rb +7 -7
  127. data/doc/ex/rvg_opacity.rb +5 -5
  128. data/doc/ex/rvg_pattern.rb +8 -8
  129. data/doc/ex/rvg_stroke_dasharray.rb +2 -2
  130. data/doc/ex/sepiatone.rb +0 -0
  131. data/doc/ex/shadow.rb +6 -6
  132. data/doc/ex/shear.rb +2 -2
  133. data/doc/ex/skewx.rb +8 -8
  134. data/doc/ex/skewy.rb +9 -9
  135. data/doc/ex/smile.rb +5 -4
  136. data/doc/ex/sparse_color.rb +0 -4
  137. data/doc/ex/splice.rb +1 -1
  138. data/doc/ex/stegano.rb +4 -5
  139. data/doc/ex/stroke_dasharray.rb +10 -10
  140. data/doc/ex/stroke_fill.rb +2 -2
  141. data/doc/ex/stroke_linecap.rb +12 -12
  142. data/doc/ex/stroke_linejoin.rb +12 -12
  143. data/doc/ex/stroke_width.rb +11 -11
  144. data/doc/ex/swirl.rb +2 -2
  145. data/doc/ex/text.rb +6 -6
  146. data/doc/ex/text01.rb +4 -4
  147. data/doc/ex/text_align.rb +5 -5
  148. data/doc/ex/text_antialias.rb +2 -2
  149. data/doc/ex/text_styles.rb +8 -8
  150. data/doc/ex/text_undercolor.rb +4 -4
  151. data/doc/ex/texture_fill_to_border.rb +8 -8
  152. data/doc/ex/texture_floodfill.rb +8 -8
  153. data/doc/ex/texturefill.rb +2 -2
  154. data/doc/ex/threshold.rb +2 -2
  155. data/doc/ex/to_blob.rb +1 -1
  156. data/doc/ex/translate.rb +8 -8
  157. data/doc/ex/transparent.rb +6 -6
  158. data/doc/ex/transpose.rb +0 -0
  159. data/doc/ex/transverse.rb +0 -0
  160. data/doc/ex/tref01.rb +6 -6
  161. data/doc/ex/triangle01.rb +2 -2
  162. data/doc/ex/trim.rb +2 -2
  163. data/doc/ex/tspan01.rb +5 -5
  164. data/doc/ex/tspan02.rb +5 -5
  165. data/doc/ex/tspan03.rb +5 -5
  166. data/doc/ex/unsharp_mask.rb +3 -3
  167. data/doc/ex/viewex.rb +5 -5
  168. data/doc/ex/vignette.rb +0 -0
  169. data/doc/ex/watermark.rb +6 -6
  170. data/doc/ex/wet_floor.rb +2 -2
  171. data/doc/ex/writing_mode01.rb +12 -12
  172. data/doc/ex/writing_mode02.rb +12 -12
  173. data/examples/constitute.rb +1 -1
  174. data/examples/crop_with_gravity.rb +5 -5
  175. data/examples/demo.rb +6 -7
  176. data/examples/describe.rb +8 -10
  177. data/examples/find_similar_region.rb +3 -3
  178. data/examples/histogram.rb +192 -201
  179. data/examples/identify.rb +62 -73
  180. data/examples/image_opacity.rb +0 -1
  181. data/examples/import_export.rb +1 -1
  182. data/examples/pattern_fill.rb +3 -4
  183. data/examples/rotating_text.rb +5 -4
  184. data/examples/spinner.rb +5 -5
  185. data/examples/thumbnail.rb +3 -3
  186. data/examples/vignette.rb +5 -5
  187. data/ext/RMagick/extconf.rb +213 -230
  188. data/ext/RMagick/rmagick.c +1 -0
  189. data/ext/RMagick/rmagick.h +26 -29
  190. data/ext/RMagick/rmdraw.c +3 -38
  191. data/ext/RMagick/rmenum.c +36 -0
  192. data/ext/RMagick/rmimage.c +166 -10
  193. data/ext/RMagick/rminfo.c +7 -2
  194. data/ext/RMagick/rmkinfo.c +247 -0
  195. data/ext/RMagick/rmmain.c +96 -0
  196. data/ext/RMagick/rmutil.c +4 -0
  197. data/lib/rmagick/version.rb +3 -3
  198. data/lib/rmagick_internal.rb +226 -308
  199. data/lib/rvg/clippath.rb +2 -4
  200. data/lib/rvg/container.rb +25 -22
  201. data/lib/rvg/deep_equal.rb +11 -11
  202. data/lib/rvg/describable.rb +2 -2
  203. data/lib/rvg/embellishable.rb +60 -66
  204. data/lib/rvg/misc.rb +122 -128
  205. data/lib/rvg/pathdata.rb +15 -17
  206. data/lib/rvg/rvg.rb +41 -44
  207. data/lib/rvg/stretchable.rb +22 -28
  208. data/lib/rvg/stylable.rb +10 -10
  209. data/lib/rvg/text.rb +164 -165
  210. data/lib/rvg/transformable.rb +15 -15
  211. data/lib/rvg/units.rb +2 -2
  212. data/rmagick.gemspec +9 -33
  213. data/spec/rmagick/draw_spec.rb +5 -6
  214. data/spec/rmagick/image/blue_shift_spec.rb +1 -3
  215. data/spec/rmagick/image/channel_entropy_spec.rb +9 -0
  216. data/spec/rmagick/image/composite_spec.rb +2 -4
  217. data/spec/rmagick/image/constitute_spec.rb +2 -4
  218. data/spec/rmagick/image/dispatch_spec.rb +1 -3
  219. data/spec/rmagick/image/from_blob_spec.rb +1 -3
  220. data/spec/rmagick/image/ping_spec.rb +1 -3
  221. data/spec/rmagick/image/properties_spec.rb +0 -2
  222. data/spec/rmagick/image/read_spec.rb +28 -0
  223. data/spec/spec_helper.rb +7 -1
  224. data/spec/support/issue_200/app.rb +8 -0
  225. data/test/Image1.rb +70 -70
  226. data/test/Image2.rb +369 -361
  227. data/test/Image3.rb +64 -63
  228. data/test/ImageList1.rb +796 -792
  229. data/test/ImageList2.rb +43 -44
  230. data/test/Image_attributes.rb +26 -48
  231. data/test/Import_Export.rb +71 -77
  232. data/test/Info.rb +30 -31
  233. data/test/Magick.rb +47 -46
  234. data/test/Pixel.rb +24 -24
  235. data/test/Preview.rb +7 -6
  236. data/test/test_all_basic.rb +15 -7
  237. data/test/tmpnam_test.rb +3 -3
  238. metadata +57 -18
@@ -1,11 +1,10 @@
1
-
2
- #!/usr/bin/env ruby -w
1
+ # !/usr/bin/env ruby -w
3
2
 
4
3
  require 'rmagick'
5
4
  require 'test/unit'
6
5
  require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
7
6
 
8
- class Info_UT < Test::Unit::TestCase
7
+ class InfoUT < Test::Unit::TestCase
9
8
  def setup
10
9
  @info = Magick::Image::Info.new
11
10
  end
@@ -58,7 +57,7 @@ class Info_UT < Test::Unit::TestCase
58
57
  red = Magick::Pixel.new(Magick::QuantumRange)
59
58
  assert_nothing_raised { @info.background_color = red }
60
59
  assert_equal('red', @info.background_color)
61
- img = Magick::Image.new(20,20) { self.background_color = 'red' }
60
+ img = Magick::Image.new(20, 20) { self.background_color = 'red' }
62
61
  assert_equal('red', img.background_color)
63
62
  end
64
63
 
@@ -67,14 +66,14 @@ class Info_UT < Test::Unit::TestCase
67
66
  red = Magick::Pixel.new(Magick::QuantumRange)
68
67
  assert_nothing_raised { @info.border_color = red }
69
68
  assert_equal('red', @info.border_color)
70
- img = Magick::Image.new(20,20) { self.border_color = 'red' }
69
+ img = Magick::Image.new(20, 20) { self.border_color = 'red' }
71
70
  assert_equal('red', img.border_color)
72
71
  end
73
72
 
74
73
  def caption
75
74
  assert_nothing_raised { @info.caption = 'string' }
76
75
  assert_equal('string', @info.caption)
77
- img = Magick::Image.new(20,20) { self.caption = 'string' }
76
+ img = Magick::Image.new(20, 20) { self.caption = 'string' }
78
77
  assert_equal('string', img.caption)
79
78
  end
80
79
 
@@ -87,8 +86,8 @@ class Info_UT < Test::Unit::TestCase
87
86
 
88
87
  def test_colorspace
89
88
  Magick::ColorspaceType.values.each do |cs|
90
- assert_nothing_raised {@info.colorspace = cs}
91
- assert_equal(cs, @info.colorspace)
89
+ assert_nothing_raised { @info.colorspace = cs }
90
+ assert_equal(cs, @info.colorspace)
92
91
  end
93
92
  end
94
93
 
@@ -99,8 +98,8 @@ class Info_UT < Test::Unit::TestCase
99
98
 
100
99
  def test_compression
101
100
  Magick::CompressionType.values.each do |v|
102
- assert_nothing_raised { @info.compression = v }
103
- assert_equal(v, @info.compression)
101
+ assert_nothing_raised { @info.compression = v }
102
+ assert_equal(v, @info.compression)
104
103
  end
105
104
  end
106
105
 
@@ -131,8 +130,8 @@ class Info_UT < Test::Unit::TestCase
131
130
 
132
131
  def test_dispose
133
132
  Magick::DisposeType.values.each do |v|
134
- assert_nothing_raised { @info.dispose = v }
135
- assert_equal(v, @info.dispose)
133
+ assert_nothing_raised { @info.dispose = v }
134
+ assert_equal(v, @info.dispose)
136
135
  end
137
136
  end
138
137
 
@@ -187,22 +186,22 @@ class Info_UT < Test::Unit::TestCase
187
186
 
188
187
  def test_gravity
189
188
  Magick::GravityType.values.each do |v|
190
- assert_nothing_raised { @info.gravity = v }
191
- assert_equal(v, @info.gravity)
189
+ assert_nothing_raised { @info.gravity = v }
190
+ assert_equal(v, @info.gravity)
192
191
  end
193
192
  end
194
193
 
195
194
  def test_image_type
196
195
  Magick::ImageType.values.each do |v|
197
- assert_nothing_raised { @info.image_type = v }
198
- assert_equal(v, @info.image_type)
196
+ assert_nothing_raised { @info.image_type = v }
197
+ assert_equal(v, @info.image_type)
199
198
  end
200
199
  end
201
200
 
202
201
  def test_interlace
203
202
  Magick::InterlaceType.values.each do |v|
204
- assert_nothing_raised { @info.interlace = v }
205
- assert_equal(v, @info.interlace)
203
+ assert_nothing_raised { @info.interlace = v }
204
+ assert_equal(v, @info.interlace)
206
205
  end
207
206
  end
208
207
 
@@ -216,17 +215,17 @@ class Info_UT < Test::Unit::TestCase
216
215
  red = Magick::Pixel.new(Magick::QuantumRange)
217
216
  assert_nothing_raised { @info.matte_color = red }
218
217
  assert_equal('red', @info.matte_color)
219
- img = Magick::Image.new(20,20) { self.matte_color = 'red' }
218
+ img = Magick::Image.new(20, 20) { self.matte_color = 'red' }
220
219
  assert_equal('red', img.matte_color)
221
220
  end
222
221
 
223
222
  def test_monitor
224
- assert_nothing_raised { @info.monitor = lambda {} }
223
+ assert_nothing_raised { @info.monitor = -> {} }
225
224
  monitor = proc do |mth, q, s|
226
- assert_equal('resize!', mth)
227
- assert_instance_of(Fixnum, q)
228
- assert_instance_of(Fixnum, s)
229
- true
225
+ assert_equal('resize!', mth)
226
+ assert_instance_of(Fixnum, q)
227
+ assert_instance_of(Fixnum, s)
228
+ true
230
229
  end
231
230
  img = Magick::Image.new(2000, 2000) { self.monitor = monitor }
232
231
  img.resize!(20, 20)
@@ -240,8 +239,8 @@ class Info_UT < Test::Unit::TestCase
240
239
 
241
240
  def test_orientation
242
241
  Magick::OrientationType.values.each do |v|
243
- assert_nothing_raised { @info.orientation = v }
244
- assert_equal(v, @info.orientation)
242
+ assert_nothing_raised { @info.orientation = v }
243
+ assert_equal(v, @info.orientation)
245
244
  end
246
245
  end
247
246
 
@@ -280,7 +279,7 @@ class Info_UT < Test::Unit::TestCase
280
279
  def test_size
281
280
  assert_nothing_raised { @info.size = '200x100' }
282
281
  assert_equal('200x100', @info.size)
283
- assert_nothing_raised { @info.size = Magick::Geometry.new(100,200) }
282
+ assert_nothing_raised { @info.size = Magick::Geometry.new(100, 200) }
284
283
  assert_equal('100x200', @info.size)
285
284
  end
286
285
 
@@ -307,14 +306,14 @@ class Info_UT < Test::Unit::TestCase
307
306
  end
308
307
 
309
308
  def test_texture
310
- img = Magick::Image.read('granite:') {self.size = '20x20' }
309
+ img = Magick::Image.read('granite:') { self.size = '20x20' }
311
310
  assert_nothing_raised { @info.texture = img.first }
312
311
  end
313
312
 
314
313
  def test_tile_offset
315
314
  assert_nothing_raised { @info.tile_offset = '200x100' }
316
315
  assert_equal('200x100', @info.tile_offset)
317
- assert_nothing_raised { @info.tile_offset = Magick::Geometry.new(100,200) }
316
+ assert_nothing_raised { @info.tile_offset = Magick::Geometry.new(100, 200) }
318
317
  assert_equal('100x200', @info.tile_offset)
319
318
  end
320
319
 
@@ -333,8 +332,8 @@ class Info_UT < Test::Unit::TestCase
333
332
 
334
333
  def test_units
335
334
  Magick::ResolutionType.values.each do |v|
336
- assert_nothing_raised { @info.units = v }
337
- assert_equal(v, @info.units)
335
+ assert_nothing_raised { @info.units = v }
336
+ assert_equal(v, @info.units)
338
337
  end
339
338
  end
340
339
 
@@ -1,5 +1,4 @@
1
-
2
- #!/usr/bin/env ruby -w
1
+ # !/usr/bin/env ruby -w
3
2
 
4
3
  require 'rmagick'
5
4
  require 'test/unit'
@@ -29,18 +28,18 @@ class Magick::AnchorType
29
28
  end
30
29
  end
31
30
 
32
- class Magick_UT < Test::Unit::TestCase
31
+ class MagickUT < Test::Unit::TestCase
33
32
  def test_colors
34
33
  res = nil
35
34
  assert_nothing_raised { res = Magick.colors }
36
35
  assert_instance_of(Array, res)
37
36
  res.each do |c|
38
- assert_instance_of(Magick::Color, c)
39
- assert_instance_of(String, c.name)
40
- assert_instance_of(Magick::ComplianceType, c.compliance)
41
- assert_instance_of(Magick::Pixel, c.color)
37
+ assert_instance_of(Magick::Color, c)
38
+ assert_instance_of(String, c.name)
39
+ assert_instance_of(Magick::ComplianceType, c.compliance)
40
+ assert_instance_of(Magick::Pixel, c.color)
42
41
  end
43
- Magick.colors {|c| assert_instance_of(Magick::Color, c) }
42
+ Magick.colors { |c| assert_instance_of(Magick::Color, c) }
44
43
  end
45
44
 
46
45
  # Test a few of the @@enumerator arrays in the Enum subclasses.
@@ -48,18 +47,18 @@ class Magick_UT < Test::Unit::TestCase
48
47
  def test_enumerators
49
48
  ary = nil
50
49
  assert_nothing_raised do
51
- ary = Magick::AlphaChannelType.enumerators
50
+ ary = Magick::AlphaChannelType.enumerators
52
51
  end
53
52
  assert_instance_of(Array, ary)
54
53
 
55
54
  assert_nothing_raised do
56
- ary = Magick::AlignType.enumerators
55
+ ary = Magick::AlignType.enumerators
57
56
  end
58
57
  assert_instance_of(Array, ary)
59
58
  assert_equal(4, ary.length)
60
59
 
61
60
  assert_nothing_raised do
62
- ary = Magick::AnchorType.enumerators
61
+ ary = Magick::AnchorType.enumerators
63
62
  end
64
63
  assert_instance_of(Array, ary)
65
64
  assert_equal(3, ary.length)
@@ -76,18 +75,18 @@ class Magick_UT < Test::Unit::TestCase
76
75
  assert_nothing_raised { res = Magick.fonts }
77
76
  assert_instance_of(Array, res)
78
77
  res.each do |f|
79
- assert_instance_of(Magick::Font, f)
80
- assert_instance_of(String, f.name)
81
- assert_instance_of(String, f.description) unless f.description.nil?
82
- assert_instance_of(String, f.family)
83
- assert_instance_of(Magick::StyleType, f.style)
84
- assert_instance_of(Magick::StretchType, f.stretch)
85
- assert_instance_of(Fixnum, f.weight)
86
- assert_instance_of(String, f.encoding) unless f.encoding.nil?
87
- assert_instance_of(String, f.foundry) unless f.foundry.nil?
88
- assert_instance_of(String, f.format) unless f.format.nil?
78
+ assert_instance_of(Magick::Font, f)
79
+ assert_instance_of(String, f.name)
80
+ assert_instance_of(String, f.description) unless f.description.nil?
81
+ assert_instance_of(String, f.family)
82
+ assert_instance_of(Magick::StyleType, f.style)
83
+ assert_instance_of(Magick::StretchType, f.stretch)
84
+ assert_instance_of(Fixnum, f.weight)
85
+ assert_instance_of(String, f.encoding) unless f.encoding.nil?
86
+ assert_instance_of(String, f.foundry) unless f.foundry.nil?
87
+ assert_instance_of(String, f.format) unless f.format.nil?
89
88
  end
90
- Magick.fonts {|f| assert_instance_of(Magick::Font, f) }
89
+ Magick.fonts { |f| assert_instance_of(Magick::Font, f) }
91
90
  end
92
91
 
93
92
  def test_formats
@@ -95,17 +94,19 @@ class Magick_UT < Test::Unit::TestCase
95
94
  assert_nothing_raised { res = Magick.formats }
96
95
  assert_instance_of(Hash, res)
97
96
  res.each do |f, v|
98
- assert_instance_of(String, f)
99
- assert_instance_of(String, v)
97
+ assert_instance_of(String, f)
98
+ assert_instance_of(String, v)
99
+ end
100
+ Magick.formats.each do |f, v|
101
+ assert_not_nil(f)
102
+ assert_not_nil(v)
100
103
  end
101
- Magick.formats.each { |f, v| assert_not_nil(f); assert_not_nil(v) }
102
104
  end
103
105
 
104
106
  def test_geometry
105
107
  g = nil
106
108
  gs = nil
107
109
  g2 = nil
108
- gs2 = nil
109
110
  assert_nothing_raised { g = Magick::Geometry.new }
110
111
  assert_nothing_raised { gs = g.to_s }
111
112
  assert_equal('', gs)
@@ -267,31 +268,31 @@ class Magick_UT < Test::Unit::TestCase
267
268
  def test_limit_resources
268
269
  cur = new = nil
269
270
 
270
- assert_nothing_raised {cur = Magick.limit_resource(:memory, 500)}
271
+ assert_nothing_raised { cur = Magick.limit_resource(:memory, 500) }
271
272
  assert_kind_of(Integer, cur)
272
- assert(cur > 1024 ** 2)
273
- assert_nothing_raised {new = Magick.limit_resource('memory')}
273
+ assert(cur > 1024**2)
274
+ assert_nothing_raised { new = Magick.limit_resource('memory') }
274
275
  assert_equal(500, new)
275
276
  Magick.limit_resource(:memory, cur)
276
277
 
277
- assert_nothing_raised {cur = Magick.limit_resource(:map, 3500)}
278
+ assert_nothing_raised { cur = Magick.limit_resource(:map, 3500) }
278
279
  assert_kind_of(Integer, cur)
279
- assert(cur > 1024 ** 2)
280
- assert_nothing_raised {new = Magick.limit_resource('map')}
280
+ assert(cur > 1024**2)
281
+ assert_nothing_raised { new = Magick.limit_resource('map') }
281
282
  assert_equal(3500, new)
282
283
  Magick.limit_resource(:map, cur)
283
284
 
284
- assert_nothing_raised {cur = Magick.limit_resource(:disk, 3*1024*1024*1024)}
285
+ assert_nothing_raised { cur = Magick.limit_resource(:disk, 3 * 1024 * 1024 * 1024) }
285
286
  assert_kind_of(Integer, cur)
286
- assert(cur > 1024 ** 2)
287
- assert_nothing_raised {new = Magick.limit_resource('disk')}
288
- assert_equal(3221225472, new)
287
+ assert(cur > 1024**2)
288
+ assert_nothing_raised { new = Magick.limit_resource('disk') }
289
+ assert_equal(3_221_225_472, new)
289
290
  Magick.limit_resource(:disk, cur)
290
291
 
291
- assert_nothing_raised {cur = Magick.limit_resource(:file, 500)}
292
+ assert_nothing_raised { cur = Magick.limit_resource(:file, 500) }
292
293
  assert_kind_of(Integer, cur)
293
294
  assert(cur > 512)
294
- assert_nothing_raised {new = Magick.limit_resource('file')}
295
+ assert_nothing_raised { new = Magick.limit_resource('file') }
295
296
  assert_equal(500, new)
296
297
  Magick.limit_resource(:file, cur)
297
298
 
@@ -303,19 +304,19 @@ class Magick_UT < Test::Unit::TestCase
303
304
 
304
305
  def test_trace_proc
305
306
  Magick.trace_proc = proc do |which, description, id, method|
306
- assert(which == :c)
307
- assert_instance_of(String, description)
308
- assert_instance_of(String, id)
309
- assert_equal(:initialize, method)
307
+ assert(which == :c)
308
+ assert_instance_of(String, description)
309
+ assert_instance_of(String, id)
310
+ assert_equal(:initialize, method)
310
311
  end
311
312
  begin
312
- img = Magick::Image.new(20,20)
313
+ Magick::Image.new(20, 20)
313
314
  ensure
314
- Magick.trace_proc = nil
315
+ Magick.trace_proc = nil
315
316
  end
316
317
  end
317
318
  end
318
319
 
319
- if __FILE__ == $PROGRAM_NAME
320
- Test::Unit::UI::Console::TestRunner.run(Magick_UT) unless RUBY_VERSION[/^1\.9|^2/]
320
+ if $PROGRAM_NAME == __FILE__
321
+ Test::Unit::UI::Console::TestRunner.run(MagickUT) unless RUBY_VERSION[/^1\.9|^2/]
321
322
  end
@@ -4,22 +4,22 @@ require 'rmagick'
4
4
  require 'test/unit'
5
5
  require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
6
6
 
7
- class Pixel_UT < Test::Unit::TestCase
7
+ class PixelUT < Test::Unit::TestCase
8
8
  def setup
9
9
  @pixel = Magick::Pixel.from_color('brown')
10
10
  end
11
11
 
12
12
  def test_hash
13
13
  hash = nil
14
- assert_nothing_raised { hash = @pixel.hash}
14
+ assert_nothing_raised { hash = @pixel.hash }
15
15
  assert_not_nil(hash)
16
- assert_equal(1385501952, hash)
16
+ assert_equal(1_385_501_952, hash)
17
17
 
18
18
  p = Magick::Pixel.new
19
19
  assert_equal(0, p.hash)
20
20
 
21
21
  p = Magick::Pixel.from_color('red')
22
- assert_equal(2139095040, p.hash)
22
+ assert_equal(2_139_095_040, p.hash)
23
23
 
24
24
  # Pixel.hash sacrifices the last bit of the opacity channel
25
25
  p = Magick::Pixel.new(0, 0, 0, 72)
@@ -60,29 +60,29 @@ class Pixel_UT < Test::Unit::TestCase
60
60
  assert_nothing_raised { @pixel.to_hsla }
61
61
 
62
62
  18.times do |h|
63
- 25.times do |s|
64
- 25.times do |l|
65
- 5.times do |a|
66
- args = [20*h, s+25, l+25, a/5.0]
67
- px = Magick::Pixel.from_hsla(*args)
68
- hsla = px.to_hsla
69
- #puts "[#{args.join(', ')}] = [#{hsla.join(', ')}]"
70
- # Handle cases where the result is very near 360
71
- #hsla[0] = ((hsla[0] + 0.005) % 360.0) - 0.005
72
- #hsla[1] = ((hsla[1] + 0.005) % 360.0) - 0.005
73
- #hsla[2] = ((hsla[2] + 0.005) % 360.0) - 0.005
74
- assert_in_delta(args[0], hsla[0], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
75
- assert_in_delta(args[1], hsla[1], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
76
- assert_in_delta(args[2], hsla[2], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
77
- assert_in_delta(args[3], hsla[3], 0.005, "expected #{args.inspect} got #{hsla.inspect}")
63
+ 25.times do |s|
64
+ 25.times do |l|
65
+ 5.times do |a|
66
+ args = [20 * h, s + 25, l + 25, a / 5.0]
67
+ px = Magick::Pixel.from_hsla(*args)
68
+ hsla = px.to_hsla
69
+ # puts "[#{args.join(', ')}] = [#{hsla.join(', ')}]"
70
+ # Handle cases where the result is very near 360
71
+ # hsla[0] = ((hsla[0] + 0.005) % 360.0) - 0.005
72
+ # hsla[1] = ((hsla[1] + 0.005) % 360.0) - 0.005
73
+ # hsla[2] = ((hsla[2] + 0.005) % 360.0) - 0.005
74
+ assert_in_delta(args[0], hsla[0], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
75
+ assert_in_delta(args[1], hsla[1], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
76
+ assert_in_delta(args[2], hsla[2], 0.25, "expected #{args.inspect} got #{hsla.inspect}")
77
+ assert_in_delta(args[3], hsla[3], 0.005, "expected #{args.inspect} got #{hsla.inspect}")
78
+ end
79
+ end
78
80
  end
79
- end
80
- end
81
81
  end
82
82
 
83
83
  # test percentages
84
- args = ['20%','20%','20%','20%']
85
- args2 = [360.0/5,255.0/5,255.0/5,1.0/5]
84
+ args = ['20%', '20%', '20%', '20%']
85
+ args2 = [360.0 / 5, 255.0 / 5, 255.0 / 5, 1.0 / 5]
86
86
  px = Magick::Pixel.from_hsla(*args)
87
87
  hsla = px.to_hsla
88
88
  px2 = Magick::Pixel.from_hsla(*args2)
@@ -91,7 +91,7 @@ class Pixel_UT < Test::Unit::TestCase
91
91
  assert_in_delta(hsla[0], hsla2[0], 0.25, "#{hsla.inspect} != #{hsla2.inspect} with args: #{args.inspect} and #{args2.inspect}")
92
92
  assert_in_delta(hsla[1], hsla2[1], 0.25, "#{hsla.inspect} != #{hsla2.inspect} with args: #{args.inspect} and #{args2.inspect}")
93
93
  assert_in_delta(hsla[2], hsla2[2], 0.25, "#{hsla.inspect} != #{hsla2.inspect} with args: #{args.inspect} and #{args2.inspect}")
94
- assert_in_delta(hsla[3], hsla2[3], 0.005, "#{hsla.inspect} != #{hsla2.inspect} with args: #{args.inspect} and #{args2.inspect}")
94
+ assert_in_delta(hsla[3], hsla2[3], 0.005, "#{hsla.inspect} != #{hsla2.inspect} with args: #{args.inspect} and #{args2.inspect}")
95
95
  end
96
96
 
97
97
  def test_to_color
@@ -4,7 +4,7 @@ require 'rmagick'
4
4
  require 'test/unit'
5
5
  require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
6
6
 
7
- class Preview_UT < Test::Unit::TestCase
7
+ class PreviewUT < Test::Unit::TestCase
8
8
  def test_preview
9
9
  preview_types = [
10
10
  Magick::RotatePreview,
@@ -35,9 +35,10 @@ class Preview_UT < Test::Unit::TestCase
35
35
  Magick::WavePreview,
36
36
  Magick::OilPaintPreview,
37
37
  Magick::CharcoalDrawingPreview,
38
- Magick::JPEGPreview ]
38
+ Magick::JPEGPreview
39
+ ]
39
40
 
40
- hat = Magick::Image.read(IMAGES_DIR+'/Flower_Hat.jpg').first
41
+ hat = Magick::Image.read(IMAGES_DIR + '/Flower_Hat.jpg').first
41
42
  assert_nothing_raised do
42
43
  prev = hat.preview(Magick::RotatePreview)
43
44
  assert_instance_of(Magick::Image, prev)
@@ -51,7 +52,7 @@ class Preview_UT < Test::Unit::TestCase
51
52
  end
52
53
  end
53
54
 
54
- if __FILE__ == $PROGRAM_NAME
55
- IMAGES_DIR = '../doc/ex/images'
56
- Test::Unit::UI::Console::TestRunner.run(Preview_UT) unless RUBY_VERSION[/^1\.9|^2/]
55
+ if $PROGRAM_NAME == __FILE__
56
+ IMAGES_DIR = '../doc/ex/images'
57
+ Test::Unit::UI::Console::TestRunner.run(PreviewUT) unless RUBY_VERSION[/^1\.9|^2/]
57
58
  end