viewworkbook 0.1.3 → 0.3

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/viewworkbook.rb CHANGED
@@ -1,49 +1,38 @@
1
1
  #!/usr/bin/env ruby
2
2
  #encoding: UTF-8
3
-
4
3
  =begin
5
- /******************************************************************************
6
- * Copyright © 2014-2016, Michael Uplawski <michael.uplawski@uplawski.eu> *
7
- * *
8
- * This program is free software; you can redistribute it and/or modify *
9
- * it under the terms of the GNU General Public License as published by *
10
- * the Free Software Foundation; either version 3 of the License, or *
11
- * (at your option) any later version. *
12
- * *
13
- * This program is distributed in the hope that it will be useful, *
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16
- * GNU General Public License for more details. *
17
- * *
18
- * You should have received a copy of the GNU General Public License *
19
- * along with this program; if not, write to the *
20
- * Free Software Foundation, Inc., *
21
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22
- ******************************************************************************/
4
+ /***************************************************************************
5
+ * ©2016-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
6
+ * *
7
+ * This program is free software; you can redistribute it and/or modify *
8
+ * it under the terms of the WTFPL 2.0 or later, see *
9
+ * http://www.wtfpl.net/about/ *
10
+ * *
11
+ * This program is distributed in the hope that it will be useful, *
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
14
+ * *
15
+ ***************************************************************************/
23
16
  =end
24
17
 
25
- require_relative 'logging'
18
+ require 'tempfile'
19
+ require_relative 'basic_logging'
26
20
  require_relative 'file_checking'
27
21
  require_relative 'sheetinterface'
28
22
  require_relative 'sheetdata'
29
23
  require_relative 'color_output'
30
24
 
31
- require 'roo'
32
- require 'roo-xls'
33
- require 'tempfile'
34
-
35
25
  class ViewWorkBook
36
- include Logging
26
+ include BasicLogging
37
27
  include File_Checking
38
28
 
39
29
  attr_reader :workbook
40
30
 
41
31
  def initialize(*args)
42
- init_logger(STDOUT, Logger::INFO)
43
- @log.debug('args is ' << args.to_s)
32
+ debug('args is ' << args.to_s)
44
33
  wb = args[0]
45
34
  path = File.path(wb) if wb
46
- @log.debug('workbook file will be ' << (path ? path : 'N I L'))
35
+ debug('workbook file will be ' << (path ? path : 'N I L'))
47
36
 
48
37
  if(wb)
49
38
  msg = file_check(path, :exist?, :file?, :readable?)
@@ -53,14 +42,14 @@ class ViewWorkBook
53
42
  view_sheet if @workbook
54
43
  end
55
44
  else
56
- @log.error(yellow("Cannot open " << path << ": " << msg))
45
+ error(yellow("Cannot open " << path << ": " << msg))
57
46
  # raise IOError.new(msg)
58
47
  puts red("\n\tPlease name a valid spreadsheet file! Aborting.")
59
48
  puts
60
49
  exit false
61
50
  end
62
51
  end
63
- @log.debug('initialized')
52
+ debug('initialized')
64
53
  end
65
54
 
66
55
  def method_missing(method, *args)
@@ -73,7 +62,7 @@ class ViewWorkBook
73
62
 
74
63
  private
75
64
  def view_sheet(number = 0)
76
- @log.debug('default_sheet is ' << sheets[number])
65
+ debug('default_sheet is ' << sheets[number])
77
66
  SheetInterface.new(@workbook, number)
78
67
  end
79
68
  end
@@ -0,0 +1,26 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'viewworkbook'
3
+ s.version = '0.3'
4
+ s.date = '2025-08-29'
5
+ s.summary = "Documentation text improved, "
6
+ s.summary << "List of dependencies completed."
7
+ s.description = "View spreadsheet files in a text-console."
8
+ s.authors = ["Michael Uplawski"]
9
+ s.email = 'michael.uplawski@uplawski.eu'
10
+ s.files = %w~action.rb scrollable.rb cell.rb column.rb row.rb color_output.rb menu.rb sheetdata.rb translating.rb user_input.rb file_checking.rb basic_logging.rb sheetinterface.rb translations viewworkbook.rb~.collect{|f| 'lib/' << f} +
11
+ %w~license.txt rst/viewworkbook.rst man/viewworkbook.1.gz html/viewworkbook.html~.collect{|f| 'doc/' << f} +
12
+ %w~busy_function_test.rb busy_indicator.rb~.collect{|f| 'lib/busy_indicator/' << f} + ["README.md", "viewworkbook.gemspec"]
13
+ s.homepage = 'http://rubygems.org/gems/viewworkbook'
14
+ s.requirements = 'roo, roo-xls, ruby-filemagic'
15
+ s.add_runtime_dependency 'roo', '~> 2.4', '>= 2.4.0'
16
+ s.add_runtime_dependency 'roo-xls', '~> 1.2', '>= 1.2.0'
17
+ s.add_runtime_dependency 'ruby-filemagic', '~> 0.3', '>= 0.3.2'
18
+ s.executables = 'viewworkbook'
19
+ s.license = 'Nonstandard'
20
+ s.required_ruby_version = '>= 3.0'
21
+ s.metadata = {
22
+ "homepage_uri" => 'https://www.uplawski.eu/software/viewworkbook/',
23
+ "documentation_uri" => 'https://www.uplawski.eu/software/viewworkbook/viewworkbook.html'
24
+ }
25
+
26
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viewworkbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Uplawski
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2018-02-10 00:00:00.000000000 Z
10
+ date: 2025-08-29 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: roo
@@ -36,40 +35,40 @@ dependencies:
36
35
  requirements:
37
36
  - - "~>"
38
37
  - !ruby/object:Gem::Version
39
- version: '1.0'
38
+ version: '1.2'
40
39
  - - ">="
41
40
  - !ruby/object:Gem::Version
42
- version: 1.0.0
41
+ version: 1.2.0
43
42
  type: :runtime
44
43
  prerelease: false
45
44
  version_requirements: !ruby/object:Gem::Requirement
46
45
  requirements:
47
46
  - - "~>"
48
47
  - !ruby/object:Gem::Version
49
- version: '1.0'
48
+ version: '1.2'
50
49
  - - ">="
51
50
  - !ruby/object:Gem::Version
52
- version: 1.0.0
51
+ version: 1.2.0
53
52
  - !ruby/object:Gem::Dependency
54
53
  name: ruby-filemagic
55
54
  requirement: !ruby/object:Gem::Requirement
56
55
  requirements:
57
56
  - - "~>"
58
57
  - !ruby/object:Gem::Version
59
- version: '0.7'
58
+ version: '0.3'
60
59
  - - ">="
61
60
  - !ruby/object:Gem::Version
62
- version: 0.7.1
61
+ version: 0.3.2
63
62
  type: :runtime
64
63
  prerelease: false
65
64
  version_requirements: !ruby/object:Gem::Requirement
66
65
  requirements:
67
66
  - - "~>"
68
67
  - !ruby/object:Gem::Version
69
- version: '0.7'
68
+ version: '0.3'
70
69
  - - ">="
71
70
  - !ruby/object:Gem::Version
72
- version: 0.7.1
71
+ version: 0.3.2
73
72
  description: View spreadsheet files in a text-console.
74
73
  email: michael.uplawski@uplawski.eu
75
74
  executables:
@@ -77,20 +76,20 @@ executables:
77
76
  extensions: []
78
77
  extra_rdoc_files: []
79
78
  files:
79
+ - README.md
80
80
  - bin/viewworkbook
81
81
  - doc/html/viewworkbook.html
82
82
  - doc/license.txt
83
83
  - doc/man/viewworkbook.1.gz
84
84
  - doc/rst/viewworkbook.rst
85
85
  - lib/action.rb
86
+ - lib/basic_logging.rb
86
87
  - lib/busy_indicator/busy_function_test.rb
87
88
  - lib/busy_indicator/busy_indicator.rb
88
89
  - lib/cell.rb
89
90
  - lib/color_output.rb
90
91
  - lib/column.rb
91
92
  - lib/file_checking.rb
92
- - lib/log.conf
93
- - lib/logging.rb
94
93
  - lib/menu.rb
95
94
  - lib/row.rb
96
95
  - lib/scrollable.rb
@@ -100,11 +99,13 @@ files:
100
99
  - lib/translations
101
100
  - lib/user_input.rb
102
101
  - lib/viewworkbook.rb
103
- homepage: http://rubygems.org
102
+ - viewworkbook.gemspec
103
+ homepage: http://rubygems.org/gems/viewworkbook
104
104
  licenses:
105
- - GPL-3.0
106
- metadata: {}
107
- post_install_message:
105
+ - Nonstandard
106
+ metadata:
107
+ homepage_uri: https://www.uplawski.eu/software/viewworkbook/
108
+ documentation_uri: https://www.uplawski.eu/software/viewworkbook/viewworkbook.html
108
109
  rdoc_options: []
109
110
  require_paths:
110
111
  - lib
@@ -112,17 +113,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
113
  requirements:
113
114
  - - ">="
114
115
  - !ruby/object:Gem::Version
115
- version: 2.1.2
116
+ version: '3.0'
116
117
  required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  requirements:
118
119
  - - ">="
119
120
  - !ruby/object:Gem::Version
120
121
  version: '0'
121
122
  requirements:
122
- - roo, roo-xls, filemagic
123
- rubyforge_project:
124
- rubygems_version: 2.7.3
125
- signing_key:
123
+ - roo, roo-xls, ruby-filemagic
124
+ rubygems_version: 3.6.7
126
125
  specification_version: 4
127
- summary: bugfix, gzipped man-page
126
+ summary: Documentation text improved,List of dependencies completed.
128
127
  test_files: []
data/lib/log.conf DELETED
@@ -1,62 +0,0 @@
1
- #encoding: UTF-8
2
- =begin
3
- /***************************************************************************
4
- * ©2013 Michael Uplawski <michael.uplawski@uplawski.eu> *
5
- * *
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. *
10
- * *
11
- * This program is distributed in the hope that it will be useful, *
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. *
15
- * *
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
- ***************************************************************************/
21
-
22
- A simplified logger configuration. Set the level for each individual logger
23
- below. Choose a different log-device or log-file if you like. Keep the
24
- formatting intact. Do not change other sections of this file.
25
- =end
26
-
27
- # Do not touch from here ----->
28
- require 'logger'
29
-
30
- debug = Logger::DEBUG
31
- info = Logger::INFO
32
- error = Logger::ERROR
33
- fatal = Logger::FATAL
34
- warn = Logger::WARN
35
- unknown = Logger::UNKNOWN
36
- {
37
- # <---------------- to here !
38
-
39
- # Enter your settings here, but take into consideration that not all
40
- # the named classes will really produce readable output. Well, you can
41
- # always try... Either name just the log-level or make the log-level
42
- # precede the output-device or output-file like in the examples.
43
-
44
- # Example: naming a log-file
45
- # :HtmlBuilder => [info, 'C:\temp\htmlbuilder.log']
46
- # :HtmlBuilder => [debug, '/tmp/htmlbuilder.log'],
47
-
48
- :ViewWorkBook => debug,
49
- :SheetInterface => debug,
50
- :Action => info,
51
- :Menu => info,
52
- :SheetData => info,
53
- :Row => info,
54
- :Cell => info,
55
- :Column => info,
56
- :Scrollable => debug,
57
- :AnsiEscapedText => debug,
58
-
59
- # And ignore the remainder, too.
60
- }
61
-
62
- #eof
data/lib/logging.rb DELETED
@@ -1,195 +0,0 @@
1
- #encoding: UTF-8
2
- =begin
3
- /***************************************************************************
4
- * ©2011-2016 Michael Uplawski <michael.uplawski@uplawski.eu> *
5
- * *
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. *
10
- * *
11
- * This program is distributed in the hope that it will be useful, *
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. *
15
- * *
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
- ***************************************************************************/
21
- =end
22
- require 'logger'
23
- require_relative 'file_checking'
24
-
25
- $DEBUG = :DEBUG
26
-
27
- =begin Creates a member @log and precede its output with the name of the class
28
- of the object.
29
- Example for a class-level logger:
30
- # --------------------
31
- class TClass
32
- self.extend(Logging)
33
- @@log = init_logger(STDOUT)
34
- def test_log
35
- @@log.info('class-level logger called from instance: ' << @@log.to_s)
36
- @log = @@log
37
- @log.info('AGAIN: class-level logger called from instance: ' << @log.to_s)
38
- end
39
- def self::test_log
40
- @log.info('class-level logger called from class: ' << @log.to_s)
41
- @@log.info('AGAIN: class-level logger called from class: ' << @@log.to_s)
42
- end
43
- end
44
- #---------------------
45
- Example for a object-level logger:
46
- ATTN! This means 1 logger per object.
47
- # --------------------
48
- class TClass
49
- include Logging
50
- def initialize
51
- init_logger(STDOUT, Logger::DEBUG)
52
- end
53
- def test_log
54
- @log.debug('called test_log() ')
55
- end
56
- end
57
- =end
58
- module Logging
59
- include File_Checking
60
-
61
- @@have_log = false
62
- @@LOG_CONF = File.dirname(File.absolute_path(__FILE__)) << File::Separator << 'log.conf'
63
-
64
- # Call this method in an instance-method (e.g. initialize() ) to define the
65
- # object-level logger; i.e. an object-specific member @log.
66
- # Call this method within the class-definition for a class-level logger; i.e.
67
- # a member @log for class-level acces.
68
- # The method returns the logger, so you can actually do what you want with it.
69
- def init_logger(target = STDOUT, level = Logger::INFO)
70
- # Prepare for a class-level logger. This is actually quite cool.
71
-
72
- # ---> Ingeniuous code starts here
73
- cn = (self.class == Class ? name : self.class.name)
74
- # <--- Ingeniuous code ends here
75
-
76
- # allow to override the set log-levels with an
77
- # external configuration (log.conf).
78
- log_conf(cn)
79
- # Or use the defaults as set here or elsewhere...
80
-
81
- @level ||= level
82
- @target ||= target
83
-
84
- @log = Logger.new(@target)
85
- @log.level = @level
86
-
87
- @log.formatter = proc do |severity, datetime, progname, msg|
88
- t = Time.now
89
- "#{cn}: #{severity} #{t.hour}-#{t.min}-#{t.sec}: #{msg}\n"
90
- end
91
- if ! @@have_log
92
- @log.debug cn.dup << ' reading logging-configuration from ' << @@LOG_CONF
93
- @@have_log = true
94
- @log.debug('level is ' << level.to_s)
95
- end
96
- return @log
97
- end
98
-
99
- # Set the log-target to an IO object.
100
- def log_target=(target)
101
- @target = target
102
- @log = Logger.new(@@target)
103
- @log.level = @level
104
- end
105
-
106
- # set the log-level
107
- def log_level=(level)
108
- @level = level
109
- @log.level = @level
110
- end
111
-
112
- private
113
-
114
- # Override or set the log-level and target-device, as set in a file 'log.conf'.
115
- # I do not like the look of this, but it works just the way I want it to.
116
- # "HEAVANS! Isn't there a standard way to do this in Ruby, for Christ's sake?", you say.
117
- # Heck, I don't care. <= Read that again, I say.
118
- def log_conf(cn = nil)
119
- config = level = target = nil
120
- # puts 'log-config is in ' << @@LOG_CONF
121
- if(File::exist?(@@LOG_CONF) )
122
- begin
123
- conf = File.read(@@LOG_CONF)
124
- config = instance_eval(conf)
125
- rescue Exception => ex
126
- STDERR.puts "WARNING! Cannot evaluate the logger-configuration!" << ' ' << ex.message
127
- STDERR.puts "Default log-levels apply."
128
- end
129
- else
130
- puts "Default log-levels apply."
131
- end
132
-
133
- if(config && config.respond_to?(:to_hash) )
134
- config.default = nil
135
- if cn
136
- config = config[cn.to_sym]
137
- else
138
- config = config[self.class.name.to_sym]
139
- end
140
-
141
- if(config )
142
- if(config.respond_to?(:to_ary) && config.size == 2)
143
- @level, @target = config
144
- @target.downcase!
145
- logdir = File.dirname(@target)
146
- msg = file_check(logdir, :exist?, :directory?, :writable?)
147
- if(msg)
148
- STDERR.puts "WARNING! A logfile for '%s' cannot be written to %s (%s)!" %[self.class.name, logdir, msg]
149
- @target = nil
150
- end
151
- else
152
- @level = config
153
- end
154
- end
155
- end
156
- end
157
- end
158
-
159
- ######### test
160
- if __FILE__ == $0
161
- class TClass
162
- # class level ---->
163
- self.extend(Logging)
164
- @@log = init_logger(STDOUT, Logger::INFO)
165
- # <------
166
- # object-level ---->
167
- include Logging
168
- # <---------
169
-
170
- def test_log
171
- @@log.info('class-level logger called from instance: ' << @@log.to_s)
172
- #@log = @@log # works too
173
- @log = TClass.class_eval{@log}
174
- @log.info('AGAIN: class-level logger called from instance: ' << @log.to_s)
175
- @log.debug("you won't see this on log-level INFO")
176
-
177
- # object-level ---->
178
- init_logger
179
- # <-----------
180
- @log.info("That's a different thing: " << @log.to_s << " - object-level logger!")
181
-
182
- end
183
- def self::test_log
184
- @log.info('class-level logger called from class: ' << @log.to_s)
185
- @@log.info('AGAIN: class-level logger called from class: ' << @log.to_s)
186
- end
187
- end
188
-
189
- TClass.new.test_log # class-logger + 1st object-logger
190
- TClass.new.test_log # same class-logger + 2nd object-logger
191
-
192
- TClass::test_log # same class-logger
193
- puts 'And just say it once clearly: THIS IS COOOL!!'
194
- end
195
- #EOF