Class: PostProcessor
- Inherits:
-
Object
- Object
- PostProcessor
- Includes:
- BasicLogging
- Defined in:
- lib/flnews_post_proc.rb
Overview
The main application class.
Does it.
Constant Summary
Constants included from BasicLogging
BasicLogging::DEBUG, BasicLogging::ERROR, BasicLogging::FATAL, BasicLogging::INFO, BasicLogging::Levels, BasicLogging::UNKNOWN, BasicLogging::WARN
Instance Attribute Summary collapse
-
#article ⇒ Object
readonly
Returns the value of attribute article.
Instance Method Summary collapse
-
#initialize(article_text) ⇒ PostProcessor
constructor
A new instance of PostProcessor.
Methods included from BasicLogging
#clear_log, is_muted?, #level, #log, mute, #set_level, #set_target, #target
Constructor Details
#initialize(article_text) ⇒ PostProcessor
Returns a new instance of PostProcessor.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/flnews_post_proc.rb', line 35 def initialize(article_text) @config = Configuration.instance # for simplicity. # separate the headers and the body. debug ' initializing headers' headers = Headers.new(article_text) debug('headers is ' << headers.inspect) body = Body.new(article_text) debug('calling headers.update') headers.update() newsgroups = headers.newsgroups # Order matters. These actions work on a # preliminary version of the article, each # one on the result of the previous ! body.set_intro(newsgroups.intro) # if need be, extract references and footnotes. body.handle_references body.set_signature(newsgroups.signature) # verify and eventually correct URIs. # Will only handle http(s) for the time. body.handle_uris =begin require 'gpgme' debug('signing') if ENV['GPG_AGENT_INFO'] crypto = GPGME::Crypto.new data = GPGME::Data.new(body) signature = crypto.clearsign(data, { :output => File.new("/tmp/crypt_out.asc", 'w+') }) end =end # get the headers and the body as a string. # Assemble. @article = headers.join << $LN << body.join diff = Diffy::Diff.new(article_text, @article, :context => 2).to_s info("\n" << "–" * 20 << "\nDiffs\n" << "–" * 20 << "\n" << diff) end |
Instance Attribute Details
#article ⇒ Object (readonly)
Returns the value of attribute article.
83 84 85 |
# File 'lib/flnews_post_proc.rb', line 83 def article @article end |