flnews_post_proc 1.70 → 1.71

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: 1154fced020bd8562041d85157d723b91cd81466678718cd4ea92f4f04a9b286
4
- data.tar.gz: de908508f8abeb90fea5d4ce2a656085db492688fd43dcb6dfb63d24c625ef8b
3
+ metadata.gz: 7cede40b08799a20bef9bb5b631371f5837269f17d16f4401190f73b953ea748
4
+ data.tar.gz: 682eea779a029ed1078ef6ce5cb09d5aa877b8bb0d62c3df238e26db5dbf3ba1
5
5
  SHA512:
6
- metadata.gz: 88b0acd2b3587720ec3850039a23df22d81b572aa3abfc18ed61e63ed42c89166be41b5ae4b5b194bd2a773b684ed73ab4afd3cd30d85483db4444e6bbc2e3e9
7
- data.tar.gz: 3555138eb59e5d59e2fffbd3bf5c9459d7b80cc7c039379b461e1ee6edda7618203f6b80c47661a12ae6eb0fc7f84a74640cb36a19045ef3e554265998522d8d
6
+ metadata.gz: caca97eb88abfe09b7fae35da0389c0f7a3a0a336b59ac83432f8cdb958fbc98076ede8b52fa095044d51a04f4178c9227b6d2d596deb9e1504d51fb336a6bbd
7
+ data.tar.gz: bfe1dc4048ff44e1f712fdd98eeab6512b6f60d95c122279d80e4d4d7a2f8a2f29078dc3ecee22ff1bcde7caf2412169a8e2645c86ddfa6b53311b3c183704aa
data/bin/flnews_post_proc CHANGED
@@ -15,7 +15,7 @@
15
15
  ***************************************************************************/
16
16
  =end
17
17
  # This program is Linux only
18
- if ! /linux/ =~ RUBY_PLATFORM
18
+ if ! (/linux/ =~ RUBY_PLATFORM)
19
19
  msg = "ERROR ! This script #{$0} cannot be used with #{RUBY_PLATFORM}"
20
20
  msg << "\n\tABORTING! Bye."
21
21
  STDERR.puts msg
@@ -59,19 +59,6 @@ class PostProcessor
59
59
  # Will only handle http(s) for the time.
60
60
  body.handle_uris
61
61
 
62
- =begin
63
- require 'gpgme'
64
-
65
- debug('signing')
66
- if ENV['GPG_AGENT_INFO']
67
- crypto = GPGME::Crypto.new
68
- data = GPGME::Data.new(body)
69
- signature = crypto.clearsign(data, {
70
- :output => File.new("/tmp/crypt_out.asc", 'w+')
71
- })
72
- end
73
- =end
74
-
75
62
  # get the headers and the body as a string.
76
63
  # Assemble.
77
64
  @article = headers.join << $LN << body.join
data/lib/headers.rb CHANGED
@@ -95,7 +95,8 @@ class Headers
95
95
  # or add a new value
96
96
  @headers[cur_header] = val
97
97
  end
98
- #@headers[l.match(/^(.*?):/)[1].to_sym] = l.match(/:(.*)/)[1].strip
98
+ # CURRENTLY UNUSED
99
+ # @headers[l.match(/^(.*?):/)[1].to_sym] = l.match(/:(.*)/)[1].strip
99
100
  # h = l.split(':')
100
101
  # @headers[h[0].strip.to_sym] = h[1...h.size].join(':').strip
101
102
  end
@@ -116,7 +117,7 @@ class Headers
116
117
  end
117
118
  end
118
119
 
119
- # Modify headers, if need be.
120
+ # Add headers, if need be. Set values where necessary.
120
121
  def update()
121
122
  no_archive = @newsgroups.no_archive
122
123
  debug('no_archive should be set now : ' << no_archive.to_s)
data/lib/newsgroups.rb CHANGED
@@ -127,18 +127,45 @@ class Newsgroups
127
127
  end
128
128
  end
129
129
 
130
- # pick a random signature
130
+ # pick a random signature, if a list is available.
131
131
  def pick_sig(sigfile)
132
132
  debug 'picking signature from ' << sigfile.to_s
133
+ allSigs = nil
134
+ sig = nil
133
135
  if sigfile && !sigfile.empty? && File.exist?(sigfile) && File.readable?(sigfile)
134
- allSigs = File::read(sigfile).split("\n\n")
135
- numSigs = allSigs.length
136
- srand(Time.now.nsec)
137
- allSigs[rand(numSigs)]
136
+ File.open(sigfile, 'r') do |sfile|
137
+ allSigs = sfile.read.split("\n\n")
138
+ numSigs = allSigs.length
139
+ srand(Time.now.nsec)
140
+ sig = allSigs[rand(numSigs)]
141
+ end
142
+ # improve hazard for the next time.
143
+ rearrange_sigs(sigfile, allSigs)
138
144
  else
139
145
  error 'Cannot read signature from file ' << sigfile
140
146
  nil
141
147
  end
148
+ return sig
149
+ end
150
+
151
+ # write a new rearranged version of the signature file for
152
+ # better hazard.
153
+ def rearrange_sigs(sigfile, all_sigs)
154
+ if File.writable?(sigfile)
155
+ new_sigs = Array.new(all_sigs.length)
156
+ until all_sigs.compact.empty? do
157
+ srand(Time.now.nsec)
158
+ sig = all_sigs.delete_at(rand(all_sigs.length))
159
+ new_sigs.push(sig)
160
+ end
161
+ new_sigs.compact!
162
+ File.open(sigfile, 'w') do |sfile|
163
+ debug 'Have ' << new_sigs.length.to_s << ' rearranged sigs'
164
+ sfile.write(new_sigs.join("\n\n") )
165
+ end
166
+ else
167
+ error 'Cannot write rearranged list of signatures to ' << sigfile
168
+ end
142
169
  end
143
170
 
144
171
  # define the no_archive header.
data/lib/override.rb CHANGED
@@ -19,7 +19,6 @@
19
19
  # notably to deactivate them.
20
20
  #
21
21
  # Post-processing CANNOT be deactivated completely in this dialog.
22
- # I do not remember, why a previous comment stated the contrary.
23
22
 
24
23
  require_relative 'basic_logging'
25
24
 
@@ -141,7 +140,12 @@ class OverrideDlg
141
140
  return nopts
142
141
  end
143
142
 
144
- # creates a textual dialog in xterm.
143
+ # Creates a textual dialog in xterm.
144
+ # Some duplicate code, here, but I am afraid to oversee
145
+ # unique requirements of the external programs. It had
146
+ # not been necessary to correct the global behavior,
147
+ # but adaptations in each single method should be
148
+ # possible.
145
149
  def ruby_dlg
146
150
  debug('xterm dialog')
147
151
  tf = Tempfile.new
data/lib/version.rb CHANGED
@@ -14,9 +14,9 @@
14
14
  =end
15
15
 
16
16
  PROGNAME = 'flnews_post_proc'
17
- PROGVERSION = "1.70"
17
+ PROGVERSION = "1.71"
18
18
  AUTHORS = "Michael Uplawski"
19
19
  EMAIL = "michael.uplawski@uplawski.eu"
20
- YEARS = "2023 - 2024"
21
- SUMMARY = "Read random signature from file"
20
+ YEARS = "2023 - 2025"
21
+ SUMMARY = "Improve randomness of signatures, if need be."
22
22
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flnews_post_proc
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.70'
4
+ version: '1.71'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Uplawski
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-01-02 00:00:00.000000000 Z
10
+ date: 2025-03-09 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: diffy
@@ -87,7 +86,6 @@ homepage: https://rubygems.org
87
86
  licenses:
88
87
  - Nonstandard
89
88
  metadata: {}
90
- post_install_message:
91
89
  rdoc_options: []
92
90
  require_paths:
93
91
  - lib
@@ -102,8 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
100
  - !ruby/object:Gem::Version
103
101
  version: '0'
104
102
  requirements: []
105
- rubygems_version: 3.5.3
106
- signing_key:
103
+ rubygems_version: 3.6.3
107
104
  specification_version: 4
108
- summary: Read random signature from file
105
+ summary: Improve randomness of signatures, if need be.
109
106
  test_files: []