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.
- checksums.yaml +4 -4
- data/README.md +126 -0
- data/bin/viewworkbook +12 -10
- data/doc/html/viewworkbook.html +98 -388
- data/doc/man/viewworkbook.1.gz +0 -0
- data/doc/rst/viewworkbook.rst +59 -51
- data/lib/action.rb +10 -16
- data/lib/basic_logging.rb +178 -0
- data/lib/cell.rb +22 -19
- data/lib/color_output.rb +16 -0
- data/lib/column.rb +17 -18
- data/lib/file_checking.rb +36 -11
- data/lib/menu.rb +11 -24
- data/lib/row.rb +13 -16
- data/lib/scrollable.rb +8 -17
- data/lib/sheetdata.rb +45 -58
- data/lib/sheetinterface.rb +11 -25
- data/lib/translating.rb +6 -12
- data/lib/user_input.rb +4 -11
- data/lib/viewworkbook.rb +20 -31
- data/viewworkbook.gemspec +26 -0
- metadata +22 -23
- data/lib/log.conf +0 -62
- data/lib/logging.rb +0 -195
data/lib/file_checking.rb
CHANGED
@@ -1,25 +1,21 @@
|
|
1
1
|
#encoding: UTF-8
|
2
2
|
=begin
|
3
3
|
/***************************************************************************
|
4
|
-
* ©2011-
|
4
|
+
* ©2011-2024, 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
|
8
|
-
*
|
9
|
-
* (at your option) any later version. *
|
7
|
+
* it under the terms of the WTFPL 2.0 or later, see *
|
8
|
+
* http://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.
|
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
16
|
|
17
|
+
require 'filemagic'
|
18
|
+
|
23
19
|
=begin
|
24
20
|
A module to facilitate frequently occuring checks on
|
25
21
|
file-system objects
|
@@ -39,6 +35,10 @@ module File_Checking
|
|
39
35
|
:directory => "is not a directory!",
|
40
36
|
:file? => "is not a file!",
|
41
37
|
:file => "is not a file!",
|
38
|
+
:type => "is not of the sought file-type (not '%s', but '%s')!",
|
39
|
+
:type? => "is not of the sought file-type (not '%s', but '%s')!",
|
40
|
+
:mime => "does not have the sought mime-type (not '%s', but '%s')!",
|
41
|
+
:mime? => "does not have the sought mime-type (not '%s', but '%s')!",
|
42
42
|
}
|
43
43
|
|
44
44
|
# Checks if the file with the name from the first
|
@@ -76,12 +76,37 @@ module File_Checking
|
|
76
76
|
end
|
77
77
|
msg
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
|
+
def self.mime_check(file, mime_type)
|
81
|
+
fm = FileMagic.mime
|
82
|
+
fd = fm.fd(File.new(file) ).split(';')[0]
|
83
|
+
if fd != mime_type.strip
|
84
|
+
return file.dup << ' ' << (@@text_messages[:mime] %[mime_type, fd])
|
85
|
+
end
|
86
|
+
return nil
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.magic_check(file, magic)
|
90
|
+
fm = FileMagic.fm
|
91
|
+
fd = fm.fd(File.new(file) ).split(';')[0]
|
92
|
+
if fd != magic.strip
|
93
|
+
return file.dup << ' ' << (@@text_messages[:type] %[magic, fd])
|
94
|
+
end
|
95
|
+
return nil
|
96
|
+
end
|
97
|
+
|
98
|
+
end # module
|
80
99
|
|
81
100
|
=begin
|
82
101
|
# example
|
83
102
|
|
84
103
|
include File_Checking
|
85
104
|
msg = file_check('some_file.txt', [:exist?, :readable?, 'writable'])
|
105
|
+
# same as
|
106
|
+
# msg = file_check('some_file.txt', [:exist, :readable, 'writable?'])
|
107
|
+
|
108
|
+
msg ||= magic_check('some_file.txt', [:type?], 'OpenDocument Text'
|
109
|
+
msg ||= mime_check('some_file.txt', [:mime?], 'application/vnd.oasis.opendocument.text'
|
86
110
|
puts msg if msg
|
87
111
|
=end
|
112
|
+
# E O F
|
data/lib/menu.rb
CHANGED
@@ -1,41 +1,30 @@
|
|
1
1
|
#encoding: UTF-8
|
2
|
-
|
3
2
|
=begin
|
4
3
|
/***************************************************************************
|
5
|
-
*
|
4
|
+
* ©2014-2024, 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
|
9
|
-
*
|
10
|
-
* (at your option) any later version. *
|
7
|
+
* it under the terms of the WTFPL 2.0 or later, see *
|
8
|
+
* http://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.
|
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
|
|
24
17
|
require 'io/wait'
|
25
18
|
require 'io/console'
|
26
19
|
require_relative 'action'
|
27
|
-
require_relative '
|
20
|
+
require_relative 'basic_logging'
|
28
21
|
require_relative 'user_input'
|
29
22
|
|
30
23
|
# Shows options that the user can choose from.
|
31
24
|
# Options may be associated with sub-menus.
|
32
|
-
|
33
25
|
class Menu
|
34
|
-
|
35
|
-
self.extend(Logging)
|
36
|
-
@@log = self.init_logger(STDOUT)
|
26
|
+
include BasicLogging
|
37
27
|
|
38
|
-
attr_accessor :key, :name
|
39
28
|
|
40
29
|
class MenuError < StandardError
|
41
30
|
end
|
@@ -43,8 +32,8 @@ class Menu
|
|
43
32
|
@@global_elements = []
|
44
33
|
@@hidden_elements = []
|
45
34
|
|
35
|
+
# create the menu
|
46
36
|
def initialize(options = {})
|
47
|
-
@log = @@log
|
48
37
|
@elements = []
|
49
38
|
if(options && !options.respond_to?(:to_hash) )
|
50
39
|
raise MenuError.new('Arguments to menu.new must be hash-pairs')
|
@@ -53,10 +42,12 @@ class Menu
|
|
53
42
|
@key = options[:key] if options[:key]
|
54
43
|
end
|
55
44
|
|
45
|
+
# display menu
|
56
46
|
def call(*args)
|
57
47
|
show()
|
58
48
|
end
|
59
49
|
|
50
|
+
# add an action or sub menu to the menu
|
60
51
|
def add(element, pos = nil)
|
61
52
|
if(element.respond_to?(:call))
|
62
53
|
if(pos)
|
@@ -77,8 +68,8 @@ class Menu
|
|
77
68
|
end
|
78
69
|
end
|
79
70
|
|
80
|
-
|
81
71
|
private
|
72
|
+
# display menu and react to user input.
|
82
73
|
def show()
|
83
74
|
@elements.each do |ele|
|
84
75
|
name = ele.name.downcase
|
@@ -89,11 +80,6 @@ class Menu
|
|
89
80
|
ele = nil
|
90
81
|
until ele
|
91
82
|
key = "%c" %wait_for_user
|
92
|
-
=begin
|
93
|
-
if "\e" == key
|
94
|
-
break
|
95
|
-
end
|
96
|
-
=end
|
97
83
|
ele = @elements.detect{ |e| key == e.key }
|
98
84
|
ele ||= @@global_elements.detect{ |e| key == e.key }
|
99
85
|
end
|
@@ -101,6 +87,7 @@ class Menu
|
|
101
87
|
end
|
102
88
|
|
103
89
|
public
|
90
|
+
attr_accessor :key, :name
|
104
91
|
alias :add_action :add
|
105
92
|
alias :add_sub_menu :add
|
106
93
|
alias :add_menu :add
|
data/lib/row.rb
CHANGED
@@ -1,41 +1,34 @@
|
|
1
1
|
#encoding: UTF-8
|
2
|
-
|
3
2
|
=begin
|
4
3
|
/***************************************************************************
|
5
|
-
*
|
4
|
+
* ©2016-2024, 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
|
9
|
-
*
|
10
|
-
* (at your option) any later version. *
|
7
|
+
* it under the terms of the WTFPL 2.0 or later, see *
|
8
|
+
* http://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.
|
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
|
|
24
17
|
require_relative 'cell'
|
25
|
-
require_relative '
|
18
|
+
require_relative 'basic_logging'
|
26
19
|
|
27
20
|
# Objects of this class represent rows in a spreadsheet table
|
28
21
|
class Row
|
29
22
|
@@DEF_HEIGHT=2
|
30
|
-
|
31
|
-
|
23
|
+
include BasicLogging
|
24
|
+
|
32
25
|
def initialize(number = nil)
|
33
|
-
@log = @@log
|
34
26
|
@number = number
|
35
27
|
@cells = Array.new
|
36
28
|
@height = 1
|
37
29
|
end
|
38
30
|
|
31
|
+
# add a cell to the row
|
39
32
|
def add(cell)
|
40
33
|
n_cell = nil
|
41
34
|
if cell.respond_to?(:to_cell)
|
@@ -44,7 +37,7 @@ class Row
|
|
44
37
|
n_cell = Cell.new(@number, cell)
|
45
38
|
else
|
46
39
|
msg = 'For a new cell, a colum-number must be specified'
|
47
|
-
|
40
|
+
error(red(msg))
|
48
41
|
raise StandardError(msg)
|
49
42
|
end
|
50
43
|
@cells.insert(n_cell.col, n_cell)
|
@@ -52,12 +45,15 @@ class Row
|
|
52
45
|
resize()
|
53
46
|
end
|
54
47
|
|
48
|
+
# execute block on each cell in the row
|
55
49
|
def each(&b)
|
56
50
|
@cells.each do |c|
|
57
51
|
yield(c)
|
58
52
|
end
|
59
53
|
end
|
60
54
|
|
55
|
+
# adapt the height of the row to the ideal height of the
|
56
|
+
# highest cell
|
61
57
|
def resize()
|
62
58
|
if(@cells && ! @cells.empty? )
|
63
59
|
if(@cells.length == 1 )
|
@@ -70,6 +66,7 @@ class Row
|
|
70
66
|
@height ||= @@DEF_HEIGHT
|
71
67
|
end
|
72
68
|
|
69
|
+
# returns a string representation of the row
|
73
70
|
def to_s
|
74
71
|
'#<' << self.class.name << ':' << object_id.to_s << "{number=%s height=%s cells.length=%s}" %[@number.to_s, @height.to_s, @cells.length.to_s]
|
75
72
|
end
|
data/lib/scrollable.rb
CHANGED
@@ -1,30 +1,23 @@
|
|
1
1
|
#encoding: UTF-8
|
2
|
-
|
3
2
|
=begin
|
4
3
|
/***************************************************************************
|
5
|
-
*
|
4
|
+
* ©2017-2024, 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
|
9
|
-
*
|
10
|
-
* (at your option) any later version. *
|
7
|
+
* it under the terms of the WTFPL 2.0 or later, see *
|
8
|
+
* http://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.
|
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
|
if __FILE__ == $0
|
24
17
|
require_relative 'user_input'
|
25
18
|
end
|
26
19
|
|
27
|
-
require_relative '
|
20
|
+
require_relative 'basic_logging'
|
28
21
|
require_relative 'color_output'
|
29
22
|
|
30
23
|
class ScrollException < StandardError
|
@@ -38,13 +31,12 @@ end
|
|
38
31
|
# You can have a box around the scrollable "window" by setting the attribute
|
39
32
|
# 'box' to true and, -as I do not care to be asked for my opinion-, you should.
|
40
33
|
module Scrollable
|
41
|
-
|
34
|
+
include BasicLogging
|
42
35
|
# may not be needed at all, but when it is..,
|
43
36
|
# you want it on class level.
|
44
37
|
@@box = %w~┌ ┐ └ ┘ ─ │~
|
45
38
|
|
46
39
|
# dto. and how so!
|
47
|
-
@@log = self.init_logger(STDOUT)
|
48
40
|
|
49
41
|
# pfffft. As you please.
|
50
42
|
@@def_step_x = 1
|
@@ -227,7 +219,6 @@ module Scrollable
|
|
227
219
|
|
228
220
|
# sets a few values, needed for the rest of the module to function.
|
229
221
|
def defaults()
|
230
|
-
@log = @@log
|
231
222
|
if(self.respond_to?(:to_s) )
|
232
223
|
# @view = self
|
233
224
|
@view = self.gsub(/\e\[\d+m/, '')
|
@@ -251,11 +242,11 @@ module Scrollable
|
|
251
242
|
@have_defaults = true
|
252
243
|
elsif !view
|
253
244
|
msg = 'Need to know, what to scroll! (argument "view" missing)'
|
254
|
-
|
245
|
+
error(yellow(msg))
|
255
246
|
raise ScrollException.new(msg)
|
256
247
|
else
|
257
248
|
msg = 'The "view" to scroll must have a method "to_s()"'
|
258
|
-
|
249
|
+
error(yellow(msg))
|
259
250
|
raise ScrollException.new(msg)
|
260
251
|
end
|
261
252
|
end
|
data/lib/sheetdata.rb
CHANGED
@@ -1,96 +1,83 @@
|
|
1
1
|
#encoding: UTF-8
|
2
2
|
|
3
3
|
=begin
|
4
|
-
|
5
|
-
*
|
6
|
-
*
|
7
|
-
* This program is free software; you can redistribute it and/or modify
|
8
|
-
* it under the terms of the
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
|
16
|
-
* *
|
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
|
-
*****************************************************************************/
|
4
|
+
/***************************************************************************
|
5
|
+
* ©2016-2025, 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
|
+
***************************************************************************/
|
22
16
|
=end
|
23
17
|
|
18
|
+
require 'filemagic'
|
24
19
|
require 'roo'
|
25
20
|
require 'roo-xls'
|
26
|
-
require 'filemagic'
|
27
21
|
|
28
|
-
require_relative '
|
22
|
+
require_relative 'basic_logging'
|
29
23
|
|
30
|
-
# Transforms a file into a Roo spreadsheet instance.
|
31
24
|
|
32
|
-
ODS_Magic
|
33
|
-
XLS_Magic
|
25
|
+
ODS_Magic = "OpenDocument Spreadsheet"
|
26
|
+
XLS_Magic = "Composite Document File V2 Document"
|
34
27
|
XLSX_Magic = "Microsoft OOXML"
|
28
|
+
# SoftMaker Office
|
29
|
+
PMDX_Magic = "Microsoft Excel 2007+"
|
35
30
|
|
36
|
-
ODS_MIME
|
37
|
-
XLS_MIME
|
38
|
-
XLSX_MIME = "application/
|
39
|
-
CSV_MIME
|
31
|
+
ODS_MIME = "application/vnd.oasis.opendocument.spreadsheet"
|
32
|
+
XLS_MIME = "application/vnd.ms-excel"
|
33
|
+
XLSX_MIME = "application/zip"
|
34
|
+
CSV_MIME = "text/plain"
|
35
|
+
# SoftMaker Office
|
36
|
+
PMDX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
40
37
|
|
38
|
+
=begin
|
39
|
+
Transforms a file into a Roo spreadsheet instance.
|
40
|
+
=end
|
41
41
|
class SheetData
|
42
|
-
|
43
|
-
|
42
|
+
# logs on class level
|
43
|
+
self.extend BasicLogging
|
44
44
|
|
45
45
|
@@file = nil
|
46
46
|
@@workbook = nil
|
47
47
|
|
48
|
+
# returns a new workbook
|
48
49
|
def self::workbook(file)
|
49
50
|
@@file = file
|
50
51
|
if !@@workbook
|
51
52
|
begin
|
52
|
-
|
53
|
-
|
53
|
+
fm = FileMagic.mime
|
54
|
+
mtype = fm.fd(File.new(file) ).split(';')[0]
|
55
|
+
fm = FileMagic.fm
|
56
|
+
magic = fm.fd(File.new(file) ).split(';')[0]
|
57
|
+
@@workbook = case mtype
|
54
58
|
when ODS_MIME
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
64
|
-
when XLSX_MIME
|
65
|
-
if magic.match XLSX_Magic
|
66
|
-
@@log.debug('XLSX')
|
67
|
-
Roo::Spreadsheet::open(@@file, extension: :xlsx )
|
68
|
-
end
|
59
|
+
debug('ODS')
|
60
|
+
Roo::Spreadsheet::open(@@file, extension: :ods )
|
61
|
+
when (XLS_MIME)
|
62
|
+
debug('XLS')
|
63
|
+
Roo::Spreadsheet::open(@@file, extension: :xls )
|
64
|
+
when XLSX_MIME, PMDX_MIME
|
65
|
+
debug('XLSX')
|
66
|
+
Roo::Spreadsheet::open(@@file, extension: :xlsx )
|
69
67
|
when CSV_MIME
|
70
68
|
raise IOError.new('CSV is not yet supported, sorry')
|
71
69
|
else
|
72
|
-
raise IOError.new('Mime-Type is ' <<
|
70
|
+
raise IOError.new('Mime-Type is ' << mtype << ' and Magic sais: ' << magic << ". Is this supposed to be a spreadsheet?")
|
73
71
|
end
|
74
72
|
rescue Exception => ex
|
75
73
|
msg = 'ERROR! File %s is not supported: %s' %[@@file, ex.message]
|
76
74
|
puts msg
|
77
|
-
|
75
|
+
error yellow(msg)
|
78
76
|
exit false
|
79
77
|
end
|
80
78
|
|
81
79
|
return @@workbook
|
82
80
|
end
|
83
81
|
end
|
84
|
-
|
85
|
-
private
|
86
|
-
# derive the mime-type from the file
|
87
|
-
def self::file_type
|
88
|
-
fm = FileMagic.fm
|
89
|
-
file_magic = fm.file(@@file)
|
90
|
-
fm.flags = [:mime_type]
|
91
|
-
file_mime = fm.file(@@file)
|
92
|
-
@log.debug('File type is ' << file_magic << ', Mime-type is ' << file_mime)
|
93
|
-
return file_magic, file_mime
|
94
|
-
end
|
95
82
|
end
|
96
83
|
|
data/lib/sheetinterface.rb
CHANGED
@@ -2,22 +2,16 @@
|
|
2
2
|
|
3
3
|
=begin
|
4
4
|
/***************************************************************************
|
5
|
-
*
|
5
|
+
* ©2014-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
6
6
|
* *
|
7
7
|
* This program is free software; you can redistribute it and/or modify *
|
8
|
-
* it under the terms of the
|
9
|
-
*
|
10
|
-
* (at your option) any later version. *
|
8
|
+
* it under the terms of the WTFPL 2.0 or later, see *
|
9
|
+
* http://www.wtfpl.net/about/ *
|
11
10
|
* *
|
12
11
|
* This program is distributed in the hope that it will be useful, *
|
13
12
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
15
|
-
* GNU General Public License for more details. *
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
16
14
|
* *
|
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
15
|
***************************************************************************/
|
22
16
|
=end
|
23
17
|
|
@@ -25,7 +19,7 @@ require 'roo'
|
|
25
19
|
require 'io/wait'
|
26
20
|
require 'io/console'
|
27
21
|
|
28
|
-
require_relative '
|
22
|
+
require_relative 'basic_logging'
|
29
23
|
require_relative 'scrollable'
|
30
24
|
require_relative 'row'
|
31
25
|
require_relative 'cell'
|
@@ -45,7 +39,7 @@ require_relative 'translating'
|
|
45
39
|
#TODO: provide conversion for column designators to int vv, also for AA to ZZ !
|
46
40
|
|
47
41
|
class SheetInterface
|
48
|
-
include
|
42
|
+
include BasicLogging
|
49
43
|
include Translating
|
50
44
|
|
51
45
|
class Status
|
@@ -59,7 +53,6 @@ class SheetInterface
|
|
59
53
|
end
|
60
54
|
|
61
55
|
def initialize(wb, num)
|
62
|
-
init_logger(STDOUT, Logger::INFO)
|
63
56
|
@workbook = wb.sheet(num)
|
64
57
|
@menu = nil
|
65
58
|
@status = Status.new
|
@@ -75,7 +68,7 @@ class SheetInterface
|
|
75
68
|
size = `stty size`.split.map { |x| x.to_i }.reverse
|
76
69
|
return size
|
77
70
|
end
|
78
|
-
# Asks the user to enter a number, then verifies
|
71
|
+
# Asks the user to enter a number, then verifies against eventual
|
79
72
|
# constraints.
|
80
73
|
def ask_number(question, &constraint)
|
81
74
|
num = nil
|
@@ -197,8 +190,8 @@ class SheetInterface
|
|
197
190
|
end
|
198
191
|
|
199
192
|
if sn && !sn.to_s.empty?
|
200
|
-
|
201
|
-
|
193
|
+
debug('calling workbook.sheet with ' << sn.to_s)
|
194
|
+
debug('@workbook is of type ' << @workbook.class.name)
|
202
195
|
set_sheet(sn)
|
203
196
|
end
|
204
197
|
construct
|
@@ -230,7 +223,7 @@ class SheetInterface
|
|
230
223
|
begin
|
231
224
|
File::open(file, 'w+') do |out|
|
232
225
|
@workbook.sheets.each do |s|
|
233
|
-
|
226
|
+
debug('writing sheet ' << s)
|
234
227
|
set_sheet(s)
|
235
228
|
construct(false)
|
236
229
|
draw(out)
|
@@ -385,13 +378,7 @@ class SheetInterface
|
|
385
378
|
end
|
386
379
|
|
387
380
|
end
|
388
|
-
|
389
|
-
table_width = hline.length
|
390
|
-
tw = terminal_size[0]
|
391
|
-
if(on_screen && table_width > tw)
|
392
|
-
@status.message = red("ATTN! Terminal is to narrow to display the whole table (#{tw} characters for #{table_width}). Diminish column-width!")
|
393
|
-
end
|
394
|
-
=end
|
381
|
+
|
395
382
|
return table_view
|
396
383
|
else
|
397
384
|
return nil
|
@@ -436,7 +423,6 @@ class SheetInterface
|
|
436
423
|
end
|
437
424
|
end
|
438
425
|
end
|
439
|
-
|
440
426
|
bi.stop("\n")
|
441
427
|
if(on_screen)
|
442
428
|
@table_view = draw()
|
data/lib/translating.rb
CHANGED
@@ -1,23 +1,17 @@
|
|
1
1
|
#encoding: UTF-8
|
2
|
+
|
2
3
|
=begin
|
3
4
|
/***************************************************************************
|
4
|
-
* ©2011-
|
5
|
-
* <michael.uplawski@uplawski.eu> *
|
5
|
+
* ©2011-2024, Michael Uplawski <michael.uplawski@uplawski.eu> *
|
6
6
|
* *
|
7
7
|
* This program is free software; you can redistribute it and/or modify *
|
8
|
-
* it under the terms of the
|
9
|
-
*
|
10
|
-
*
|
11
|
-
* *
|
8
|
+
* it under the terms of the WTFPL 2.0 or later, see *
|
9
|
+
* http://www.wtfpl.net/about/ *
|
10
|
+
* *
|
12
11
|
* This program is distributed in the hope that it will be useful, *
|
13
12
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
15
|
-
* GNU General Public License for more details. *
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
16
14
|
* *
|
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
15
|
***************************************************************************/
|
22
16
|
=end
|
23
17
|
|
data/lib/user_input.rb
CHANGED
@@ -1,23 +1,16 @@
|
|
1
1
|
#encoding: UTF-8
|
2
|
-
|
3
2
|
=begin
|
4
3
|
/***************************************************************************
|
5
|
-
*
|
4
|
+
* ©2014-2024, 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
|
9
|
-
*
|
10
|
-
* (at your option) any later version. *
|
7
|
+
* it under the terms of the WTFPL 2.0 or later, see *
|
8
|
+
* http://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.
|
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
|
|