flnews_post_proc 1.80 → 1.90

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68848e2172c1555bc98ed2ad95fcc219871a4b53ef4647dba81e274902f12c45
4
- data.tar.gz: 4248c0c515796d015ffe92610d1e75f14eef4235576cede2a97097d8c79d8671
3
+ metadata.gz: eaf8937c84ebdfda37d9ec06162a8ed4ce51410d927a60abac3913c49b5e6d13
4
+ data.tar.gz: 62de405fd45ddd2b1b24bf97218a8f40284496477aea0cdc30313bc81eacd9b6
5
5
  SHA512:
6
- metadata.gz: fdc9928326e6b1a93a30615a1bd9e8db18f51400594e1385bf10411a3994f5e53a3eda06c0963ce0361d6705cc5ae8f9b45b3a262b347f1af39758108f7571e9
7
- data.tar.gz: c9367005a143b112384827412280af9e33e4287c0f87bc4bb7b1507d6ab4046cdf66df72757b03c194d798e9785dbe5660fbcf263260d6d299ab0fbf1a438cac
6
+ metadata.gz: aa16a2cc4e87dede86e753fb7c9f77fb85a6c693b47bd3e82e5254a47ba411fba1a30fc5b035066ddbe29aff5f7632e731c7f5c454ae5f24ff1af3efd220c12d
7
+ data.tar.gz: e7cb57c935be4d9cc4504c3405e658890d1e820022341f92ead07262c5bf058acfcae435f2bdd59cc26bdd7dec014a8e4f929d6a154c9c4a0529ebcc05987ad6
data/bin/flnews_post_proc CHANGED
@@ -88,6 +88,11 @@ if (!STDIN.tty?)
88
88
  warn 'Input contains other things than plain-text, but I cannot say, what.'
89
89
  end
90
90
  end
91
+ # Is this article superseding another ?
92
+ if (Headers::supersedes?(artext) )
93
+ debug 'is supersedes! '
94
+ config.set(:SUPERSEDES, true)
95
+ end
91
96
  #----------->
92
97
  # Allow to override the configuration,
93
98
  # if not disabled (default is true)
data/lib/basic_logging.rb CHANGED
@@ -116,7 +116,6 @@ module BasicLogging
116
116
  alias :error :log
117
117
  alias :fatal :log
118
118
 
119
-
120
119
  private
121
120
 
122
121
  def lock_target(&block)
data/lib/body.rb CHANGED
@@ -151,15 +151,21 @@ class Body
151
151
  end
152
152
 
153
153
  def set_signature(signature)
154
- # unless no changes requested.
155
- if signature && !signature.empty?
156
- # remove any signature(s) from
157
- # the current article
158
- sigpos = @lines.index('-- ')
159
- debug('found signature in line ' << sigpos.to_s) if sigpos
160
- @lines = @lines.slice(0, sigpos ) if sigpos
161
- debug('setting signature ' << signature) if signature
162
- @lines << "-- " << signature if signature
154
+ unless @@config.SUPERSEDES
155
+ # unless no changes requested.
156
+ if signature && !signature.empty?
157
+ # remove any signature(s) from
158
+ # the current article
159
+ sigpos = @lines.index('-- ')
160
+ debug('found signature in line ' << sigpos.to_s) if sigpos
161
+ @lines = @lines.slice(0, sigpos ) if sigpos
162
+ debug('setting signature ' << signature) if signature
163
+ @lines << "-- " << signature if signature
164
+ else
165
+ debug 'signature is ' << signature ? signature : 'not set.'
166
+ end
167
+ else
168
+ debug 'ignoring signature in spersedes'
163
169
  end
164
170
  end
165
171
 
@@ -293,6 +299,7 @@ class Body
293
299
  end
294
300
  end
295
301
 
302
+ # formatting http URLs, not much is done here.
296
303
  def handle_http(l)
297
304
  debug('handle http')
298
305
  l_array = l.split
@@ -53,6 +53,7 @@ class PostProcessor
53
53
 
54
54
  # if need be, extract references and footnotes.
55
55
  body.handle_references
56
+ # signatures are ignored in Supersedes
56
57
  body.set_signature(newsgroups.signature)
57
58
 
58
59
  # verify and eventually correct URIs.
data/lib/headers.rb CHANGED
@@ -22,13 +22,12 @@ require_relative 'newsgroups'
22
22
  class Headers
23
23
  include BasicLogging
24
24
 
25
- # read the headers from the article
26
- def initialize(article_text)
25
+ def self.supersedes?(article_text)
27
26
 
28
- @config = Configuration.instance
29
- line = nil
27
+ end
28
+
29
+ def self.headers(article_text)
30
30
  # transform the article to an array.
31
- debug('before split, article_text is : ' << article_text)
32
31
  line_array = article_text.split($LN)
33
32
 
34
33
  # Ensure that all three headers are present.
@@ -36,42 +35,36 @@ class Headers
36
35
  if(missing_header)
37
36
  msg = "Input does not look like a news-article, no #{missing_header.delete(':')}; aborting."
38
37
  STDERR.puts msg
39
- error(msg)
40
38
  exit false
41
39
  end
42
40
 
43
- debug('after split, line_array is : ' << line_array.inspect)
44
41
  # find the first empty line
45
42
  end_index = line_array.index {|ele| ele.strip == ''}
46
43
  # keep the preceding lines.
47
44
  begin
48
- @lines = line_array.slice!(0, end_index)
45
+ lines = line_array.slice!(0, end_index)
49
46
  rescue Exception => ex
50
47
  msg = 'ERROR: cannot split the input into lines: ' << self.class.name << ': ' << ex.message
51
48
  # console
52
49
  STDERR.puts msg
53
50
  # log
54
- error(msg)
55
51
  exit false
56
52
  end
57
53
 
58
- debug('headers: ' << @lines.to_s)
59
-
60
54
  # headername: headervalue
61
- @headers = {}
55
+ headers = {}
62
56
 
63
57
  # fill the headers Hash from the header-lines.
64
58
  # headers may have been line-wrapped.
65
59
 
66
60
  cur_header = nil
67
- @lines.each do |l|
61
+ lines.each do |l|
68
62
  # has the header been wrapped?
69
63
  if !l.start_with?(/\s+/)
70
64
  # header is all before the first colon
71
65
  begin
72
66
  cur_header = l.match(/^(.*?):/)[1].to_sym
73
67
  rescue Exception => ex
74
- error ("Cannot match a header in line " << l << "(" << ex.message << ")")
75
68
  exit false;
76
69
  end
77
70
  # Consider the two following fixes as preliminary until proven.
@@ -85,28 +78,46 @@ class Headers
85
78
  val = l
86
79
  end
87
80
  # add value to the existing
88
- if cur_header && @headers[cur_header]
89
- @headers[cur_header] += val
81
+ if cur_header && headers[cur_header]
82
+ headers[cur_header] += val
90
83
  else
91
84
  # or add a new value
92
- @headers[cur_header] = val
85
+ headers[cur_header] = val
93
86
  end
94
87
  end
95
- debug('headers are ' << @headers.to_s)
88
+
89
+ return headers
90
+ end
91
+
92
+ def self::supersedes?(article_text)
93
+ headers(article_text).keys.include?(:Supersedes)
94
+ end
95
+
96
+ # read the headers from the article
97
+ def initialize(article_text)
98
+
99
+ @config = Configuration.instance
100
+ line = nil
101
+ debug 'setting the headers'
102
+ @headers = Headers::headers(article_text)
103
+
96
104
  @newsgroups = Newsgroups.new(header(:Newsgroups))
97
105
  debug('Newsgroups is ' << @newsgroups.inspect)
98
-
99
106
  end
100
107
 
101
108
  # returns the value of header 'name'
102
109
  def header(name)
103
110
  # name must be a symbol.
104
- if name.respond_to?(:to_sym)
105
- @headers[name]
106
- else
107
- error(name.to_s << ' is not a symbol!')
108
- nil
111
+ if(@headers && !@headers.empty?)
112
+ if name.respond_to?(:to_sym)
113
+ return @headers[name]
114
+ else
115
+ error(name.to_s << ' is not a symbol!')
116
+ end
117
+ else
118
+ error('no headers set')
109
119
  end
120
+ nil
110
121
  end
111
122
 
112
123
  # Add headers, if need be. Set values where necessary.
@@ -124,7 +135,7 @@ class Headers
124
135
  ch = pair.split(':')
125
136
  hn = ch[0].strip
126
137
  hv = ch[1].strip
127
- # Ensure header is ascii only
138
+ # Ensure header is as only
128
139
  if hv.ascii_only? && hn.ascii_only?
129
140
  # <---------- special treatment Post-Processor ---------->
130
141
  hv << ' ' << PROGVERSION.to_s if hn == 'X-Post-Processor' && hv == 'flnews_post_proc'
@@ -147,8 +158,13 @@ class Headers
147
158
  # basically a replacement for header(name), above.
148
159
  # But you can call self.Newsgroups or self.From etc.
149
160
  def method_missing(method, args = nil)
150
- return @headers[method] if @headers[method]
151
- error("unknown symbol '#{method}'")
161
+ if(@headers && !@headers.empty?)
162
+ return @headers[method] if @headers[method]
163
+ error("unknown symbol '#{method}'")
164
+ else
165
+ error('no article headers set')
166
+ end
167
+ return nil
152
168
  end
153
169
 
154
170
  # return the headers as a String.
data/lib/newsgroups.rb CHANGED
@@ -28,7 +28,9 @@ class Newsgroups
28
28
  debug('set signature, intro, no_archive')
29
29
  # set details for this post
30
30
  if @groups.size == 1
31
- set_signature
31
+ debug 'supersedes is ' << @config.SUPERSEDES.to_s
32
+ debug 'Signature will ' << (@config.SUPERSEDES ? 'NOT ' : '') << 'be set'
33
+ set_signature if !@config.SUPERSEDES
32
34
  set_intro
33
35
  set_no_archive
34
36
  end
data/lib/override.rb CHANGED
@@ -18,7 +18,8 @@
18
18
  # before posting, to do some “last minute” changes,
19
19
  # notably to deactivate them.
20
20
  #
21
- # Post-processing CANNOT be deactivated completely in this dialog.
21
+ # Post-processing CANNOT be deactivated completely in this dialog
22
+ # but cancelling the dialog will stop posting altogether.
22
23
 
23
24
  require_relative 'basic_logging'
24
25
 
data/lib/version.rb CHANGED
@@ -14,9 +14,9 @@
14
14
  =end
15
15
 
16
16
  PROGNAME = 'flnews_post_proc'
17
- PROGVERSION = "1.80"
17
+ PROGVERSION = "1.90"
18
18
  AUTHORS = "Michael Uplawski"
19
19
  EMAIL = "michael.uplawski@uplawski.eu"
20
20
  YEARS = "2023 - 2025"
21
- SUMMARY = "Generation of documentation simplified. BUG in signatures corrected."
21
+ SUMMARY = "Not changing signatures in Supsersedes"
22
22
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flnews_post_proc
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.80'
4
+ version: '1.90'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Uplawski
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-12-02 00:00:00.000000000 Z
10
+ date: 2025-12-26 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: diffy
@@ -103,5 +103,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  requirements: []
104
104
  rubygems_version: 3.6.7
105
105
  specification_version: 4
106
- summary: Generation of documentation simplified. BUG in signatures corrected.
106
+ summary: Not changing signatures in Supsersedes
107
107
  test_files: []