spreadbase 0.1.2 → 0.3.0

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.
@@ -1,43 +1,24 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
2
 
4
- =begin
5
- Copyright 2012 Saverio Miroddi saverio.pub2 <a-hat!> gmail.com
6
-
7
- This file is part of SpreadBase.
8
-
9
- SpreadBase is free software: you can redistribute it and/or modify it under the
10
- terms of the GNU Lesser General Public License as published by the Free Software
11
- Foundation, either version 3 of the License, or (at your option) any later
12
- version.
13
-
14
- SpreadBase is distributed in the hope that it will be useful, but WITHOUT ANY
15
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
16
- PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17
-
18
- You should have received a copy of the GNU Lesser General Public License along
19
- with SpreadBase. If not, see <http://www.gnu.org/licenses/>.
20
- =end
21
-
22
- require File.expand_path( '../../lib/spreadbase', __FILE__ )
23
- require File.expand_path( '../utils_helpers', __FILE__ )
3
+ require_relative '../lib/spreadbase'
4
+ require_relative 'utils_helpers'
24
5
 
25
6
  include UtilsHelpers
26
7
 
27
- def test_recoding_from_content( file_path )
28
- content_xml_data = IO.read( file_path )
29
- document = SpreadBase::Codecs::OpenDocument12.new.decode_content_xml( content_xml_data )
8
+ def test_recoding_from_content(file_path)
9
+ content_xml_data = IO.read(file_path)
10
+ document = SpreadBase::Codecs::OpenDocument12.new.decode_content_xml(content_xml_data)
30
11
 
31
12
  with_tempfile do | temp_file |
32
13
  document.document_path = temp_file.path
33
- document.save( :prettify => true )
14
+ document.save(prettify: true)
34
15
 
35
- `openoffice.org3 #{ temp_file.path }`
16
+ open_office_document(temp_file.path)
36
17
  end
37
18
  end
38
19
 
39
- if __FILE__ == $0
40
- file_path = ARGV[ 0 ] || raise( "Usage: test_recoding_from_content.rb <file>" )
20
+ if __FILE__ == $PROGRAM_NAME
21
+ file_path = ARGV[0] || raise("Usage: test_recoding_from_content.rb <file>")
41
22
 
42
- test_recoding_from_content( file_path )
23
+ test_recoding_from_content(file_path)
43
24
  end
@@ -1,28 +1,14 @@
1
- # encoding: UTF-8
2
-
3
- =begin
4
- Copyright 2012 Saverio Miroddi saverio.pub2 <a-hat!> gmail.com
5
-
6
- This file is part of SpreadBase.
7
-
8
- SpreadBase is free software: you can redistribute it and/or modify it under the
9
- terms of the GNU Lesser General Public License as published by the Free Software
10
- Foundation, either version 3 of the License, or (at your option) any later
11
- version.
12
-
13
- SpreadBase is distributed in the hope that it will be useful, but WITHOUT ANY
14
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15
- PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
-
17
- You should have received a copy of the GNU Lesser General Public License along
18
- with SpreadBase. If not, see <http://www.gnu.org/licenses/>.
19
- =end
20
-
21
1
  require 'tempfile'
22
2
  require 'zipruby'
23
3
 
24
4
  module UtilsHelpers
25
5
 
6
+ # Kept trivial; will extend if needed/useful.
7
+ #
8
+ def open_office_document(file)
9
+ `xdg-open '#{ file }'`
10
+ end
11
+
26
12
  # The file is closed before being passed to the block; even if overwritten, it's deleted when
27
13
  # the object is garbage-collected.
28
14
  #
@@ -30,38 +16,38 @@ module UtilsHelpers
30
16
  # :content [nil]
31
17
  # :name_prefix [spreadbase_testing]
32
18
  #
33
- def with_tempfile( options={}, &block )
34
- content = options[ :content ]
35
- name_prefix = options[ :name_prefix ] || 'spreadbase_testing'
19
+ def with_tempfile(options={}, &block)
20
+ content = options[:content]
21
+ name_prefix = options[:name_prefix] || 'spreadbase_testing'
36
22
 
37
- temp_file = Tempfile.new( name_prefix )
23
+ temp_file = Tempfile.new(name_prefix)
38
24
 
39
25
  temp_file << content if content
40
26
 
41
27
  temp_file.close
42
28
 
43
- yield( temp_file )
29
+ yield(temp_file)
44
30
 
45
31
  temp_file
46
32
  end
47
33
 
48
34
  # Create an archive, whose entries' path is relative to the path passed.
49
35
  #
50
- def relative_compress_to_zip( folder_path, options={} )
51
- absolute_path = File.expand_path( folder_path ) + '/'
52
- zip_filename = options[ :zip_filename ] || File.expand_path( folder_path ) + '.zip'
36
+ def relative_compress_to_zip(folder_path, options={})
37
+ absolute_path = File.expand_path(folder_path) + '/'
38
+ zip_filename = options[:zip_filename] || File.expand_path(folder_path) + '.zip'
53
39
 
54
- absolute_files = Dir.glob( absolute_path + '**/*' )
40
+ absolute_files = Dir.glob(absolute_path + '**/*')
55
41
 
56
- Zip::Archive.open( zip_filename, Zip::CREATE ) do | archive |
42
+ Zip::Archive.open(zip_filename, Zip::CREATE) do | archive |
57
43
  absolute_files.each do | absolute_file |
58
44
  # Lovely ZipRuby
59
45
  #
60
- next if File.directory?( absolute_file )
46
+ next if File.directory?(absolute_file)
61
47
 
62
- relative_file = absolute_file.sub( absolute_path, '' )
48
+ relative_file = absolute_file.sub(absolute_path, '')
63
49
 
64
- archive.add_file( relative_file, absolute_file )
50
+ archive.add_file(relative_file, absolute_file)
65
51
  end
66
52
  end
67
53
  end
metadata CHANGED
@@ -1,38 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreadbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Saverio Miroddi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-04-27 00:00:00.000000000 Z
11
+ date: 2021-03-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: zipruby
16
- requirement: &18448480 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: rubyzip
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 0.3.6
19
+ version: 2.3.0
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *18448480
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.3.0
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: rspec
27
- requirement: &18447960 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.9.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
29
37
  requirements:
30
- - - ~>
38
+ - - "~>"
31
39
  - !ruby/object:Gem::Version
32
- version: 2.9.0
40
+ version: 3.9.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
33
48
  type: :development
34
49
  prerelease: false
35
- version_requirements: *18447960
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
36
55
  description: Library for reading/writing OpenOffice Calc documents.
37
56
  email:
38
57
  - saverio.pub2@gmail.com
@@ -40,10 +59,17 @@ executables: []
40
59
  extensions: []
41
60
  extra_rdoc_files: []
42
61
  files:
43
- - .gitignore
44
- - COPYING.LESSER
62
+ - ".github/workflows/ci.yml"
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - Gemfile
66
+ - LICENSE
45
67
  - README.md
68
+ - Rakefile
69
+ - docs/STRUCTURE.md
70
+ - docs/TESTING.md
46
71
  - lib/spreadbase.rb
72
+ - lib/spreadbase/cell.rb
47
73
  - lib/spreadbase/codecs/open_document_12.rb
48
74
  - lib/spreadbase/codecs/open_document_12_modules/decoding.rb
49
75
  - lib/spreadbase/codecs/open_document_12_modules/encoding.rb
@@ -54,36 +80,36 @@ files:
54
80
  - spec/codecs/open_document_12_spec.rb
55
81
  - spec/elements/document_spec.rb
56
82
  - spec/elements/table_spec.rb
83
+ - spec/fixtures/test.ods
84
+ - spec/spec_helper.rb
57
85
  - spec/spec_helpers.rb
58
86
  - spreadbase.gemspec
59
87
  - utils/convert_sqlite_to_ods.rb
60
- - utils/prettify_file.rb
61
88
  - utils/test_ods_folder.rb
62
89
  - utils/test_recoding_file.rb
63
90
  - utils/test_recoding_from_content.rb
64
91
  - utils/utils_helpers.rb
65
- homepage: ''
66
- licenses: []
92
+ homepage: https://github.com/saveriomiroddi/spreadbase
93
+ licenses:
94
+ - GPL-3.0
95
+ metadata: {}
67
96
  post_install_message:
68
97
  rdoc_options: []
69
98
  require_paths:
70
99
  - lib
71
100
  required_ruby_version: !ruby/object:Gem::Requirement
72
- none: false
73
101
  requirements:
74
- - - ! '>='
102
+ - - ">="
75
103
  - !ruby/object:Gem::Version
76
- version: '0'
104
+ version: 2.4.0
77
105
  required_rubygems_version: !ruby/object:Gem::Requirement
78
- none: false
79
106
  requirements:
80
- - - ! '>='
107
+ - - ">="
81
108
  - !ruby/object:Gem::Version
82
109
  version: '0'
83
110
  requirements: []
84
- rubyforge_project:
85
- rubygems_version: 1.8.17
111
+ rubygems_version: 3.2.3
86
112
  signing_key:
87
- specification_version: 3
113
+ specification_version: 4
88
114
  summary: Library for reading/writing OpenOffice Calc documents.
89
115
  test_files: []
data/COPYING.LESSER DELETED
@@ -1,165 +0,0 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
-
9
- This version of the GNU Lesser General Public License incorporates
10
- the terms and conditions of version 3 of the GNU General Public
11
- License, supplemented by the additional permissions listed below.
12
-
13
- 0. Additional Definitions.
14
-
15
- As used herein, "this License" refers to version 3 of the GNU Lesser
16
- General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
- General Public License.
18
-
19
- "The Library" refers to a covered work governed by this License,
20
- other than an Application or a Combined Work as defined below.
21
-
22
- An "Application" is any work that makes use of an interface provided
23
- by the Library, but which is not otherwise based on the Library.
24
- Defining a subclass of a class defined by the Library is deemed a mode
25
- of using an interface provided by the Library.
26
-
27
- A "Combined Work" is a work produced by combining or linking an
28
- Application with the Library. The particular version of the Library
29
- with which the Combined Work was made is also called the "Linked
30
- Version".
31
-
32
- The "Minimal Corresponding Source" for a Combined Work means the
33
- Corresponding Source for the Combined Work, excluding any source code
34
- for portions of the Combined Work that, considered in isolation, are
35
- based on the Application, and not on the Linked Version.
36
-
37
- The "Corresponding Application Code" for a Combined Work means the
38
- object code and/or source code for the Application, including any data
39
- and utility programs needed for reproducing the Combined Work from the
40
- Application, but excluding the System Libraries of the Combined Work.
41
-
42
- 1. Exception to Section 3 of the GNU GPL.
43
-
44
- You may convey a covered work under sections 3 and 4 of this License
45
- without being bound by section 3 of the GNU GPL.
46
-
47
- 2. Conveying Modified Versions.
48
-
49
- If you modify a copy of the Library, and, in your modifications, a
50
- facility refers to a function or data to be supplied by an Application
51
- that uses the facility (other than as an argument passed when the
52
- facility is invoked), then you may convey a copy of the modified
53
- version:
54
-
55
- a) under this License, provided that you make a good faith effort to
56
- ensure that, in the event an Application does not supply the
57
- function or data, the facility still operates, and performs
58
- whatever part of its purpose remains meaningful, or
59
-
60
- b) under the GNU GPL, with none of the additional permissions of
61
- this License applicable to that copy.
62
-
63
- 3. Object Code Incorporating Material from Library Header Files.
64
-
65
- The object code form of an Application may incorporate material from
66
- a header file that is part of the Library. You may convey such object
67
- code under terms of your choice, provided that, if the incorporated
68
- material is not limited to numerical parameters, data structure
69
- layouts and accessors, or small macros, inline functions and templates
70
- (ten or fewer lines in length), you do both of the following:
71
-
72
- a) Give prominent notice with each copy of the object code that the
73
- Library is used in it and that the Library and its use are
74
- covered by this License.
75
-
76
- b) Accompany the object code with a copy of the GNU GPL and this license
77
- document.
78
-
79
- 4. Combined Works.
80
-
81
- You may convey a Combined Work under terms of your choice that,
82
- taken together, effectively do not restrict modification of the
83
- portions of the Library contained in the Combined Work and reverse
84
- engineering for debugging such modifications, if you also do each of
85
- the following:
86
-
87
- a) Give prominent notice with each copy of the Combined Work that
88
- the Library is used in it and that the Library and its use are
89
- covered by this License.
90
-
91
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
- document.
93
-
94
- c) For a Combined Work that displays copyright notices during
95
- execution, include the copyright notice for the Library among
96
- these notices, as well as a reference directing the user to the
97
- copies of the GNU GPL and this license document.
98
-
99
- d) Do one of the following:
100
-
101
- 0) Convey the Minimal Corresponding Source under the terms of this
102
- License, and the Corresponding Application Code in a form
103
- suitable for, and under terms that permit, the user to
104
- recombine or relink the Application with a modified version of
105
- the Linked Version to produce a modified Combined Work, in the
106
- manner specified by section 6 of the GNU GPL for conveying
107
- Corresponding Source.
108
-
109
- 1) Use a suitable shared library mechanism for linking with the
110
- Library. A suitable mechanism is one that (a) uses at run time
111
- a copy of the Library already present on the user's computer
112
- system, and (b) will operate properly with a modified version
113
- of the Library that is interface-compatible with the Linked
114
- Version.
115
-
116
- e) Provide Installation Information, but only if you would otherwise
117
- be required to provide such information under section 6 of the
118
- GNU GPL, and only to the extent that such information is
119
- necessary to install and execute a modified version of the
120
- Combined Work produced by recombining or relinking the
121
- Application with a modified version of the Linked Version. (If
122
- you use option 4d0, the Installation Information must accompany
123
- the Minimal Corresponding Source and Corresponding Application
124
- Code. If you use option 4d1, you must provide the Installation
125
- Information in the manner specified by section 6 of the GNU GPL
126
- for conveying Corresponding Source.)
127
-
128
- 5. Combined Libraries.
129
-
130
- You may place library facilities that are a work based on the
131
- Library side by side in a single library together with other library
132
- facilities that are not Applications and are not covered by this
133
- License, and convey such a combined library under terms of your
134
- choice, if you do both of the following:
135
-
136
- a) Accompany the combined library with a copy of the same work based
137
- on the Library, uncombined with any other library facilities,
138
- conveyed under the terms of this License.
139
-
140
- b) Give prominent notice with the combined library that part of it
141
- is a work based on the Library, and explaining where to find the
142
- accompanying uncombined form of the same work.
143
-
144
- 6. Revised Versions of the GNU Lesser General Public License.
145
-
146
- The Free Software Foundation may publish revised and/or new versions
147
- of the GNU Lesser General Public License from time to time. Such new
148
- versions will be similar in spirit to the present version, but may
149
- differ in detail to address new problems or concerns.
150
-
151
- Each version is given a distinguishing version number. If the
152
- Library as you received it specifies that a certain numbered version
153
- of the GNU Lesser General Public License "or any later version"
154
- applies to it, you have the option of following the terms and
155
- conditions either of that published version or of any later version
156
- published by the Free Software Foundation. If the Library as you
157
- received it does not specify a version number of the GNU Lesser
158
- General Public License, you may choose any version of the GNU Lesser
159
- General Public License ever published by the Free Software Foundation.
160
-
161
- If the Library as you received it specifies that a proxy can decide
162
- whether future versions of the GNU Lesser General Public License shall
163
- apply, that proxy's public statement of acceptance of any version is
164
- permanent authorization for you to choose that version for the
165
- Library.
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- =begin
5
- Copyright 2012 Saverio Miroddi saverio.pub2 <a-hat!> gmail.com
6
-
7
- This file is part of SpreadBase.
8
-
9
- SpreadBase is free software: you can redistribute it and/or modify it under the
10
- terms of the GNU Lesser General Public License as published by the Free Software
11
- Foundation, either version 3 of the License, or (at your option) any later
12
- version.
13
-
14
- SpreadBase is distributed in the hope that it will be useful, but WITHOUT ANY
15
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
16
- PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17
-
18
- You should have received a copy of the GNU Lesser General Public License along
19
- with SpreadBase. If not, see <http://www.gnu.org/licenses/>.
20
- =end
21
-
22
- require 'rexml/document'
23
-
24
- def pretty_print( file_path, output=$stdout )
25
- xml_str = IO.read( file_path )
26
-
27
- root = REXML::Document.new( xml_str )
28
-
29
- xml_formatter = REXML::Formatters::Pretty.new
30
- xml_formatter.compact = true
31
- xml_formatter.write( root, output )
32
-
33
- nil
34
- end
35
-
36
- def prettify_file( file_path )
37
- File.open( file_path, 'r+' ) do | file |
38
- pretty_print( file_path, file )
39
- end
40
- end
41
-
42
- if __FILE__ == $0
43
- file_path = ARGV[ 0 ] || raise( "Usage: prettify_file.rb <file>" )
44
-
45
- prettify_file( file_path )
46
- end