flnews_post_proc 1.72 → 1.74

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.
data/lib/headers.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #encoding: UTF-8
2
2
  =begin
3
3
  /***************************************************************************
4
- * 2023-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
4
+ * 2023-2025, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
5
  * This program is free software; you can redistribute it and/or modify *
6
6
  * it under the terms of the WTFPL 2.0 or later, see *
7
7
  * http://www.wtfpl.net/about/ *
@@ -31,7 +31,7 @@ class Headers
31
31
  debug('before split, article_text is : ' << article_text)
32
32
  line_array = article_text.split($LN)
33
33
 
34
- # Emsure that all three headers are present.
34
+ # Ensure that all three headers are present.
35
35
  missing_header = ['From:', 'Newsgroups:', 'Message-ID:'].detect{|h| ! line_array.any?{|l| l.match(h) } }
36
36
  if(missing_header)
37
37
  msg = "Input does not look like a news-article, no #{missing_header.delete(':')}; aborting."
@@ -79,13 +79,9 @@ class Headers
79
79
  # it should.
80
80
  #
81
81
  # value is all after the first colon
82
- # BUGGY: val = l.match(/:(.*)/)[1].strip
83
- # BUGFIX 3/2024, use lstrip
84
82
  val = l.match(/:(.*)/)[1].lstrip
85
83
  else # start_with?(' ')
86
84
  # a wrapped value is not devided
87
- # BUGGY: val = l.strip
88
- # BUGFIX 3/2024
89
85
  val = l
90
86
  end
91
87
  # add value to the existing
@@ -95,10 +91,6 @@ class Headers
95
91
  # or add a new value
96
92
  @headers[cur_header] = val
97
93
  end
98
- # CURRENTLY UNUSED
99
- # @headers[l.match(/^(.*?):/)[1].to_sym] = l.match(/:(.*)/)[1].strip
100
- # h = l.split(':')
101
- # @headers[h[0].strip.to_sym] = h[1...h.size].join(':').strip
102
94
  end
103
95
  debug('headers are ' << @headers.to_s)
104
96
  @newsgroups = Newsgroups.new(header(:Newsgroups))
@@ -171,3 +163,4 @@ class Headers
171
163
 
172
164
  end
173
165
  # EOF
166
+
data/lib/newsgroups.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #encoding: UTF-8
2
2
  =begin
3
3
  /***************************************************************************
4
- * 2023-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
4
+ * 2023-2025, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
5
  * This program is free software; you can redistribute it and/or modify *
6
6
  * it under the terms of the WTFPL 2.0 or later, see *
7
7
  * http://www.wtfpl.net/about/ *
@@ -116,8 +116,8 @@ class Newsgroups
116
116
  end # if no signature
117
117
  end # gsigs.each
118
118
  end # gsigs for group?
119
- if tsig && tsig.start_with?('/')
120
- tsig = pick_sig(tsig)
119
+ if tsig && tsig.strip.start_with?('/')
120
+ tsig = pick_sig(tsig.strip)
121
121
  end
122
122
  @signature = correct_linebreaks(tsig) if tsig
123
123
  else # gsigs and is hash?
@@ -129,25 +129,44 @@ class Newsgroups
129
129
 
130
130
  # pick a random signature, if a list is available.
131
131
  def pick_sig(sigfile)
132
- debug 'picking signature from ' << sigfile.to_s
133
- allSigs = nil
134
- sig = nil
135
- if sigfile && !sigfile.empty? && File.exist?(sigfile) && File.readable?(sigfile)
136
- File.open(sigfile, 'r') do |sfile|
137
- allSigs = sfile.read.split("\n\n")
138
- numSigs = allSigs.length
139
- # srand(Time.now.nsec)
140
- # use /dev/urandom
141
- srand()
142
- sig = allSigs[rand(numSigs)]
132
+ # finds sourced files
133
+ srcregex = /^\.\s(.*)/
134
+ # delimiter for signature blocks in the file
135
+ delim = "\n\n"
136
+
137
+ if File.exist?(sigfile) && File.readable?(sigfile)
138
+ ssigs = Array.new
139
+ all_sigs = Array.new
140
+ File::read(sigfile).split(delim).collect do |item|
141
+ item.strip!
142
+ # find a sourced file
143
+ psrc = item.match(srcregex)
144
+ if(psrc )
145
+ psrc = psrc[1]
146
+ if File.exist?(psrc) && File.readable?(psrc)
147
+ ssigs = File.read(psrc).split(delim)
148
+ else
149
+ warn 'cannot find or read sourced signature file: ' << psrc
150
+ end
151
+ else
152
+ # else take the block, as is
153
+ all_sigs << item
154
+ end
143
155
  end
144
- # improve hazard for the next time.
145
- # rearrange_sigs(sigfile, allSigs)
156
+
157
+ # add sourced signatures
158
+ all_sigs.concat(ssigs) if !ssigs.empty?
159
+ numSigs = all_sigs.length
160
+
161
+ # get that signature, already!
162
+
163
+ # srand(Time.now.nsec)
164
+ srand()
165
+ return all_sigs[rand(numSigs)]
146
166
  else
147
- error 'Cannot read signature from file ' << sigfile
148
- nil
167
+ warn 'cannot find or read signature file: ' << sigfile
149
168
  end
150
- return sig
169
+ return nil
151
170
  end
152
171
 
153
172
  # write a new rearranged version of the signature file for
data/lib/override.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #encoding: UTF-8
2
2
  =begin
3
3
  /***************************************************************************
4
- * 2023-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
4
+ * 2023-2025, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
5
  * This program is free software; you can redistribute it and/or modify *
6
6
  * it under the terms of the WTFPL 2.0 or later, see *
7
7
  * http://www.wtfpl.net/about/ *
data/lib/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #encoding: UTF-8
2
2
  =begin
3
3
  /***************************************************************************
4
- * 2023-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
4
+ * 2023-2025, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
5
  * This program is free software; you can redistribute it and/or modify *
6
6
  * it under the terms of the WTFPL 2.0 or later, see *
7
7
  * http://www.wtfpl.net/about/ *
@@ -14,9 +14,9 @@
14
14
  =end
15
15
 
16
16
  PROGNAME = 'flnews_post_proc'
17
- PROGVERSION = "1.72"
17
+ PROGVERSION = "1.74"
18
18
  AUTHORS = "Michael Uplawski"
19
19
  EMAIL = "michael.uplawski@uplawski.eu"
20
20
  YEARS = "2023 - 2025"
21
- SUMMARY = "Override settings does not use Yad nor Zenity, only Whiptail or XTerm"
21
+ SUMMARY = "new documentation- and homepage URIs"
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.72'
4
+ version: '1.74'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Uplawski
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-17 00:00:00.000000000 Z
10
+ date: 2025-08-26 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: diffy
@@ -82,10 +82,11 @@ files:
82
82
  - lib/whiptail_dlg
83
83
  - lib/yad_dlg
84
84
  - lib/zenity_dlg
85
- homepage: https://rubygems.org
86
85
  licenses:
87
86
  - Nonstandard
88
- metadata: {}
87
+ metadata:
88
+ homepage_uri: https://www.uplawski.eu/software/flnews_post_proc/flnews_post_proc.html
89
+ documentation_uri: https://www.uplawski.eu/div/flnews/gem_doc/html/flnews_post_proc.html
89
90
  rdoc_options: []
90
91
  require_paths:
91
92
  - lib
@@ -102,5 +103,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  requirements: []
103
104
  rubygems_version: 3.6.7
104
105
  specification_version: 4
105
- summary: Override settings does not use Yad nor Zenity, only Whiptail or XTerm
106
+ summary: new documentation- and homepage URIs
106
107
  test_files: []