pdf_info 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pdf_info might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OGYzNzE5ZTY5NDdmOWNkZmRkZTE5MTgyODk1YjM4ODFjZjY5M2E2Nw==
5
- data.tar.gz: !binary |-
6
- NTFiYjlhNGUzYjM0OGM3YTNhZTdmNTg0N2I4N2VlYTMwMDNiZjM2Mg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YmEyMjM1NzFjYTRjNjQxNmUzYjk3OTQyYjZjMTc5MTI0ZDU0MmY1M2M1Yjhh
10
- YzU3OWRiYzQ3MDIyMzdmMTI1YmNmNjE1MmFjNGMwMGU2NGYyZDFlNmVlN2Rk
11
- Y2FiMGVjNWU3MTExYjczNmIyZTViMWUzNDUyYjc3ZmJkYmExMzk=
12
- data.tar.gz: !binary |-
13
- NGI0ZGViZGFjNmM5NmEyMjYzZWQ4ZmVlNGQ2NjA4MjdkNzRlYzcwODVhMjFm
14
- MTk0ZjQzNzAxMmE0N2U2NjQxZjU1MjFlNjE5M2QxNDY1ZDE4NWQ4MDkzYWVm
15
- MDIyYjRjMjAwOTUyZjY4NjI2NzI4MGNkYzlkNGMzMGEwNjEzZGE=
2
+ SHA1:
3
+ metadata.gz: d12043f74284429c74aafe8e9784c34ed72123ba
4
+ data.tar.gz: 337f439eedb9250fbe5d3185b9091dbf5e811c0a
5
+ SHA512:
6
+ metadata.gz: 22815c5f77af4887d1184d03904e6fce45ab572721cea97839a9fe629693837447094ad57e9f26dd74a41f02c83ca43bb67ca42691e8a8580b1e5852da56f340
7
+ data.tar.gz: 6dc175083822fd7f85a7bc63ece632200f33ba8496dc121f9057bc501982bae10cb5a89e7e0096d14abe020ceb9640aec96815f7b8c6a385ab2c6ac45cc0d495
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ doc
4
4
  .bundle
5
5
  pkg
6
6
  Gemfile.lock
7
+ *.gem
data/lib/pdf/info.rb CHANGED
@@ -18,10 +18,16 @@ module PDF
18
18
  end
19
19
 
20
20
  def command
21
- output = `#{self.class.command_path} "#{@pdf_path}" -f 1 -l -1`
21
+ output = `#{self.class.command_path} -enc UTF-8 "#{@pdf_path}" -f 1 -l -1`
22
22
  exit_code = $?
23
23
  case exit_code
24
24
  when 0 || nil
25
+ if !output.valid_encoding?
26
+ # It's already UTF-8, so we need to convert to UTF-16 and back to
27
+ # force the bad characters to be replaced.
28
+ output.encode!('UTF-16', :undef => :replace, :invalid => :replace, :replace => "")
29
+ output.encode!('UTF-8')
30
+ end
25
31
  return output
26
32
  else
27
33
  exit_error = PDF::Info::UnexpectedExitError.new
@@ -1,6 +1,5 @@
1
1
  module PDF
2
2
  class Info
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
  end
5
5
  end
6
-
Binary file
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
  describe PDF::Info do
@@ -160,4 +161,18 @@ describe PDF::Info do
160
161
  its([:file_size]) { should eq "218882 bytes" }
161
162
  end
162
163
 
164
+ describe "running on a file with invalid utf-8 metadata" do
165
+ subject do
166
+ PDF::Info.command_path = "pdfinfo"
167
+ PDF::Info.new(File.join(File.dirname(__FILE__), 'assets', 'invalid-utf8.pdf')).metadata
168
+ end
169
+
170
+ its([:page_count]) { should == 12 }
171
+ its([:title]) { should eq "图形1.CDR" }
172
+ # the two date fields are badly encoded in this file, so the DateTime parse
173
+ # will fail, and we'll have a nil in these fields
174
+ its([:creation_date]) { should be_nil }
175
+ its([:modification_date]) { should be_nil }
176
+ end
177
+
163
178
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf_info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Taylor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-16 00:00:00.000000000 Z
11
+ date: 2013-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description:
@@ -57,6 +57,7 @@ files:
57
57
  - lib/pdf/info/exceptions.rb
58
58
  - lib/pdf/info/version.rb
59
59
  - pdf_info.gemspec
60
+ - spec/assets/invalid-utf8.pdf
60
61
  - spec/assets/sample.pdf
61
62
  - spec/output/successful.txt
62
63
  - spec/pdf_info_spec.rb
@@ -72,12 +73,12 @@ require_paths:
72
73
  - lib
73
74
  required_ruby_version: !ruby/object:Gem::Requirement
74
75
  requirements:
75
- - - ! '>='
76
+ - - '>='
76
77
  - !ruby/object:Gem::Version
77
78
  version: '0'
78
79
  required_rubygems_version: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - ! '>='
81
+ - - '>='
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
84
  requirements: []
@@ -87,6 +88,7 @@ signing_key:
87
88
  specification_version: 4
88
89
  summary: Wraps the pdfinfo command line tool to provide a hash of metadata
89
90
  test_files:
91
+ - spec/assets/invalid-utf8.pdf
90
92
  - spec/assets/sample.pdf
91
93
  - spec/output/successful.txt
92
94
  - spec/pdf_info_spec.rb