Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20dd21c
commit 1a79cb1
Showing
10 changed files
with
155 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
AllCops: | ||
Include: | ||
- '**/Rakefile' | ||
- '*.gemspec' | ||
Exclude: | ||
- 'pkg/**/*' | ||
|
||
# These cops need to remain disabled for valid reasons on this code base | ||
|
||
# set_ methods are the part of PDF::Reader API | ||
Style/AccessorMethodName: | ||
Enabled: false | ||
|
||
# We need to reference non-ascii characters when testing and explaining | ||
# behavior related to win-1252, UTF-8 and UTF-16 encodings for example. | ||
Style/AsciiComments: | ||
Enabled: false | ||
|
||
Style/BlockDelimiters: | ||
EnforcedStyle: semantic | ||
|
||
Style/Documentation: | ||
Enabled: false | ||
|
||
# We don't always prefer modified if statements even if they do fit on | ||
# a line. | ||
Style/IfUnlessModifier: | ||
Enabled: false | ||
|
||
Style/MultilineOperationIndentation: | ||
Exclude: | ||
- prawn.gemspec | ||
|
||
Style/PercentLiteralDelimiters: | ||
PreferredDelimiters: | ||
'%': '()' | ||
'%i': '[]' | ||
'%I': '[]' | ||
'%q': '()' | ||
'%Q': '()' | ||
'%r': '{}' | ||
'%s': '()' | ||
'%w': '[]' | ||
'%W': '[]' | ||
'%x': '()' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
require "rubygems" | ||
require "pdf/reader" | ||
require "pdf/inspector/text" | ||
require "pdf/inspector/xobject" | ||
require "pdf/inspector/extgstate" | ||
require "pdf/inspector/graphics" | ||
require "pdf/inspector/page" | ||
require "stringio" | ||
require 'rubygems' | ||
require 'pdf/reader' | ||
require 'pdf/inspector/text' | ||
require 'pdf/inspector/xobject' | ||
require 'pdf/inspector/extgstate' | ||
require 'pdf/inspector/graphics' | ||
require 'pdf/inspector/page' | ||
require 'stringio' | ||
|
||
module PDF | ||
class Inspector | ||
def self.analyze(output,*args,&block) | ||
def self.analyze(output, *args, &block) | ||
if output.is_a?(String) | ||
output = StringIO.new(output) | ||
end | ||
obs = self.new(*args, &block) | ||
obs = new(*args, &block) | ||
PDF::Reader.open(output) do |reader| | ||
reader.pages.each do |page| | ||
page.walk(obs) | ||
end | ||
end | ||
obs | ||
end | ||
def self.analyze_file(filename,*args,&block) | ||
File.open(filename, "rb") do |io| | ||
analyze(io, *args,&block) | ||
obs | ||
end | ||
|
||
def self.analyze_file(filename, *args, &block) | ||
File.open(filename, 'rb') do |io| | ||
analyze(io, *args, &block) | ||
end | ||
end | ||
end | ||
|
||
def self.parse(obj) | ||
PDF::Reader::Parser.new( | ||
PDF::Reader::Buffer.new(StringIO.new(obj)), nil).parse_token | ||
PDF::Reader::Buffer.new(StringIO.new(obj)), | ||
nil | ||
).parse_token | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.