html2index 1.2.1 → 1.31

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/file_checking.rb CHANGED
@@ -1,24 +1,19 @@
1
1
  #encoding: UTF-8
2
2
  =begin
3
3
  /***************************************************************************
4
- * ©2011-2017 Michael Uplawski <michael.uplawski@uplawski.eu> *
4
+ * ©2015-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
5
  * *
6
6
  * This program is free software; you can redistribute it and/or modify *
7
- * it under the terms of the GNU General Public License as published by *
8
- * the Free Software Foundation; either version 3 of the License, or *
9
- * (at your option) any later version. *
7
+ * it under the terms of the WTFPL, version 2 or later, as published on *
8
+ * https://www.wtfpl.net/about/. *
10
9
  * *
11
10
  * This program is distributed in the hope that it will be useful, *
12
11
  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
- * GNU General Public License for more details. *
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15
13
  * *
16
- * You should have received a copy of the GNU General Public License *
17
- * along with this program; if not, write to the *
18
- * Free Software Foundation, Inc., *
19
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
14
  ***************************************************************************/
21
15
  =end
16
+
22
17
  require 'filemagic'
23
18
 
24
19
  =begin
data/lib/html2index.rb CHANGED
@@ -1,27 +1,20 @@
1
1
  #encoding: UTF-8
2
2
  =begin
3
3
  /***************************************************************************
4
- * ©2015-201/ Michael Uplawski <michael.uplawski@uplawski.eu> *
4
+ * ©2015-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
5
  * *
6
6
  * This program is free software; you can redistribute it and/or modify *
7
- * it under the terms of the GNU General Public License as published by *
8
- * the Free Software Foundation; either version 3 of the License, or *
9
- * (at your option) any later version. *
7
+ * it under the terms of the WTFPL, version 2 or later, as published on *
8
+ * https://www.wtfpl.net/about/. *
10
9
  * *
11
10
  * This program is distributed in the hope that it will be useful, *
12
11
  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
- * GNU General Public License for more details. *
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15
13
  * *
16
- * You should have received a copy of the GNU General Public License *
17
- * along with this program; if not, write to the *
18
- * Free Software Foundation, Inc., *
19
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
14
  ***************************************************************************/
21
15
  =end
22
-
23
16
  require_relative 'argparser'
24
- require_relative 'logging'
17
+ require_relative 'basic_logging'
25
18
  require_relative 'translating'
26
19
  require_relative 'user_input'
27
20
  require_relative 'constants'
@@ -36,7 +29,7 @@ require_relative 'file_checking'
36
29
  require_relative 'configuration'
37
30
 
38
31
  class HTML2Index
39
- include Logging
32
+ include BasicLogging
40
33
  include Nokogiri
41
34
 
42
35
  =begin
@@ -44,30 +37,29 @@ class HTML2Index
44
37
  =end
45
38
 
46
39
  def initialize(*argv)
47
- init_logger()
48
40
  # ensure the configuration-file exist.
49
41
  options = ArgParser.parse(argv)
50
42
  $configuration = Configuration.new(options)
51
43
  $configuration.user_conf
52
- @log.level = $log_level
44
+ set_level $log_level
53
45
  @file = $configuration.source
54
46
 
55
- @log.debug("read #{@file}, write #{$configuration.target}")
47
+ debug("read #{@file}, write #{$configuration.target}")
56
48
  msg = File_Checking::file_check(@file, :exist?, :readable?, :file?)
57
49
  if(msg)
58
- @log.error("Error: unsuitable file " <<@file << ": " << msg)
50
+ error("Error: unsuitable file " <<@file << ": " << msg)
59
51
  exit false
60
52
  end
61
53
 
62
54
  ftype = File_Checking::file_type(@file)
63
- @log.debug('ftype for ' << @file << ' is ' << ftype.to_s)
55
+ debug('ftype for ' << @file << ' is ' << ftype.to_s)
64
56
  if(ftype && !ftype.empty? && !ftype[0].downcase.match("(html|xml) .*document") )
65
- @log.error(@file.dup << ' does not look like a valid file to scan: ' << ftype)
57
+ error(@file.dup << ' does not look like a valid file to scan: ' << ftype)
66
58
  exit false
67
59
  end
68
60
 
69
61
  @problem_log = File.join(temp_dir, PROBLEM_LOG)
70
- @log.debug('calling generate() ')
62
+ debug('calling generate() ')
71
63
  generate()
72
64
  end
73
65
 
@@ -77,7 +69,7 @@ class HTML2Index
77
69
  $configuration.dicts.each do |d|
78
70
  list << '<li>' << d.name << ' : ' << '<a href="' << d.url << '">' << d.url << '</a></li>' << "\n"
79
71
  end
80
- @log.debug('list is ' << list.to_s)
72
+ debug('list is ' << list.to_s)
81
73
  list << "</ul>\n"
82
74
  end
83
75
 
@@ -85,19 +77,19 @@ class HTML2Index
85
77
  Parses the html-file and generates the glossary.
86
78
  =end
87
79
  def generate()
88
- @log.info('Generating... PSE wait')
80
+ info('Generating... PSE wait')
89
81
  begin
90
82
  @doc = HTML::Document.parse(File.open(@file ) )
91
83
  write_html()
92
84
  rescue SystemExit => ir
93
- @log.info "Bye"
85
+ info "Bye"
94
86
  exit true
95
87
  rescue Exception => ex
96
- @log.error "line #{__LINE__}: " << ex.message
88
+ error "line #{__LINE__}: " << ex.message
97
89
  exit false
98
90
  end
99
91
  if(File.exist?(@problem_log ))
100
- @log.info "Some expressions caused problems and are listed in " << @problem_log
92
+ info "Some expressions caused problems and are listed in " << @problem_log
101
93
  end
102
94
  end
103
95
  private
@@ -117,13 +109,13 @@ class HTML2Index
117
109
  page = Nokogiri::HTML(URI.open(url))
118
110
  rescue Exception => ex
119
111
  url_b = d.url.dup << URI.encode_www_form_component(expression.gsub(/\s/,'_'))
120
- @log.warn('WARNING, accessing ' << url << ': ' << ex.message)
112
+ warn('WARNING, accessing ' << url << ': ' << ex.message)
121
113
  if(url_b != url)
122
- @log.warn("\twill try " << url_b)
114
+ warn("\twill try " << url_b)
123
115
  begin
124
116
  page = Nokogiri::HTML(URI.open(url_b, "User-Agent"=>"#{APPNAME} #{VERSION}", "From"=>"Function Test <bat.guano@don.blech.e4ward.com>"))
125
117
  rescue Exception => ex
126
- @log.warn("\tWARNING, accessing " << url_b << ': ' << ex.message)
118
+ warn("\tWARNING, accessing " << url_b << ': ' << ex.message)
127
119
  end
128
120
  end
129
121
  end
@@ -157,7 +149,7 @@ Creates and returns an Array of Definitions.
157
149
  value = $configuration.attr_value
158
150
  xpath = ".//#{tag}[contains(@#{attr}, '#{value}')]"
159
151
  # xpath = './/' << value << '[@' << attr << '="' << value << '"]'
160
- @log.debug('xpath is ' << xpath)
152
+ debug('xpath is ' << xpath)
161
153
  tags = @doc.xpath(xpath)
162
154
  tags.each do |t|
163
155
  expression = t.attribute('title').to_s
@@ -172,7 +164,7 @@ Creates and returns an Array of Definitions.
172
164
  list.push expression.downcase
173
165
  definition = dict_definition(expression)
174
166
  if(definition && !definition.empty?)
175
- # @log.debug('definition is ' << definition.to_s)
167
+ # debug('definition is ' << definition.to_s)
176
168
  def_list.push(format_index(definition) )
177
169
  def_list.sort!
178
170
  end
@@ -181,13 +173,13 @@ Creates and returns an Array of Definitions.
181
173
  end
182
174
  end
183
175
  =begin
184
- if(@log.level == Logger::DEBUG)
185
- @log.debug('def_list is ')
186
- def_list.each_with_index{|t, i| @log.debug( "%i %s"%[i, t]) }
176
+ if(level == Logger::DEBUG)
177
+ debug('def_list is ')
178
+ def_list.each_with_index{|t, i| debug( "%i %s"%[i, t]) }
187
179
  end
188
180
  =end
189
181
  rescue Interrupt => ex
190
- @log.warn "--------------\n\tIndex generation interrupted by user\n---------------"
182
+ warn "--------------\n\tIndex generation interrupted by user\n---------------"
191
183
  end
192
184
  return def_list
193
185
  end
@@ -212,11 +204,11 @@ Formats the definition text.
212
204
  # def temp_dir options = {:remove => true}
213
205
  def temp_dir
214
206
  @temp_dir ||= begin
215
- @log.debug('creating temp_dir')
207
+ debug('creating temp_dir')
216
208
  require 'tmpdir'
217
209
  require 'fileutils'
218
210
  path = File.join(Dir::tmpdir, "HTML2Index_#{Time.now.to_i}_#{rand(1000)}")
219
- @log.debug('temp-dir path is ' << path)
211
+ debug('temp-dir path is ' << path)
220
212
  Dir.mkdir(path)
221
213
  # at_exit {FileUtils.rm_rf(path) if File.exists?(path)} if options[:remove]
222
214
  File.new path
@@ -245,7 +237,7 @@ Formats the definition text.
245
237
  end
246
238
  end
247
239
  else
248
- @log.debug('out_file is STDOUT')
240
+ debug('out_file is STDOUT')
249
241
  end
250
242
  begin
251
243
  html = template.to_s
@@ -258,15 +250,15 @@ Formats the definition text.
258
250
  fdelim = $configuration.fdelim
259
251
  placeholders.each_pair do |k, v|
260
252
  repl = fdelim.dup << v << fdelim.reverse
261
- @log.debug('try to replace ' << repl)
253
+ debug('try to replace ' << repl)
262
254
  html.gsub!(repl, data[k])
263
255
  end
264
- @log.debug('html is now ' << html)
256
+ debug('html is now ' << html)
265
257
  html.gsub!(/\<head\>/, "<head>\n\t#{GeneratorMeta}")
266
258
  File.write(out_file, html) if out_file
267
259
  puts html if !out_file
268
260
  rescue Exception => ex
269
- @log.error( "line #{__LINE__} " << ex.message << ' (' << ex.class.name << ')')
261
+ error( "line #{__LINE__} " << ex.message << ' (' << ex.class.name << ')')
270
262
  ensure
271
263
  out.close if out && !out.closed?
272
264
  File.unlink(out) if out
data/lib/template.rb CHANGED
@@ -1,38 +1,31 @@
1
1
  #encoding: UTF-8
2
+
2
3
  =begin
3
4
  /***************************************************************************
4
- * ©2017-2017 Michael Uplawski <michael.uplawski@uplawski.eu> *
5
+ * ©2017-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
5
6
  * *
6
7
  * This program is free software; you can redistribute it and/or modify *
7
- * it under the terms of the GNU General Public License as published by *
8
- * the Free Software Foundation; either version 3 of the License, or *
9
- * (at your option) any later version. *
8
+ * it under the terms of the WTFPL, version 2 or later, as published on *
9
+ * https://www.wtfpl.net/about/. *
10
10
  * *
11
11
  * This program is distributed in the hope that it will be useful, *
12
12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
- * GNU General Public License for more details. *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15
14
  * *
16
- * You should have received a copy of the GNU General Public License *
17
- * along with this program; if not, write to the *
18
- * Free Software Foundation, Inc., *
19
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
15
  ***************************************************************************/
21
16
  =end
22
- require 'logger'
17
+
23
18
  require 'date'
24
- require_relative 'logging'
19
+ require_relative 'basic_logging'
25
20
  require_relative 'dictionary'
26
21
  require_relative 'constants'
27
22
  require_relative 'file_checking'
28
23
 
29
24
  class Template
30
- self.extend(Logging)
31
- @@log = init_logger
25
+ include BasicLogging
32
26
 
33
27
  def initialize()
34
- @log = @@log
35
- @log.level = $log_level
28
+ set_level = $log_level
36
29
  template_file = $configuration.template
37
30
  @template = nil
38
31
  if template_file
@@ -45,9 +38,9 @@ class Template
45
38
  end
46
39
  if(!msg)
47
40
  @template = File.read(template_file)
48
- @log.debug('using template ' << template_file)
41
+ debug('using template ' << template_file)
49
42
  else
50
- @log.warn('Cannot use template ' << template_file << ': ' << msg << "\n\tusing default template")
43
+ warn('Cannot use template ' << template_file << ': ' << msg << "\n\tusing default template")
51
44
  end
52
45
  end
53
46
  end
@@ -57,7 +50,7 @@ class Template
57
50
  if @template && @template.respond_to?(:to_str)
58
51
  str = @template
59
52
  else
60
- @log.warn('Empty template, using default!')
53
+ warn('Empty template, using default!')
61
54
  str = @@def_template
62
55
  end
63
56
  str
@@ -74,8 +67,8 @@ class Template
74
67
  when :def_template
75
68
  @@def_template
76
69
  else
77
- @log.error('Do not know ' << name.to_s)
78
- @log.error('Aborting. Bye!')
70
+ error('Do not know ' << name.to_s)
71
+ error('Aborting. Bye!')
79
72
  end
80
73
  end
81
74
 
data/lib/translating.rb CHANGED
@@ -1,23 +1,16 @@
1
1
  #encoding: UTF-8
2
2
  =begin
3
3
  /***************************************************************************
4
- * ©2011-2017, Michael Uplawski *
5
- * <michael.uplawski@uplawski.eu> *
4
+ * ©2011-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
6
5
  * *
7
6
  * This program is free software; you can redistribute it and/or modify *
8
- * it under the terms of the GNU General Public License as published by *
9
- * the Free Software Foundation; either version 3 of the License, or *
10
- * (at your option) any later version. *
11
- * *
7
+ * it under the terms of the WTFPL, version 2 or later, as published on *
8
+ * https://www.wtfpl.net/about/. *
9
+ * *
12
10
  * This program is distributed in the hope that it will be useful, *
13
11
  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
- * GNU General Public License for more details. *
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
16
13
  * *
17
- * You should have received a copy of the GNU General Public License *
18
- * along with this program; if not, write to the *
19
- * Free Software Foundation, Inc., *
20
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21
14
  ***************************************************************************/
22
15
  =end
23
16
 
data/lib/user_input.rb CHANGED
@@ -1,26 +1,18 @@
1
1
  #encoding: UTF-8
2
-
3
2
  =begin
4
3
  /***************************************************************************
5
- * Copyright © 2014, Michael Uplawski <michael.uplawski@uplawski.eu> *
4
+ * ©2011-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
6
5
  * *
7
6
  * This program is free software; you can redistribute it and/or modify *
8
- * it under the terms of the GNU General Public License as published by *
9
- * the Free Software Foundation; either version 3 of the License, or *
10
- * (at your option) any later version. *
7
+ * it under the terms of the WTFPL, version 2 or later, as published on *
8
+ * https://www.wtfpl.net/about/. *
11
9
  * *
12
10
  * This program is distributed in the hope that it will be useful, *
13
11
  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
- * GNU General Public License for more details. *
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
16
13
  * *
17
- * You should have received a copy of the GNU General Public License *
18
- * along with this program; if not, write to the *
19
- * Free Software Foundation, Inc., *
20
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21
14
  ***************************************************************************/
22
15
  =end
23
-
24
16
  require 'io/wait'
25
17
  require 'io/console'
26
18
 
data/lib/version.rb CHANGED
@@ -1,12 +1,16 @@
1
- #
2
- # DON'T FORGET SCHWEINE-MET ON THE FENSTERBRETT !!
3
- # =================================================
4
- # - Change gemspec !!
5
- # - Change version in the doc/rst folder !!
6
- # - INSTALL AND TEST THAT GEM !!
7
- # - gem push
8
- #
9
- # - blame yourself.
10
- #
11
- VERSION='1.2.1'
12
-
1
+ =begin
2
+ /***************************************************************************
3
+ * ©2015-2026, Michael Uplawski <michael.uplawski@uplawski.eu> *
4
+ * *
5
+ * This program is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the WTFPL, version 2 or later, as published on *
7
+ * https://www.wtfpl.net/about/. *
8
+ * *
9
+ * This program is distributed in the hope that it will be useful, *
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
12
+ * *
13
+ ***************************************************************************/
14
+ =end
15
+ VERSION ='1.31'
16
+ SUMMARY = "New logging module, new license, homepage and documentation"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html2index
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: '1.31'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Uplawski
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2020-09-05 00:00:00.000000000 Z
10
+ date: 2026-01-16 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: nokogiri
@@ -16,20 +15,20 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '1.10'
18
+ version: '1.18'
20
19
  - - ">="
21
20
  - !ruby/object:Gem::Version
22
- version: 1.10.9
21
+ version: 1.18.10
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
26
25
  requirements:
27
26
  - - "~>"
28
27
  - !ruby/object:Gem::Version
29
- version: '1.10'
28
+ version: '1.18'
30
29
  - - ">="
31
30
  - !ruby/object:Gem::Version
32
- version: 1.10.9
31
+ version: 1.18.10
33
32
  - !ruby/object:Gem::Dependency
34
33
  name: ruby-filemagic
35
34
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +38,7 @@ dependencies:
39
38
  version: '0.7'
40
39
  - - ">="
41
40
  - !ruby/object:Gem::Version
42
- version: 0.7.2
41
+ version: 0.7.3
43
42
  type: :runtime
44
43
  prerelease: false
45
44
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +48,7 @@ dependencies:
49
48
  version: '0.7'
50
49
  - - ">="
51
50
  - !ruby/object:Gem::Version
52
- version: 0.7.2
51
+ version: 0.7.3
53
52
  description: creates a glossary from HTML
54
53
  email: michael.uplawski@uplawski.eu
55
54
  executables:
@@ -64,6 +63,7 @@ files:
64
63
  - doc/rst/html2index.rst
65
64
  - html2index.gemspec
66
65
  - lib/argparser.rb
66
+ - lib/basic_logging.rb
67
67
  - lib/configuration.rb
68
68
  - lib/constants.rb
69
69
  - lib/definition.rb
@@ -71,17 +71,17 @@ files:
71
71
  - lib/file_checking.rb
72
72
  - lib/html2index.rb
73
73
  - lib/log.conf
74
- - lib/logging.rb
75
74
  - lib/template.rb
76
75
  - lib/translating.rb
77
76
  - lib/translations
78
77
  - lib/user_input.rb
79
78
  - lib/version.rb
80
- homepage: http://www.souris-libre.fr
81
79
  licenses:
82
- - GPL-3.0
83
- metadata: {}
84
- post_install_message:
80
+ - Nonstandard
81
+ metadata:
82
+ homepage_uri: https://www.uplawski.eu/software/
83
+ documentation_uri: https://www.uplawski.eu/software/html2index/html2index.html
84
+ license_uri: https://www.wtfpl.net/about/
85
85
  rdoc_options: []
86
86
  require_paths:
87
87
  - lib
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: 2.7.1
92
+ version: '3.0'
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="
@@ -97,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  requirements:
99
99
  - nokogiri, ruby-filemagic
100
- rubygems_version: 3.1.2
101
- signing_key:
100
+ rubygems_version: 3.6.7
102
101
  specification_version: 4
103
- summary: updated dependencies, updated use of the URI module.
102
+ summary: New logging module, new license, homepage and documentation
104
103
  test_files: []