viewworkbook 0.1.3 → 0.2
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/lib/action.rb +6 -14
- data/lib/basic_logging.rb +178 -0
- data/lib/cell.rb +9 -18
- data/lib/color_output.rb +16 -0
- data/lib/column.rb +9 -17
- data/lib/file_checking.rb +36 -11
- data/lib/menu.rb +7 -23
- data/lib/row.rb +8 -16
- data/lib/scrollable.rb +8 -17
- data/lib/sheetdata.rb +41 -57
- data/lib/sheetinterface.rb +10 -24
- data/lib/translating.rb +6 -12
- data/lib/user_input.rb +4 -11
- data/lib/viewworkbook.rb +20 -31
- data/viewworkbook.gemspec +20 -0
- metadata +19 -38
- data/lib/log.conf +0 -62
- data/lib/logging.rb +0 -195
data/lib/menu.rb
CHANGED
@@ -1,41 +1,31 @@
|
|
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
25
|
|
33
26
|
class Menu
|
34
|
-
|
35
|
-
self.extend(Logging)
|
36
|
-
@@log = self.init_logger(STDOUT)
|
27
|
+
include BasicLogging
|
37
28
|
|
38
|
-
attr_accessor :key, :name
|
39
29
|
|
40
30
|
class MenuError < StandardError
|
41
31
|
end
|
@@ -44,7 +34,6 @@ class Menu
|
|
44
34
|
@@hidden_elements = []
|
45
35
|
|
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')
|
@@ -77,7 +66,6 @@ class Menu
|
|
77
66
|
end
|
78
67
|
end
|
79
68
|
|
80
|
-
|
81
69
|
private
|
82
70
|
def show()
|
83
71
|
@elements.each do |ele|
|
@@ -89,11 +77,6 @@ class Menu
|
|
89
77
|
ele = nil
|
90
78
|
until ele
|
91
79
|
key = "%c" %wait_for_user
|
92
|
-
=begin
|
93
|
-
if "\e" == key
|
94
|
-
break
|
95
|
-
end
|
96
|
-
=end
|
97
80
|
ele = @elements.detect{ |e| key == e.key }
|
98
81
|
ele ||= @@global_elements.detect{ |e| key == e.key }
|
99
82
|
end
|
@@ -101,6 +84,7 @@ class Menu
|
|
101
84
|
end
|
102
85
|
|
103
86
|
public
|
87
|
+
attr_accessor :key, :name
|
104
88
|
alias :add_action :add
|
105
89
|
alias :add_sub_menu :add
|
106
90
|
alias :add_menu :add
|
data/lib/row.rb
CHANGED
@@ -1,36 +1,28 @@
|
|
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
|
@@ -44,7 +36,7 @@ class Row
|
|
44
36
|
n_cell = Cell.new(@number, cell)
|
45
37
|
else
|
46
38
|
msg = 'For a new cell, a colum-number must be specified'
|
47
|
-
|
39
|
+
error(red(msg))
|
48
40
|
raise StandardError(msg)
|
49
41
|
end
|
50
42
|
@cells.insert(n_cell.col, n_cell)
|
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,46 +1,44 @@
|
|
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-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
|
+
***************************************************************************/
|
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
24
|
# Transforms a file into a Roo spreadsheet instance.
|
31
25
|
|
32
|
-
ODS_Magic
|
33
|
-
XLS_Magic
|
26
|
+
ODS_Magic = "OpenDocument Spreadsheet"
|
27
|
+
XLS_Magic = "Composite Document File V2 Document"
|
34
28
|
XLSX_Magic = "Microsoft OOXML"
|
29
|
+
# SoftMaker Office
|
30
|
+
PMDX_Magic = "Microsoft Excel 2007+"
|
35
31
|
|
36
|
-
ODS_MIME
|
37
|
-
XLS_MIME
|
38
|
-
XLSX_MIME = "application/
|
39
|
-
CSV_MIME
|
32
|
+
ODS_MIME = "application/vnd.oasis.opendocument.spreadsheet"
|
33
|
+
XLS_MIME = "application/vnd.ms-excel"
|
34
|
+
XLSX_MIME = "application/zip"
|
35
|
+
CSV_MIME = "text/plain"
|
36
|
+
# SoftMaker Office
|
37
|
+
PMDX_MIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
40
38
|
|
41
39
|
class SheetData
|
42
|
-
|
43
|
-
|
40
|
+
# logs on class level
|
41
|
+
self.extend BasicLogging
|
44
42
|
|
45
43
|
@@file = nil
|
46
44
|
@@workbook = nil
|
@@ -49,48 +47,34 @@ class SheetData
|
|
49
47
|
@@file = file
|
50
48
|
if !@@workbook
|
51
49
|
begin
|
52
|
-
|
53
|
-
|
50
|
+
fm = FileMagic.mime
|
51
|
+
mtype = fm.fd(File.new(file) ).split(';')[0]
|
52
|
+
fm = FileMagic.fm
|
53
|
+
magic = fm.fd(File.new(file) ).split(';')[0]
|
54
|
+
@@workbook = case mtype
|
54
55
|
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
|
56
|
+
debug('ODS')
|
57
|
+
Roo::Spreadsheet::open(@@file, extension: :ods )
|
58
|
+
when (XLS_MIME)
|
59
|
+
debug('XLS')
|
60
|
+
Roo::Spreadsheet::open(@@file, extension: :xls )
|
61
|
+
when XLSX_MIME, PMDX_MIME
|
62
|
+
debug('XLSX')
|
63
|
+
Roo::Spreadsheet::open(@@file, extension: :xlsx )
|
69
64
|
when CSV_MIME
|
70
65
|
raise IOError.new('CSV is not yet supported, sorry')
|
71
66
|
else
|
72
|
-
raise IOError.new('Mime-Type is ' <<
|
67
|
+
raise IOError.new('Mime-Type is ' << mtype << ' and Magic sais: ' << magic << ". Is this supposed to be a spreadsheet?")
|
73
68
|
end
|
74
69
|
rescue Exception => ex
|
75
70
|
msg = 'ERROR! File %s is not supported: %s' %[@@file, ex.message]
|
76
71
|
puts msg
|
77
|
-
|
72
|
+
error yellow(msg)
|
78
73
|
exit false
|
79
74
|
end
|
80
75
|
|
81
76
|
return @@workbook
|
82
77
|
end
|
83
78
|
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
79
|
end
|
96
80
|
|
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
|
@@ -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
|
|
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
|
-
*
|
7
|
-
*
|
8
|
-
* This program is free software; you can redistribute it and/or modify
|
9
|
-
* it under the terms of the
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
|
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
|
-
|
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
|
26
|
+
include BasicLogging
|
37
27
|
include File_Checking
|
38
28
|
|
39
29
|
attr_reader :workbook
|
40
30
|
|
41
31
|
def initialize(*args)
|
42
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
65
|
+
debug('default_sheet is ' << sheets[number])
|
77
66
|
SheetInterface.new(@workbook, number)
|
78
67
|
end
|
79
68
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'viewworkbook'
|
3
|
+
s.version = '0.2'
|
4
|
+
s.date = '2024-01-03'
|
5
|
+
s.summary = "New logging module, new License, runtime-dependencies corrected."
|
6
|
+
s.summary << "Better support for SoftMaker's PMDX format"
|
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 'ruby-filemagic', '~> 0.3', '>= 0.3.2'
|
17
|
+
s.executables = 'viewworkbook'
|
18
|
+
s.license = 'Nonstandard'
|
19
|
+
s.required_ruby_version = '>= 3.0'
|
20
|
+
end
|