spreadbase 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,69 @@
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
+ require 'tempfile'
22
+ require 'zipruby'
23
+
24
+ module UtilsHelpers
25
+
26
+ # The file is closed before being passed to the block; even if overwritten, it's deleted when
27
+ # the object is garbage-collected.
28
+ #
29
+ # options:
30
+ # :content [nil]
31
+ # :name_prefix [spreadbase_testing]
32
+ #
33
+ def with_tempfile( options={}, &block )
34
+ content = options[ :content ]
35
+ name_prefix = options[ :name_prefix ] || 'spreadbase_testing'
36
+
37
+ temp_file = Tempfile.new( name_prefix )
38
+
39
+ temp_file << content if content
40
+
41
+ temp_file.close
42
+
43
+ yield( temp_file )
44
+
45
+ temp_file
46
+ end
47
+
48
+ # Create an archive, whose entries' path is relative to the path passed.
49
+ #
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'
53
+
54
+ absolute_files = Dir.glob( absolute_path + '**/*' )
55
+
56
+ Zip::Archive.open( zip_filename, Zip::CREATE ) do | archive |
57
+ absolute_files.each do | absolute_file |
58
+ # Lovely ZipRuby
59
+ #
60
+ next if File.directory?( absolute_file )
61
+
62
+ relative_file = absolute_file.sub( absolute_path, '' )
63
+
64
+ archive.add_file( relative_file, absolute_file )
65
+ end
66
+ end
67
+ end
68
+
69
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spreadbase
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Saverio Miroddi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: zipruby
16
+ requirement: &18448480 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.3.6
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *18448480
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &18447960 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.9.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *18447960
36
+ description: Library for reading/writing OpenOffice Calc documents.
37
+ email:
38
+ - saverio.pub2@gmail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - COPYING.LESSER
45
+ - README.md
46
+ - lib/spreadbase.rb
47
+ - lib/spreadbase/codecs/open_document_12.rb
48
+ - lib/spreadbase/codecs/open_document_12_modules/decoding.rb
49
+ - lib/spreadbase/codecs/open_document_12_modules/encoding.rb
50
+ - lib/spreadbase/document.rb
51
+ - lib/spreadbase/helpers/helpers.rb
52
+ - lib/spreadbase/table.rb
53
+ - lib/spreadbase/version.rb
54
+ - spec/codecs/open_document_12_spec.rb
55
+ - spec/elements/document_spec.rb
56
+ - spec/elements/table_spec.rb
57
+ - spec/spec_helpers.rb
58
+ - spreadbase.gemspec
59
+ - utils/convert_sqlite_to_ods.rb
60
+ - utils/prettify_file.rb
61
+ - utils/test_ods_folder.rb
62
+ - utils/test_recoding_file.rb
63
+ - utils/test_recoding_from_content.rb
64
+ - utils/utils_helpers.rb
65
+ homepage: ''
66
+ licenses: []
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.17
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Library for reading/writing OpenOffice Calc documents.
89
+ test_files: []