This repository has been archived by the owner on Dec 28, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved message formatting to separate Class
- Loading branch information
Mike Cook
committed
Nov 17, 2011
1 parent
c64ae34
commit 0e5fac7
Showing
2 changed files
with
5 additions
and
45 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 |
---|---|---|
@@ -1,30 +1,8 @@ | ||
module EpubValidator | ||
class EpubCheck | ||
def self.process(filename) | ||
checked = epubcheck(filename) | ||
format_epubcheck_message(checked) | ||
end | ||
|
||
private | ||
|
||
def self.epubcheck(epubfile) | ||
def self.epubcheck(filename) | ||
epubcheck_jar = File.expand_path(File.dirname(__FILE__) + '/../epubcheck-1-2/epubcheck-1.2.jar') | ||
`java -jar #{epubcheck_jar} "#{epubfile}" 2>&1` | ||
end | ||
|
||
def self.format_epubcheck_message(message) | ||
return ['Passed.'] if message.match('No errors or warnings detected') | ||
|
||
m_array = message.split(/\n/) | ||
|
||
# clean up all useless info | ||
m_array.delete_if do |s| | ||
s.empty? or | ||
s.match('^Epubcheck Version.*') or | ||
s.match('^Check finished.*') | ||
end | ||
|
||
m_array.unshift('FAILED!') | ||
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