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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41d0847dab61302cfee794dd2547bc4a2f05df11
4
- data.tar.gz: 76a61a9dbeea6ade821e0a1beeb45207b74fa673
3
+ metadata.gz: e52a4e6c563756871e2e3da51503fcaad0afda14
4
+ data.tar.gz: 62cc1dc3452e1fa8678c918fc12cbd9c66288d6d
5
5
  SHA512:
6
- metadata.gz: b19271212932a8f0e0a6ee573076cd119468fb885bd481f10c45eb9ad15f7ceee75ad0f81be925aec05ab7366ef6a3e87267489a55402673c1b4703744122939
7
- data.tar.gz: 473810c88249b863763ff8f7e8733e0352c24765ff5d07b5372ffb8fbb136c6a05c79093193f4f983fc39cf08f5764ec37e2f05f5d68324a1933c194f9aaca4b
6
+ metadata.gz: 331134341d9a7fe5264c5e1fb4504dc6c5886ee63cf5648cad7f4958a8a15a14b03e59a0d6fb5b2b7b176553172b2d7397536bd8d16232437cc6de85c39947a4
7
+ data.tar.gz: 5808baad06957ebd956fa4dbe2c58898376427598c942634a63d2ae7a25aa1b9423c1afce226db31c9b883c51968aa089200f99d81018dfa74be2ce307b272bd
@@ -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
- data.gsub(/\A[ \t\r\n]+/, '').split(/[ \t\r\n]+/).map do |value|
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
@@ -1,4 +1,4 @@
1
1
  module PNM
2
- VERSION = '0.3.1' # :nodoc:
3
- DATE = '2014-10-10' # :nodoc:
2
+ VERSION = '0.3.2' # :nodoc:
3
+ DATE = '2014-10-19' # :nodoc:
4
4
  end
@@ -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
@@ -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 'stringio'
8
7
  require 'pnm'
@@ -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/image'
8
7
 
@@ -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/parser'
8
7
 
@@ -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'
8
7
 
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.1
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-10 00:00:00.000000000 Z
11
+ date: 2014-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake