pnm 0.5.2 → 0.6.1

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
  SHA256:
3
- metadata.gz: 66de49354358fed31c8299381599bb8b16d87d2143e2102ca61da00e6b8b2927
4
- data.tar.gz: 2bd7e0d7491be12b5562c3a1de19ee7e538d95c3535fc9bb92723726b5e5787c
3
+ metadata.gz: fdfdb7ac32419e9381856654116f77070fabb87713e2353c10230fb6ac9c79c9
4
+ data.tar.gz: 06042a5b1c3d26d5b4e982b3e2e4983b652d1e1ffab8987d5f8b183a017c4abb
5
5
  SHA512:
6
- metadata.gz: bd83d15feb8b65b28b43f64cd48ab23a5e3f710a991f781c43d6d74bc9ea9a02cb905d61bae70af1fe2476c551ece310050eccd0210acb5701d87efb40d61173
7
- data.tar.gz: 574e62b56e1ac1fea7a9110f1c01c805f373bfafd50210bb2145fca4086054d7d1ace113d1e46eadfe0b5c9314b3ca221168cdc2dba2e7168742615a7462e728
6
+ metadata.gz: 17970b6a53282e449e76f9225e65c914f92084e4060b5fbe3b9bbbd56cae9ae830e122fbf8ed0bbb321bf443ef1c9538d4b8a2b859759528aa8862d479375796
7
+ data.tar.gz: b66f7f50567bb137a5b091293c7b77206966e570e300157a0ebde66647e46f2c09d07cb093499f3527a5b6149d01a0f88baa235c5450e61d9b0ba02db2a2cb5e
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  PNM - A Ruby library for PNM image files (PBM, PGM, PPM)
2
2
  ========================================================
3
3
 
4
+ ![CI](https://github.com/stomar/pnm/actions/workflows/ci.yml/badge.svg)
5
+
4
6
  PNM is a pure [Ruby][Ruby] library for creating, reading,
5
7
  and writing of `PNM` image files (Portable Anymap):
6
8
 
@@ -26,11 +28,11 @@ require "pnm"
26
28
  pixels = [[ 0, 10, 20],
27
29
  [10, 20, 30]]
28
30
 
29
- # optional settings
30
- options = { maxgray: 30, comment: "Test Image" }
31
-
32
31
  # create the image object
33
- image = PNM.create(pixels, options)
32
+ image = PNM.create(pixels)
33
+
34
+ # create the image with additional optional settings
35
+ image = PNM.create(pixels, maxgray: 30, comment: "Test Image")
34
36
 
35
37
  # retrieve some image properties
36
38
  image.info # => "PGM 3x2 Grayscale"
@@ -50,10 +52,10 @@ Write an image to a file:
50
52
 
51
53
  ``` ruby
52
54
  image.write("test.pgm")
53
- image.write_with_extension("test") # adds the correct file extension
55
+ image.write("test", add_extension: true) # adds the appropriate file extension
54
56
 
55
- # use ASCII or "plain" format (default is binary)
56
- image.write("test.pgm", :ascii)
57
+ # use ASCII or "plain" format (default is :binary)
58
+ image.write("test.pgm", encoding: :ascii)
57
59
 
58
60
  # write to an I/O stream
59
61
  File.open("test.pgm", "w") {|f| image.write(f) }
@@ -98,11 +100,9 @@ Requirements
98
100
 
99
101
  - PNM has been tested with
100
102
 
101
- - Ruby 2.6, 2.5, 2.4, 2.3, 2.2, 2.1,
102
- - Ruby 2.0.0,
103
- - Ruby 1.9.3,
104
- - JRuby 1.7.19,
105
- - Rubinius 2.5.2.
103
+ - Ruby 3.1, 3.0,
104
+ - Ruby 2.7, 2.6, 2.5, 2.4, 2.3, 2.2, 2.1, 2.0.0,
105
+ - JRuby 9.3.4.0.
106
106
 
107
107
  Documentation
108
108
  -------------
@@ -118,7 +118,7 @@ Report bugs on the PNM home page: <https://github.com/stomar/pnm/>
118
118
  License
119
119
  -------
120
120
 
121
- Copyright &copy; 2013-2019 Marcus Stollsteimer
121
+ Copyright &copy; 2013-2022 Marcus Stollsteimer
122
122
 
123
123
  `PNM` is free software: you can redistribute it and/or modify
124
124
  it under the terms of the GNU General Public License version 3 or later (GPLv3+),
data/Rakefile CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # rakefile for the PNM library.
4
4
  #
5
- # Copyright (C) 2013-2019 Marcus Stollsteimer
5
+ # Copyright (C) 2013-2022 Marcus Stollsteimer
6
6
 
7
7
  require "rake/testtask"
8
8
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  # bm_converter.rb: Benchmarks for the PNM library.
5
5
  #
6
- # Copyright (C) 2013-2019 Marcus Stollsteimer
6
+ # Copyright (C) 2013-2022 Marcus Stollsteimer
7
7
 
8
8
  require "benchmark"
9
9
  require_relative "../lib/pnm"
data/lib/pnm/converter.rb CHANGED
@@ -11,7 +11,7 @@ module PNM
11
11
  def self.byte_width(type, width)
12
12
  case type
13
13
  when :pbm
14
- (width - 1) / 8 + 1
14
+ ((width - 1) / 8) + 1
15
15
  when :pgm
16
16
  width
17
17
  when :ppm
@@ -107,14 +107,14 @@ module PNM
107
107
 
108
108
  def self.convert_to_integers(data, type)
109
109
  values_as_string = if type == :pbm
110
- data.gsub(/[ \t\r\n]+/, "").split("")
110
+ data.gsub(/[ \t\r\n]+/, "").chars
111
111
  else
112
112
  data.gsub(/\A[ \t\r\n]+/, "").split(/[ \t\r\n]+/)
113
113
  end
114
114
 
115
115
  values_as_string.map {|value| Integer(value) }
116
- rescue ::ArgumentError => error
117
- raise unless error.message.start_with?("invalid value for Integer")
116
+ rescue ::ArgumentError => e
117
+ raise unless e.message.start_with?("invalid value for Integer")
118
118
 
119
119
  raise PNM::DataError, "invalid pixel value: Integer expected"
120
120
  end
data/lib/pnm/image.rb CHANGED
@@ -38,20 +38,16 @@ module PNM
38
38
  # This method should be called as PNM.create.
39
39
  # See there for a description of pixel data formats
40
40
  # and available options.
41
- def self.create(pixels, options = {})
41
+ def self.create(pixels, type: nil, maxgray: nil, comment: nil)
42
42
  assert_valid_array(pixels)
43
- assert_valid_maxgray(options[:maxgray])
44
- assert_valid_comment(options[:comment])
43
+ assert_valid_maxgray(maxgray)
44
+ assert_valid_comment(comment)
45
45
 
46
- type = sanitize_and_assert_valid_type(options[:type])
47
- type ||= detect_type(pixels, options[:maxgray])
46
+ type = sanitize_and_assert_valid_type(type)
47
+ type ||= detect_type(pixels, maxgray)
48
48
 
49
49
  # except for type detection, the maxgray option must be ignored for PBM
50
- maxgray = if type == :pbm
51
- nil
52
- else
53
- options[:maxgray]
54
- end
50
+ maxgray = nil if type == :pbm
55
51
 
56
52
  image_class = case type
57
53
  when :pbm
@@ -62,7 +58,7 @@ module PNM
62
58
  PPMImage
63
59
  end
64
60
 
65
- image_class.new(pixels, maxgray, options[:comment])
61
+ image_class.new(pixels, maxgray, comment)
66
62
  end
67
63
 
68
64
  class << self
@@ -87,35 +83,33 @@ module PNM
87
83
  @comment.freeze
88
84
  end
89
85
 
90
- # Writes the image to +file+ (a filename or an IO object),
91
- # using the specified encoding.
92
- # Valid encodings are +:binary+ (default) and +:ascii+.
86
+ # Writes the image to +file+ (a filename or an IO object).
87
+ #
88
+ # When +add_extension+ is set to +true+ (default: +false+)
89
+ # the appropriate file extension is added to the provided filename
90
+ # (+.pbm+, +.pgm+, or +.ppm+).
91
+ #
92
+ # The encoding can be set using the +encoding+ keyword argument,
93
+ # valid options are +:binary+ (default) and +:ascii+.
93
94
  #
94
95
  # Returns the number of bytes written.
95
- def write(file, encoding = :binary)
96
- content = if encoding == :ascii
96
+ def write(file, add_extension: false, encoding: :binary)
97
+ content = case encoding
98
+ when :ascii
97
99
  to_ascii
98
- elsif encoding == :binary
100
+ when :binary
99
101
  to_binary
100
102
  end
101
103
 
102
104
  if file.is_a?(String)
103
- File.binwrite(file, content)
105
+ filename = add_extension ? "#{file}.#{type}" : file
106
+ File.binwrite(filename, content)
104
107
  else
105
108
  file.binmode
106
109
  file.write content
107
110
  end
108
111
  end
109
112
 
110
- # Adds the appropriate file extension to +basename+
111
- # (+.pbm+, +.pgm+, or +.ppm+)
112
- # and writes the image to the resulting filename.
113
- #
114
- # Any options are passed on to #write, which is used internally.
115
- def write_with_extension(basename, *args)
116
- write("#{basename}.#{type}", *args)
117
- end
118
-
119
113
  # Returns a string with a short image format description.
120
114
  def info
121
115
  "#{type.to_s.upcase} #{width}x#{height} #{type_string}"
@@ -208,7 +202,7 @@ module PNM
208
202
 
209
203
  type = type.to_sym if type.is_a?(String)
210
204
 
211
- unless [:pbm, :pgm, :ppm].include?(type)
205
+ unless %i[pbm pgm ppm].include?(type)
212
206
  msg = "invalid image type - #{type.inspect}"
213
207
  raise PNM::ArgumentError, msg
214
208
  end
@@ -292,7 +286,6 @@ module PNM
292
286
  end
293
287
  end
294
288
 
295
-
296
289
  # Class for +PBM+ images. See the Image class for documentation.
297
290
  class PBMImage < Image
298
291
 
@@ -323,7 +316,6 @@ module PNM
323
316
  end
324
317
  end
325
318
 
326
-
327
319
  # Class for +PGM+ images. See the Image class for documentation.
328
320
  class PGMImage < Image
329
321
 
@@ -354,7 +346,6 @@ module PNM
354
346
  end
355
347
  end
356
348
 
357
-
358
349
  # Class for +PPM+ images. See the Image class for documentation.
359
350
  class PPMImage < Image
360
351
 
data/lib/pnm/parser.rb CHANGED
@@ -22,7 +22,7 @@ module PNM
22
22
  content = content.dup
23
23
 
24
24
  magic_number = nil
25
- tokens = []
25
+ tokens = []
26
26
  comments = []
27
27
 
28
28
  until magic_number
@@ -50,17 +50,17 @@ module PNM
50
50
 
51
51
  width, height, maxgray = tokens
52
52
 
53
- assert_integer(width, "width")
54
- assert_integer(height, "height")
53
+ assert_integer(width, "width")
54
+ assert_integer(height, "height")
55
55
  assert_integer(maxgray, "maxgray") if maxgray
56
56
 
57
- width = width.to_i
58
- height = height.to_i
57
+ width = width.to_i
58
+ height = height.to_i
59
59
  maxgray = maxgray.to_i if maxgray
60
60
 
61
- assert_value(width, "width") {|x| x > 0 }
62
- assert_value(height, "height") {|x| x > 0 }
63
- assert_value(maxgray, "maxgray") {|x| x > 0 && x <= 255 } if maxgray
61
+ assert_positive(width, "width")
62
+ assert_positive(height, "height")
63
+ assert_in_maxgray_range(maxgray) if maxgray
64
64
 
65
65
  result = {
66
66
  magic_number: magic_number,
@@ -114,10 +114,17 @@ module PNM
114
114
  raise PNM::ParserError, msg
115
115
  end
116
116
 
117
- def self.assert_value(value, name)
118
- return if yield(value)
117
+ def self.assert_positive(value, name)
118
+ return if value > 0
119
119
 
120
- msg = "invalid #{name} value - `#{value}'"
120
+ msg = "#{name} must be greater than 0 - `#{value}'"
121
+ raise PNM::ParserError, msg
122
+ end
123
+
124
+ def self.assert_in_maxgray_range(value)
125
+ return if value > 0 && value <= 255
126
+
127
+ msg = "invalid maxgray value - `#{value}'"
121
128
  raise PNM::ParserError, msg
122
129
  end
123
130
  end
data/lib/pnm/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PNM
4
- VERSION = "0.5.2"
5
- DATE = "2019-02-09"
4
+ VERSION = "0.6.1"
5
+ DATE = "2022-05-09"
6
6
  end
data/lib/pnm.rb CHANGED
@@ -34,11 +34,11 @@ require_relative "pnm/exceptions"
34
34
  # pixels = [[ 0, 10, 20],
35
35
  # [10, 20, 30]]
36
36
  #
37
- # # optional settings
38
- # options = { maxgray: 30, comment: "Test Image" }
39
- #
40
37
  # # create the image object
41
- # image = PNM.create(pixels, options)
38
+ # image = PNM.create(pixels)
39
+ #
40
+ # # create the image with additional optional settings
41
+ # image = PNM.create(pixels, maxgray: 30, comment: "Test Image")
42
42
  #
43
43
  # # retrieve some image properties
44
44
  # image.info # => "PGM 3x2 Grayscale"
@@ -56,10 +56,10 @@ require_relative "pnm/exceptions"
56
56
  # Write an image to a file:
57
57
  #
58
58
  # image.write("test.pgm")
59
- # image.write_with_extension("test") # adds the correct file extension
59
+ # image.write("test", add_extension: true) # adds the appropriate file extension
60
60
  #
61
- # # use ASCII or "plain" format (default is binary)
62
- # image.write("test.pgm", :ascii)
61
+ # # use ASCII or "plain" format (default is :binary)
62
+ # image.write("test.pgm", encoding: :ascii)
63
63
  #
64
64
  # # write to an I/O stream
65
65
  # File.open("test.pgm", "w") {|f| image.write(f) }
@@ -87,7 +87,7 @@ require_relative "pnm/exceptions"
87
87
  #
88
88
  # == Author
89
89
  #
90
- # Copyright (C) 2013-2019 Marcus Stollsteimer
90
+ # Copyright (C) 2013-2022 Marcus Stollsteimer
91
91
  #
92
92
  # License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
93
93
  #
@@ -98,7 +98,7 @@ module PNM
98
98
  TAGLINE = "create/read/write PNM image files (PBM, PGM, PPM)"
99
99
 
100
100
  COPYRIGHT = <<-TEXT.gsub(/^ +/, "")
101
- Copyright (C) 2013-2019 Marcus Stollsteimer.
101
+ Copyright (C) 2013-2022 Marcus Stollsteimer.
102
102
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
103
103
  This is free software: you are free to change and redistribute it.
104
104
  There is NO WARRANTY, to the extent permitted by law.
@@ -119,20 +119,7 @@ module PNM
119
119
 
120
120
  content = Parser.parse(raw_data)
121
121
 
122
- type, encoding = case content[:magic_number]
123
- when "P1"
124
- [:pbm, :ascii]
125
- when "P2"
126
- [:pgm, :ascii]
127
- when "P3"
128
- [:ppm, :ascii]
129
- when "P4"
130
- [:pbm, :binary]
131
- when "P5"
132
- [:pgm, :binary]
133
- when "P6"
134
- [:ppm, :binary]
135
- end
122
+ type, encoding = type_and_encoding[content[:magic_number]]
136
123
 
137
124
  width = content[:width]
138
125
  height = content[:height]
@@ -143,10 +130,9 @@ module PNM
143
130
  Converter.binary2array(type, width, height, content[:data])
144
131
  end
145
132
 
146
- options = { type: type, maxgray: maxgray }
147
- options[:comment] = content[:comments].join("\n") if content[:comments]
133
+ comment = content[:comments].join("\n") if content[:comments]
148
134
 
149
- create(pixels, options)
135
+ create(pixels, type: type, maxgray: maxgray, comment: comment)
150
136
  end
151
137
 
152
138
  # Creates an image from a two-dimensional array of bilevel,
@@ -162,7 +148,7 @@ module PNM
162
148
  # corresponding to red, green, and blue (RGB);
163
149
  # a value of 0 means that the color is turned off.
164
150
  #
165
- # Optional settings that can be specified in the +options+ hash:
151
+ # Optional settings:
166
152
  #
167
153
  # +type+:: The type of the image (+:pbm+, +:pgm+, or +:ppm+).
168
154
  # By explicitly setting +type+, PGM images can be
@@ -180,8 +166,8 @@ module PNM
180
166
  # +comment+:: A multiline comment string.
181
167
  #
182
168
  # Returns a PNM::Image object.
183
- def self.create(pixels, options = {})
184
- Image.create(pixels, options)
169
+ def self.create(pixels, type: nil, maxgray: nil, comment: nil)
170
+ Image.create(pixels, type: type, maxgray: maxgray, comment: comment)
185
171
  end
186
172
 
187
173
  # @private
@@ -192,4 +178,16 @@ module PNM
192
178
  ppm: { ascii: "P3", binary: "P6" }
193
179
  }
194
180
  end
181
+
182
+ # @private
183
+ def self.type_and_encoding # :nodoc:
184
+ {
185
+ "P1" => %i[pbm ascii],
186
+ "P2" => %i[pgm ascii],
187
+ "P3" => %i[ppm ascii],
188
+ "P4" => %i[pbm binary],
189
+ "P5" => %i[pgm binary],
190
+ "P6" => %i[ppm binary]
191
+ }
192
+ end
195
193
  end
data/pnm.gemspec CHANGED
@@ -25,10 +25,7 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.license = "GPL-3.0"
27
27
 
28
- s.required_ruby_version = ">= 1.9.3"
29
-
30
- s.add_development_dependency "minitest", ">= 5.0"
31
- s.add_development_dependency "rake", ">= 10.0"
28
+ s.required_ruby_version = ">= 2.0.0"
32
29
 
33
30
  s.require_paths = ["lib"]
34
31
 
data/test/backports.rb ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PNM
4
+ module Backports # :nodoc:
5
+ module Minitest # :nodoc:
6
+
7
+ # Provides workaround for missing value wrappers in minitest < 5.6.0.
8
+ def _(value = nil, &block)
9
+ block || value
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+
16
+ if Gem.loaded_specs["minitest"].version < Gem::Version.new("5.6.0")
17
+ warn "Using workaround for missing value wrappers in minitest < 5.6.0."
18
+ MiniTest::Spec.send(:include, PNM::Backports::Minitest)
19
+ end
@@ -2,11 +2,13 @@
2
2
 
3
3
  # test_converter.rb: Unit tests for the PNM library.
4
4
  #
5
- # Copyright (C) 2013-2019 Marcus Stollsteimer
5
+ # Copyright (C) 2013-2022 Marcus Stollsteimer
6
6
 
7
7
  require "minitest/autorun"
8
8
  require "pnm/converter"
9
9
 
10
+ require_relative "backports"
11
+
10
12
 
11
13
  describe PNM::Converter do
12
14
 
@@ -56,7 +58,7 @@ describe PNM::Converter do
56
58
  data = @pbm[:ascii]
57
59
  expected = @pbm[:array]
58
60
 
59
- @converter.ascii2array(:pbm, width, height, data).must_equal expected
61
+ _(@converter.ascii2array(:pbm, width, height, data)).must_equal expected
60
62
  end
61
63
 
62
64
  it "can convert from ASCII encoded PGM data" do
@@ -65,7 +67,7 @@ describe PNM::Converter do
65
67
  data = @pgm[:ascii]
66
68
  expected = @pgm[:array]
67
69
 
68
- @converter.ascii2array(:pgm, width, height, data).must_equal expected
70
+ _(@converter.ascii2array(:pgm, width, height, data)).must_equal expected
69
71
  end
70
72
 
71
73
  it "can convert from ASCII encoded PPM data" do
@@ -74,7 +76,7 @@ describe PNM::Converter do
74
76
  data = @ppm[:ascii]
75
77
  expected = @ppm[:array]
76
78
 
77
- @converter.ascii2array(:ppm, width, height, data).must_equal expected
79
+ _(@converter.ascii2array(:ppm, width, height, data)).must_equal expected
78
80
  end
79
81
 
80
82
  it "accepts ASCII encoded PBM data with omitted whitespace" do
@@ -83,7 +85,7 @@ describe PNM::Converter do
83
85
  data = " 010100\n000110"
84
86
  expected = [[0, 1, 0, 1], [0, 0, 0, 0], [0, 1, 1, 0]]
85
87
 
86
- @converter.ascii2array(:pbm, width, height, data).must_equal expected
88
+ _(@converter.ascii2array(:pbm, width, height, data)).must_equal expected
87
89
  end
88
90
 
89
91
  it "accepts ASCII encoded PGM data with arbitrary whitespace" do
@@ -92,7 +94,7 @@ describe PNM::Converter do
92
94
  data = " \n 10 90\t170\r250\n90 \t170 250 \t\r\n\t 10\n\n\n170\n250\n10\n90\n"
93
95
  expected = [[10, 90, 170, 250], [90, 170, 250, 10], [170, 250, 10, 90]]
94
96
 
95
- @converter.ascii2array(:pgm, width, height, data).must_equal expected
97
+ _(@converter.ascii2array(:pgm, width, height, data)).must_equal expected
96
98
  end
97
99
 
98
100
  it "can convert from binary encoded PBM data (width 6)" do
@@ -101,7 +103,7 @@ describe PNM::Converter do
101
103
  data = @pbm6[:binary]
102
104
  expected = @pbm6[:array]
103
105
 
104
- @converter.binary2array(:pbm, width, height, data).must_equal expected
106
+ _(@converter.binary2array(:pbm, width, height, data)).must_equal expected
105
107
  end
106
108
 
107
109
  it "can convert from binary encoded PBM data (width 14)" do
@@ -110,7 +112,7 @@ describe PNM::Converter do
110
112
  data = @pbm14[:binary]
111
113
  expected = @pbm14[:array]
112
114
 
113
- @converter.binary2array(:pbm, width, height, data).must_equal expected
115
+ _(@converter.binary2array(:pbm, width, height, data)).must_equal expected
114
116
  end
115
117
 
116
118
  it "can convert from binary encoded PGM data" do
@@ -119,7 +121,7 @@ describe PNM::Converter do
119
121
  data = @pgm[:binary]
120
122
  expected = @pgm[:array]
121
123
 
122
- @converter.binary2array(:pgm, width, height, data).must_equal expected
124
+ _(@converter.binary2array(:pgm, width, height, data)).must_equal expected
123
125
  end
124
126
 
125
127
  it "can convert from binary encoded PPM data" do
@@ -128,82 +130,83 @@ describe PNM::Converter do
128
130
  data = @ppm[:binary]
129
131
  expected = @ppm[:array]
130
132
 
131
- @converter.binary2array(:ppm, width, height, data).must_equal expected
133
+ _(@converter.binary2array(:ppm, width, height, data)).must_equal expected
132
134
  end
133
135
 
134
136
  it "accepts an additional whitespace character for binary encoded data" do
135
137
  width = @pbm14[:width]
136
138
  height = @pbm14[:height]
137
- data = @pbm14[:binary] + "\t"
139
+ data = @pbm14[:binary].dup << "\t"
138
140
  expected = @pbm14[:array]
139
141
 
140
- @converter.binary2array(:pbm, width, height, data).must_equal expected
142
+ refute_equal data, @pbm14[:binary]
143
+ _(@converter.binary2array(:pbm, width, height, data)).must_equal expected
141
144
  end
142
145
 
143
146
  it "can convert to ASCII encoded PBM data" do
144
147
  data = @pbm[:array]
145
148
  expected = @pbm[:ascii]
146
149
 
147
- @converter.array2ascii(data).must_equal expected
150
+ _(@converter.array2ascii(data)).must_equal expected
148
151
  end
149
152
 
150
153
  it "can convert to ASCII encoded PGM data" do
151
154
  data = @pgm[:array]
152
155
  expected = @pgm[:ascii]
153
156
 
154
- @converter.array2ascii(data).must_equal expected
157
+ _(@converter.array2ascii(data)).must_equal expected
155
158
  end
156
159
 
157
160
  it "can convert to ASCII encoded PPM data" do
158
161
  data = @ppm[:array]
159
162
  expected = @ppm[:ascii]
160
163
 
161
- @converter.array2ascii(data).must_equal expected
164
+ _(@converter.array2ascii(data)).must_equal expected
162
165
  end
163
166
 
164
167
  it "can convert to binary encoded PBM data (width 6)" do
165
168
  data = @pbm6[:array]
166
169
  expected = @pbm6[:binary]
167
170
 
168
- @converter.array2binary(:pbm, data).must_equal expected
171
+ _(@converter.array2binary(:pbm, data)).must_equal expected
169
172
  end
170
173
 
171
174
  it "can convert to binary encoded PBM data (width 14)" do
172
175
  data = @pbm14[:array]
173
176
  expected = @pbm14[:binary]
174
177
 
175
- @converter.array2binary(:pbm, data).must_equal expected
178
+ _(@converter.array2binary(:pbm, data)).must_equal expected
176
179
  end
177
180
 
178
181
  it "can convert to binary encoded PGM data" do
179
182
  data = @pgm[:array]
180
183
  expected = @pgm[:binary]
181
184
 
182
- @converter.array2binary(:pgm, data).must_equal expected
185
+ _(@converter.array2binary(:pgm, data)).must_equal expected
183
186
  end
184
187
 
185
188
  it "can convert to binary encoded PPM data" do
186
189
  data = @ppm[:array]
187
190
  expected = @ppm[:binary]
188
191
 
189
- @converter.array2binary(:ppm, data).must_equal expected
192
+ _(@converter.array2binary(:ppm, data)).must_equal expected
190
193
  end
191
194
 
192
195
  it "can calculate correct byte widths for a PBM image" do
193
- @converter.byte_width(:pbm, 0).must_equal 0
194
- @converter.byte_width(:pbm, 1).must_equal 1
195
- @converter.byte_width(:pbm, 7).must_equal 1
196
- @converter.byte_width(:pbm, 8).must_equal 1
197
- @converter.byte_width(:pbm, 9).must_equal 2
198
- @converter.byte_width(:pbm, 64).must_equal 8
199
- @converter.byte_width(:pbm, 65).must_equal 9
196
+ _(@converter.byte_width(:pbm, 0)).must_equal 0
197
+ _(@converter.byte_width(:pbm, 1)).must_equal 1
198
+ _(@converter.byte_width(:pbm, 7)).must_equal 1
199
+ _(@converter.byte_width(:pbm, 8)).must_equal 1
200
+ _(@converter.byte_width(:pbm, 9)).must_equal 2
201
+ _(@converter.byte_width(:pbm, 64)).must_equal 8
202
+ _(@converter.byte_width(:pbm, 65)).must_equal 9
200
203
  end
201
204
 
202
205
  it "can calculate correct byte widths for a PGM image" do
203
- @converter.byte_width(:pgm, 13).must_equal 13
206
+ _(@converter.byte_width(:pgm, 13)).must_equal 13
204
207
  end
205
208
 
206
209
  it "can calculate correct byte widths for a PPM image" do
207
- @converter.byte_width(:ppm, 13).must_equal 39
210
+ _(@converter.byte_width(:ppm, 13)).must_equal 39
208
211
  end
209
212
  end