Class: PostProcessor

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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
# 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()

  debug 'getting newsgroups'
  begin
    newsgroups = headers.newsgroups
    debug "\thave newsgroups " << newsgroups.to_s
  rescue Exception => ex 
    error "Cannot get Newsgroups: " << ex.message
  end

  # 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
  # signatures are ignored in Supersedes
  body.set_signature(newsgroups.signature)

  # verify and eventually correct URIs.
  # Will only handle http(s) for the time.
  body.handle_uris

  # 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

#articleObject (readonly)

Returns the value of attribute article.



77
78
79
# File 'lib/flnews_post_proc.rb', line 77

def article
  @article
end