pnm 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pnm/converter.rb +9 -3
- data/lib/pnm/version.rb +2 -2
- data/test/test_converter.rb +9 -1
- data/test/test_exceptions.rb +0 -1
- data/test/test_image.rb +0 -1
- data/test/test_parser.rb +0 -1
- data/test/test_pnm.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e52a4e6c563756871e2e3da51503fcaad0afda14
|
4
|
+
data.tar.gz: 62cc1dc3452e1fa8678c918fc12cbd9c66288d6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 331134341d9a7fe5264c5e1fb4504dc6c5886ee63cf5648cad7f4958a8a15a14b03e59a0d6fb5b2b7b176553172b2d7397536bd8d16232437cc6de85c39947a4
|
7
|
+
data.tar.gz: 5808baad06957ebd956fa4dbe2c58898376427598c942634a63d2ae7a25aa1b9423c1afce226db31c9b883c51968aa089200f99d81018dfa74be2ce307b272bd
|
data/lib/pnm/converter.rb
CHANGED
@@ -26,7 +26,7 @@ module PNM
|
|
26
26
|
def self.ascii2array(type, width, height, data)
|
27
27
|
values_per_row = type == :ppm ? 3 * width : width
|
28
28
|
|
29
|
-
values = convert_to_integers(data)
|
29
|
+
values = convert_to_integers(data, type)
|
30
30
|
assert_data_size(values.size, values_per_row * height)
|
31
31
|
|
32
32
|
case type
|
@@ -103,8 +103,14 @@ module PNM
|
|
103
103
|
data_string
|
104
104
|
end
|
105
105
|
|
106
|
-
def self.convert_to_integers(data) # :nodoc:
|
107
|
-
|
106
|
+
def self.convert_to_integers(data, type) # :nodoc:
|
107
|
+
if type == :pbm
|
108
|
+
values_as_string = data.gsub(/[ \t\r\n]+/, '').split('')
|
109
|
+
else
|
110
|
+
values_as_string = data.gsub(/\A[ \t\r\n]+/, '').split(/[ \t\r\n]+/)
|
111
|
+
end
|
112
|
+
|
113
|
+
values_as_string.map do |value|
|
108
114
|
Integer(value)
|
109
115
|
end
|
110
116
|
rescue ::ArgumentError => e
|
data/lib/pnm/version.rb
CHANGED
data/test/test_converter.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
#
|
3
3
|
# Copyright (C) 2013-2014 Marcus Stollsteimer
|
4
4
|
|
5
|
-
require 'minitest/spec'
|
6
5
|
require 'minitest/autorun'
|
7
6
|
require 'pnm/converter'
|
8
7
|
|
@@ -75,6 +74,15 @@ describe PNM::Converter do
|
|
75
74
|
@converter.ascii2array(:ppm, width, height, data).must_equal expected
|
76
75
|
end
|
77
76
|
|
77
|
+
it 'accepts ASCII encoded PBM data with omitted whitespace' do
|
78
|
+
width = 4
|
79
|
+
height = 3
|
80
|
+
data = " 010100\n000110"
|
81
|
+
expected = [[0, 1, 0, 1], [0, 0, 0, 0], [0, 1, 1, 0]]
|
82
|
+
|
83
|
+
@converter.ascii2array(:pbm, width, height, data).must_equal expected
|
84
|
+
end
|
85
|
+
|
78
86
|
it 'accepts ASCII encoded PGM data with arbitrary whitespace' do
|
79
87
|
width = 4
|
80
88
|
height = 3
|
data/test/test_exceptions.rb
CHANGED
data/test/test_image.rb
CHANGED
data/test/test_parser.rb
CHANGED
data/test/test_pnm.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pnm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcus Stollsteimer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|