pnm 0.6.0 → 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: b5d51775ecf00c43299084927b3ce8e0fb182127accb347f25806a840e7389a4
4
- data.tar.gz: 0ac3e779bb1af09853cf6429fdb0fe5ec1a6d5e951eaf0f227e97e7c81b9f053
3
+ metadata.gz: fdfdb7ac32419e9381856654116f77070fabb87713e2353c10230fb6ac9c79c9
4
+ data.tar.gz: 06042a5b1c3d26d5b4e982b3e2e4983b652d1e1ffab8987d5f8b183a017c4abb
5
5
  SHA512:
6
- metadata.gz: aa8584a19eb7f6aad9513cc379a1700dfe9e1f5b9e58feaba2ae80e18c670050f9ba3fbd39f7528f3bad2bd59eb31ba491ae0f8673669454cbae92b4f996c416
7
- data.tar.gz: 87e0d5751baa549e9f2f14be763d6b77a40bde876c23f9ee44df5ef8b1ec642024091e6d06e32172aef09e33323bca2cf5f1945e8cecf7e7aa9945629f448811
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
 
@@ -98,9 +100,9 @@ Requirements
98
100
 
99
101
  - PNM has been tested with
100
102
 
101
- - Ruby 2.7
102
- - Ruby 2.6, 2.5, 2.4, 2.3, 2.2, 2.1, 2.0.0,
103
- - JRuby 9.2.13.0.
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.
104
106
 
105
107
  Documentation
106
108
  -------------
@@ -116,7 +118,7 @@ Report bugs on the PNM home page: <https://github.com/stomar/pnm/>
116
118
  License
117
119
  -------
118
120
 
119
- Copyright &copy; 2013-2020 Marcus Stollsteimer
121
+ Copyright &copy; 2013-2022 Marcus Stollsteimer
120
122
 
121
123
  `PNM` is free software: you can redistribute it and/or modify
122
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-2020 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-2020 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,7 +107,7 @@ 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
data/lib/pnm/image.rb CHANGED
@@ -47,11 +47,7 @@ module PNM
47
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
- maxgray
54
- end
50
+ maxgray = nil if type == :pbm
55
51
 
56
52
  image_class = case type
57
53
  when :pbm
@@ -98,9 +94,10 @@ module PNM
98
94
  #
99
95
  # Returns the number of bytes written.
100
96
  def write(file, add_extension: false, encoding: :binary)
101
- content = if encoding == :ascii
97
+ content = case encoding
98
+ when :ascii
102
99
  to_ascii
103
- elsif encoding == :binary
100
+ when :binary
104
101
  to_binary
105
102
  end
106
103
 
@@ -205,7 +202,7 @@ module PNM
205
202
 
206
203
  type = type.to_sym if type.is_a?(String)
207
204
 
208
- unless [:pbm, :pgm, :ppm].include?(type)
205
+ unless %i[pbm pgm ppm].include?(type)
209
206
  msg = "invalid image type - #{type.inspect}"
210
207
  raise PNM::ArgumentError, msg
211
208
  end
@@ -289,7 +286,6 @@ module PNM
289
286
  end
290
287
  end
291
288
 
292
-
293
289
  # Class for +PBM+ images. See the Image class for documentation.
294
290
  class PBMImage < Image
295
291
 
@@ -320,7 +316,6 @@ module PNM
320
316
  end
321
317
  end
322
318
 
323
-
324
319
  # Class for +PGM+ images. See the Image class for documentation.
325
320
  class PGMImage < Image
326
321
 
@@ -351,7 +346,6 @@ module PNM
351
346
  end
352
347
  end
353
348
 
354
-
355
349
  # Class for +PPM+ images. See the Image class for documentation.
356
350
  class PPMImage < Image
357
351
 
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.6.0"
5
- DATE = "2020-09-23"
4
+ VERSION = "0.6.1"
5
+ DATE = "2022-05-09"
6
6
  end
data/lib/pnm.rb CHANGED
@@ -87,7 +87,7 @@ require_relative "pnm/exceptions"
87
87
  #
88
88
  # == Author
89
89
  #
90
- # Copyright (C) 2013-2020 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-2020 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]
@@ -191,4 +178,16 @@ module PNM
191
178
  ppm: { ascii: "P3", binary: "P6" }
192
179
  }
193
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
194
193
  end
data/pnm.gemspec CHANGED
@@ -27,9 +27,6 @@ Gem::Specification.new do |s|
27
27
 
28
28
  s.required_ruby_version = ">= 2.0.0"
29
29
 
30
- s.add_development_dependency "minitest", ">= 5.0"
31
- s.add_development_dependency "rake", ">= 10.0"
32
-
33
30
  s.require_paths = ["lib"]
34
31
 
35
32
  s.test_files = Dir.glob("test/**/test_*.rb")
data/test/backports.rb CHANGED
@@ -15,5 +15,5 @@ end
15
15
 
16
16
  if Gem.loaded_specs["minitest"].version < Gem::Version.new("5.6.0")
17
17
  warn "Using workaround for missing value wrappers in minitest < 5.6.0."
18
- include PNM::Backports::Minitest
18
+ MiniTest::Spec.send(:include, PNM::Backports::Minitest)
19
19
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # test_converter.rb: Unit tests for the PNM library.
4
4
  #
5
- # Copyright (C) 2013-2020 Marcus Stollsteimer
5
+ # Copyright (C) 2013-2022 Marcus Stollsteimer
6
6
 
7
7
  require "minitest/autorun"
8
8
  require "pnm/converter"
@@ -136,9 +136,10 @@ describe PNM::Converter do
136
136
  it "accepts an additional whitespace character for binary encoded data" do
137
137
  width = @pbm14[:width]
138
138
  height = @pbm14[:height]
139
- data = @pbm14[:binary] + "\t"
139
+ data = @pbm14[:binary].dup << "\t"
140
140
  expected = @pbm14[:array]
141
141
 
142
+ refute_equal data, @pbm14[:binary]
142
143
  _(@converter.binary2array(:pbm, width, height, data)).must_equal expected
143
144
  end
144
145
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # test_exceptions.rb: Unit tests for the PNM library.
4
4
  #
5
- # Copyright (C) 2013-2020 Marcus Stollsteimer
5
+ # Copyright (C) 2013-2022 Marcus Stollsteimer
6
6
 
7
7
  require "minitest/autorun"
8
8
  require "stringio"
data/test/test_image.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # test_image.rb: Unit tests for the PNM library.
4
4
  #
5
- # Copyright (C) 2013-2020 Marcus Stollsteimer
5
+ # Copyright (C) 2013-2022 Marcus Stollsteimer
6
6
 
7
7
  require "minitest/autorun"
8
8
  require "pnm"
data/test/test_parser.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # test_parser.rb: Unit tests for the PNM library.
4
4
  #
5
- # Copyright (C) 2013-2020 Marcus Stollsteimer
5
+ # Copyright (C) 2013-2022 Marcus Stollsteimer
6
6
 
7
7
  require "minitest/autorun"
8
8
  require "pnm/parser"
data/test/test_pnm.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # test_pnm.rb: Unit tests for the PNM library.
4
4
  #
5
- # Copyright (C) 2013-2020 Marcus Stollsteimer
5
+ # Copyright (C) 2013-2022 Marcus Stollsteimer
6
6
 
7
7
  require "minitest/autorun"
8
8
  require "pnm"
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pnm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Stollsteimer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-23 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: minitest
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '5.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '5.0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
11
+ date: 2022-05-09 00:00:00.000000000 Z
12
+ dependencies: []
41
13
  description: 'PNM is a pure Ruby library for creating, reading, and writing of PNM
42
14
  image files (Portable Anymap): PBM (Portable Bitmap), PGM (Portable Graymap), and
43
15
  PPM (Portable Pixmap).'
@@ -96,13 +68,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
68
  - !ruby/object:Gem::Version
97
69
  version: '0'
98
70
  requirements: []
99
- rubygems_version: 3.1.2
71
+ rubygems_version: 3.3.7
100
72
  signing_key:
101
73
  specification_version: 4
102
74
  summary: PNM - create/read/write PNM image files (PBM, PGM, PPM)
103
75
  test_files:
104
- - test/test_exceptions.rb
105
76
  - test/test_converter.rb
106
- - test/test_pnm.rb
77
+ - test/test_exceptions.rb
107
78
  - test/test_image.rb
108
79
  - test/test_parser.rb
80
+ - test/test_pnm.rb