pnm 0.5.2 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_parser.rb CHANGED
@@ -2,11 +2,13 @@
2
2
 
3
3
  # test_parser.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/parser"
9
9
 
10
+ require_relative "backports"
11
+
10
12
 
11
13
  describe PNM::Parser do
12
14
 
@@ -27,7 +29,7 @@ describe PNM::Parser do
27
29
  data: "0 1 0 0 1 1\n0 0 0 1 1 1"
28
30
  }
29
31
 
30
- @parser.parse(content).must_equal expected
32
+ _(@parser.parse(content)).must_equal expected
31
33
  end
32
34
 
33
35
  it "can parse ASCII encoded PGM data" do
@@ -44,7 +46,7 @@ describe PNM::Parser do
44
46
  data: "10 20 30 40\n50 60 70 80"
45
47
  }
46
48
 
47
- @parser.parse(content).must_equal expected
49
+ _(@parser.parse(content)).must_equal expected
48
50
  end
49
51
 
50
52
  it "can parse binary encoded data" do
@@ -56,7 +58,7 @@ describe PNM::Parser do
56
58
  data: ["05AF"].pack("H*")
57
59
  }
58
60
 
59
- @parser.parse(content).must_equal expected
61
+ _(@parser.parse(content)).must_equal expected
60
62
  end
61
63
 
62
64
  it "does not change the passed data" do
@@ -64,7 +66,7 @@ describe PNM::Parser do
64
66
  original_content = content.dup
65
67
  @parser.parse(content)
66
68
 
67
- content.must_equal original_content
69
+ _(content).must_equal original_content
68
70
  end
69
71
 
70
72
  it "does accept multiple whitespace as delimiter" do
@@ -76,23 +78,23 @@ describe PNM::Parser do
76
78
  data: "0 1 0 0 1 1"
77
79
  }
78
80
 
79
- @parser.parse(content).must_equal expected
81
+ _(@parser.parse(content)).must_equal expected
80
82
  end
81
83
 
82
84
  it "can parse binary encoded data including whitespace" do
83
- @parser.parse("P4 16 4 A\nB\rC D\t")[:data].must_equal "A\nB\rC D\t"
85
+ _(@parser.parse("P4 16 4 A\nB\rC D\t")[:data]).must_equal "A\nB\rC D\t"
84
86
  end
85
87
 
86
88
  it "can parse binary encoded data starting with whitespace" do
87
- @parser.parse("P4 8 2 \nA")[:data].must_equal "\nA"
89
+ _(@parser.parse("P4 8 2 \nA")[:data]).must_equal "\nA"
88
90
  end
89
91
 
90
92
  it "can parse binary encoded data starting with comment character" do
91
- @parser.parse("P4 8 2 #A")[:data].must_equal "#A"
93
+ _(@parser.parse("P4 8 2 #A")[:data]).must_equal "#A"
92
94
  end
93
95
 
94
96
  it "does not chomp newlines from parsed binary encoded data" do
95
- @parser.parse("P4 8 2 AB\n")[:data].must_equal "AB\n"
97
+ _(@parser.parse("P4 8 2 AB\n")[:data]).must_equal "AB\n"
96
98
  end
97
99
 
98
100
  it "can parse comments" do
@@ -115,6 +117,6 @@ describe PNM::Parser do
115
117
  data: "0 1 0 0 1 1\n0 0 0 1 1 1"
116
118
  }
117
119
 
118
- @parser.parse(content).must_equal expected
120
+ _(@parser.parse(content)).must_equal expected
119
121
  end
120
122
  end
data/test/test_pnm.rb CHANGED
@@ -2,11 +2,13 @@
2
2
 
3
3
  # test_pnm.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"
9
9
 
10
+ require_relative "backports"
11
+
10
12
 
11
13
  describe PNM do
12
14
 
@@ -18,89 +20,89 @@ describe PNM do
18
20
  file = File.expand_path("#{@srcpath}/bilevel_ascii.pbm")
19
21
  image = PNM.read(file)
20
22
 
21
- image.info.must_match %r{^PBM 5x6 Bilevel}
22
- image.maxgray.must_equal 1
23
- image.comment.must_equal "Bilevel"
24
- image.pixels.must_equal [[0, 0, 0, 0, 0],
25
- [0, 1, 1, 1, 0],
26
- [0, 0, 1, 0, 0],
27
- [0, 0, 1, 0, 0],
28
- [0, 0, 1, 0, 0],
29
- [0, 0, 0, 0, 0]]
23
+ _(image.info).must_equal "PBM 5x6 Bilevel"
24
+ _(image.maxgray).must_equal 1
25
+ _(image.comment).must_equal "Bilevel"
26
+ _(image.pixels).must_equal [[0, 0, 0, 0, 0],
27
+ [0, 1, 1, 1, 0],
28
+ [0, 0, 1, 0, 0],
29
+ [0, 0, 1, 0, 0],
30
+ [0, 0, 1, 0, 0],
31
+ [0, 0, 0, 0, 0]]
30
32
  end
31
33
 
32
34
  it "can read an ASCII encoded PGM file" do
33
35
  file = File.expand_path("#{@srcpath}/grayscale_ascii.pgm")
34
36
  image = PNM.read(file)
35
37
 
36
- image.info.must_match %r{^PGM 4x3 Grayscale}
37
- image.maxgray.must_equal 250
38
- image.comment.must_equal "Grayscale\n(with multiline comment)"
39
- image.pixels.must_equal [[ 0, 50, 100, 150],
40
- [ 50, 100, 150, 200],
41
- [100, 150, 200, 250]]
38
+ _(image.info).must_equal "PGM 4x3 Grayscale"
39
+ _(image.maxgray).must_equal 250
40
+ _(image.comment).must_equal "Grayscale\n(with multiline comment)"
41
+ _(image.pixels).must_equal [[ 0, 50, 100, 150],
42
+ [ 50, 100, 150, 200],
43
+ [100, 150, 200, 250]]
42
44
  end
43
45
 
44
46
  it "can read an ASCII encoded PPM file" do
45
47
  file = File.expand_path("#{@srcpath}/color_ascii.ppm")
46
48
  image = PNM.read(file)
47
49
 
48
- image.info.must_match %r{^PPM 5x3 Color}
49
- image.maxgray.must_equal 6
50
- image.pixels.must_equal [[[0, 6, 0], [1, 5, 1], [2, 4, 2], [3, 3, 4], [4, 2, 6]],
51
- [[1, 5, 2], [2, 4, 2], [3, 3, 2], [4, 2, 2], [5, 1, 2]],
52
- [[2, 4, 6], [3, 3, 4], [4, 2, 2], [5, 1, 1], [6, 0, 0]]]
50
+ _(image.info).must_equal "PPM 5x3 Color"
51
+ _(image.maxgray).must_equal 6
52
+ _(image.pixels).must_equal [[[0, 6, 0], [1, 5, 1], [2, 4, 2], [3, 3, 4], [4, 2, 6]],
53
+ [[1, 5, 2], [2, 4, 2], [3, 3, 2], [4, 2, 2], [5, 1, 2]],
54
+ [[2, 4, 6], [3, 3, 4], [4, 2, 2], [5, 1, 1], [6, 0, 0]]]
53
55
  end
54
56
 
55
57
  it "can read a binary encoded PBM file" do
56
58
  file = File.expand_path("#{@srcpath}/bilevel_binary.pbm")
57
59
  image = PNM.read(file)
58
60
 
59
- image.info.must_match %r{^PBM 5x6 Bilevel}
60
- image.maxgray.must_equal 1
61
- image.comment.must_equal "Bilevel"
62
- image.pixels.must_equal [[0, 0, 0, 0, 0],
63
- [0, 1, 1, 1, 0],
64
- [0, 0, 1, 0, 0],
65
- [0, 0, 1, 0, 0],
66
- [0, 0, 1, 0, 0],
67
- [0, 0, 0, 0, 0]]
61
+ _(image.info).must_equal "PBM 5x6 Bilevel"
62
+ _(image.maxgray).must_equal 1
63
+ _(image.comment).must_equal "Bilevel"
64
+ _(image.pixels).must_equal [[0, 0, 0, 0, 0],
65
+ [0, 1, 1, 1, 0],
66
+ [0, 0, 1, 0, 0],
67
+ [0, 0, 1, 0, 0],
68
+ [0, 0, 1, 0, 0],
69
+ [0, 0, 0, 0, 0]]
68
70
  end
69
71
 
70
72
  it "can read a binary encoded PGM file" do
71
73
  file = File.expand_path("#{@srcpath}/grayscale_binary.pgm")
72
74
  image = PNM.read(file)
73
75
 
74
- image.info.must_match %r{^PGM 4x3 Grayscale}
75
- image.maxgray.must_equal 250
76
- image.comment.must_equal "Grayscale\n(with multiline comment)"
77
- image.pixels.must_equal [[ 0, 50, 100, 150],
78
- [ 50, 100, 150, 200],
79
- [100, 150, 200, 250]]
76
+ _(image.info).must_equal "PGM 4x3 Grayscale"
77
+ _(image.maxgray).must_equal 250
78
+ _(image.comment).must_equal "Grayscale\n(with multiline comment)"
79
+ _(image.pixels).must_equal [[ 0, 50, 100, 150],
80
+ [ 50, 100, 150, 200],
81
+ [100, 150, 200, 250]]
80
82
  end
81
83
 
82
84
  it "can read a binary encoded PPM file" do
83
85
  file = File.expand_path("#{@srcpath}/color_binary.ppm")
84
86
  image = PNM.read(file)
85
87
 
86
- image.info.must_match %r{^PPM 5x3 Color}
87
- image.maxgray.must_equal 6
88
- image.pixels.must_equal [[[0, 6, 0], [1, 5, 1], [2, 4, 2], [3, 3, 4], [4, 2, 6]],
89
- [[1, 5, 2], [2, 4, 2], [3, 3, 2], [4, 2, 2], [5, 1, 2]],
90
- [[2, 4, 6], [3, 3, 4], [4, 2, 2], [5, 1, 1], [6, 0, 0]]]
88
+ _(image.info).must_equal "PPM 5x3 Color"
89
+ _(image.maxgray).must_equal 6
90
+ _(image.pixels).must_equal [[[0, 6, 0], [1, 5, 1], [2, 4, 2], [3, 3, 4], [4, 2, 6]],
91
+ [[1, 5, 2], [2, 4, 2], [3, 3, 2], [4, 2, 2], [5, 1, 2]],
92
+ [[2, 4, 6], [3, 3, 4], [4, 2, 2], [5, 1, 1], [6, 0, 0]]]
91
93
  end
92
94
 
93
95
  it "can read binary data containing CRLF" do
94
96
  file = File.expand_path("#{@srcpath}/grayscale_binary_crlf.pgm")
95
97
 
96
98
  image = PNM.read(file)
97
- image.pixels.must_equal [[65, 66], [13, 10], [65, 66]]
99
+ _(image.pixels).must_equal [[65, 66], [13, 10], [65, 66]]
98
100
  end
99
101
 
100
102
  it "can read binary data containing CRLF from an I/O stream" do
101
103
  file = File.expand_path("#{@srcpath}/grayscale_binary_crlf.pgm")
102
104
 
103
105
  image = File.open(file, "r") {|f| PNM.read(f) }
104
- image.pixels.must_equal [[65, 66], [13, 10], [65, 66]]
106
+ _(image.pixels).must_equal [[65, 66], [13, 10], [65, 66]]
105
107
  end
106
108
  end
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.5.2
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: 2019-02-09 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).'
@@ -61,6 +33,7 @@ files:
61
33
  - lib/pnm/parser.rb
62
34
  - lib/pnm/version.rb
63
35
  - pnm.gemspec
36
+ - test/backports.rb
64
37
  - test/bilevel_2_binary.pbm
65
38
  - test/bilevel_ascii.pbm
66
39
  - test/bilevel_binary.pbm
@@ -88,20 +61,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
61
  requirements:
89
62
  - - ">="
90
63
  - !ruby/object:Gem::Version
91
- version: 1.9.3
64
+ version: 2.0.0
92
65
  required_rubygems_version: !ruby/object:Gem::Requirement
93
66
  requirements:
94
67
  - - ">="
95
68
  - !ruby/object:Gem::Version
96
69
  version: '0'
97
70
  requirements: []
98
- rubygems_version: 3.0.1
71
+ rubygems_version: 3.3.7
99
72
  signing_key:
100
73
  specification_version: 4
101
74
  summary: PNM - create/read/write PNM image files (PBM, PGM, PPM)
102
75
  test_files:
76
+ - test/test_converter.rb
103
77
  - test/test_exceptions.rb
104
78
  - test/test_image.rb
105
- - test/test_converter.rb
106
- - test/test_pnm.rb
107
79
  - test/test_parser.rb
80
+ - test/test_pnm.rb