rodf 0.3.7 → 1.2.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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +77 -0
- data/LICENSE +7 -0
- data/README.md +244 -64
- data/Rakefile +9 -17
- data/lib/rodf/cell.rb +171 -0
- data/lib/rodf/column.rb +21 -0
- data/lib/rodf/container.rb +18 -0
- data/lib/rodf/data_style.rb +46 -0
- data/lib/rodf/document.rb +133 -0
- data/lib/rodf/hyperlink.rb +33 -0
- data/lib/rodf/master_page.rb +11 -0
- data/lib/rodf/page_layout.rb +41 -0
- data/lib/rodf/paragraph.rb +28 -0
- data/lib/rodf/paragraph_container.rb +30 -0
- data/lib/rodf/property.rb +138 -0
- data/lib/rodf/row.rb +56 -0
- data/lib/{odf → rodf}/skeleton/manifest.xml.erb +0 -0
- data/lib/{odf → rodf}/skeleton/styles.pxml +0 -0
- data/lib/rodf/skeleton.rb +17 -0
- data/lib/rodf/span.rb +45 -0
- data/lib/rodf/spreadsheet.rb +113 -0
- data/lib/rodf/style.rb +77 -0
- data/lib/rodf/style_section.rb +33 -0
- data/lib/rodf/tab.rb +17 -0
- data/lib/rodf/table.rb +95 -0
- data/lib/rodf/text.rb +126 -0
- data/lib/rodf/version.rb +3 -0
- data/lib/rodf.rb +31 -0
- metadata +76 -115
- data/CHANGELOG +0 -17
- data/Gemfile +0 -9
- data/LICENSE.LGPL +0 -166
- data/Manifest +0 -48
- data/lib/odf/cell.rb +0 -104
- data/lib/odf/column.rb +0 -33
- data/lib/odf/compatibility.rb +0 -25
- data/lib/odf/container.rb +0 -57
- data/lib/odf/data_style.rb +0 -45
- data/lib/odf/document.rb +0 -67
- data/lib/odf/hyperlink.rb +0 -51
- data/lib/odf/master_page.rb +0 -33
- data/lib/odf/page_layout.rb +0 -39
- data/lib/odf/paragraph.rb +0 -46
- data/lib/odf/paragraph_container.rb +0 -35
- data/lib/odf/property.rb +0 -131
- data/lib/odf/row.rb +0 -44
- data/lib/odf/skeleton.rb +0 -34
- data/lib/odf/span.rb +0 -70
- data/lib/odf/spreadsheet.rb +0 -64
- data/lib/odf/style.rb +0 -65
- data/lib/odf/style_section.rb +0 -42
- data/lib/odf/tab.rb +0 -38
- data/lib/odf/table.rb +0 -50
- data/lib/odf/text.rb +0 -66
- data/rodf.gemspec +0 -48
- data/spec/cell_spec.rb +0 -189
- data/spec/data_style_spec.rb +0 -61
- data/spec/file_storage_spec.rb +0 -47
- data/spec/hyperlink_spec.rb +0 -62
- data/spec/master_page_spec.rb +0 -35
- data/spec/page_layout_spec.rb +0 -45
- data/spec/paragraph_spec.rb +0 -75
- data/spec/property_spec.rb +0 -270
- data/spec/row_spec.rb +0 -59
- data/spec/skeleton_spec.rb +0 -33
- data/spec/span_spec.rb +0 -65
- data/spec/spec_helper.rb +0 -23
- data/spec/spreadsheet_spec.rb +0 -123
- data/spec/style_section_spec.rb +0 -42
- data/spec/style_spec.rb +0 -109
- data/spec/tab_spec.rb +0 -34
- data/spec/table_spec.rb +0 -90
- data/spec/text_spec.rb +0 -79
data/lib/odf/spreadsheet.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require 'rubygems'
|
19
|
-
|
20
|
-
require 'builder'
|
21
|
-
|
22
|
-
require 'odf/data_style'
|
23
|
-
require 'odf/document'
|
24
|
-
require 'odf/hyperlink'
|
25
|
-
require 'odf/span'
|
26
|
-
require 'odf/table'
|
27
|
-
|
28
|
-
module ODF
|
29
|
-
class Spreadsheet < Document
|
30
|
-
contains :tables, :data_styles
|
31
|
-
|
32
|
-
def xml
|
33
|
-
b = Builder::XmlMarkup.new
|
34
|
-
|
35
|
-
b.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'
|
36
|
-
b.tag! 'office:document-content',
|
37
|
-
'xmlns:office' => "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
|
38
|
-
'xmlns:table' => "urn:oasis:names:tc:opendocument:xmlns:table:1.0",
|
39
|
-
'xmlns:text' => "urn:oasis:names:tc:opendocument:xmlns:text:1.0",
|
40
|
-
'xmlns:oooc' => "http://openoffice.org/2004/calc",
|
41
|
-
'xmlns:style' => "urn:oasis:names:tc:opendocument:xmlns:style:1.0",
|
42
|
-
'xmlns:fo' => "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",
|
43
|
-
'xmlns:number' => "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0",
|
44
|
-
'xmlns:xlink' => "http://www.w3.org/1999/xlink" do
|
45
|
-
|xml|
|
46
|
-
xml.tag! 'office:styles' do
|
47
|
-
xml << default_styles_xml
|
48
|
-
end unless default_styles.empty?
|
49
|
-
xml.tag! 'office:automatic-styles' do
|
50
|
-
xml << styles_xml
|
51
|
-
xml << data_styles_xml
|
52
|
-
end unless styles.empty? && data_styles.empty?
|
53
|
-
xml.office:body do
|
54
|
-
xml.office:spreadsheet do
|
55
|
-
xml << tables_xml
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
SpreadSheet = Spreadsheet
|
63
|
-
end
|
64
|
-
|
data/lib/odf/style.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require 'rubygems'
|
19
|
-
require 'builder'
|
20
|
-
|
21
|
-
require 'odf/container'
|
22
|
-
require 'odf/property'
|
23
|
-
|
24
|
-
module ODF
|
25
|
-
class Style < Container
|
26
|
-
contains :properties
|
27
|
-
|
28
|
-
FAMILIES = {:cell => 'table-cell', :column => 'table-column', :row => 'table-row'}
|
29
|
-
|
30
|
-
def initialize(name='', opts={}, node_tag='style:style')
|
31
|
-
@name, @node_tag = name, node_tag
|
32
|
-
@elem_attrs = make_element_attributes(@name, opts)
|
33
|
-
end
|
34
|
-
|
35
|
-
def xml
|
36
|
-
Builder::XmlMarkup.new.tag!(@node_tag, @elem_attrs) do |xml|
|
37
|
-
xml << properties_xml
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def make_element_attributes(name, opts)
|
42
|
-
attrs = {
|
43
|
-
'style:name' => name,
|
44
|
-
'style:family' => (FAMILIES[opts[:family]] || opts[:family])}
|
45
|
-
attrs['style:data-style-name'] = opts[:data_style] unless opts[:data_style].nil?
|
46
|
-
attrs['style:parent-style-name'] = opts[:parent].to_s unless opts[:parent].nil?
|
47
|
-
attrs['style:master-page-name'] = opts[:master_page] unless opts[:master_page].nil?
|
48
|
-
attrs
|
49
|
-
end
|
50
|
-
|
51
|
-
def to_s
|
52
|
-
@name
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
class OfficeStyle < Style
|
57
|
-
end
|
58
|
-
|
59
|
-
class DefaultStyle < Style
|
60
|
-
def initialize(opts={})
|
61
|
-
super(nil, opts, 'style:default-style')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
data/lib/odf/style_section.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require 'rubygems'
|
19
|
-
|
20
|
-
require 'builder'
|
21
|
-
|
22
|
-
module ODF
|
23
|
-
class StyleSection
|
24
|
-
def initialize(type, second = {})
|
25
|
-
@type = type
|
26
|
-
if second.instance_of?(Hash)
|
27
|
-
@elem_attrs = make_element_attributes(second)
|
28
|
-
else
|
29
|
-
@content, @elem_attrs = second, {}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def xml
|
34
|
-
Builder::XmlMarkup.new.number @type, @content, @elem_attrs
|
35
|
-
end
|
36
|
-
|
37
|
-
def make_element_attributes(opts)
|
38
|
-
{'number:style' => opts[:style], 'number:textual' => opts[:textual]}
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
data/lib/odf/tab.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require 'rubygems'
|
19
|
-
require 'builder'
|
20
|
-
|
21
|
-
require 'odf/paragraph_container'
|
22
|
-
|
23
|
-
module ODF
|
24
|
-
class Tab
|
25
|
-
def xml
|
26
|
-
Builder::XmlMarkup.new.text:tab
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class ParagraphContainer < Container
|
31
|
-
def tab(*args)
|
32
|
-
t = Tab.new
|
33
|
-
content_parts << t
|
34
|
-
t
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
data/lib/odf/table.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require 'rubygems'
|
19
|
-
require 'builder'
|
20
|
-
|
21
|
-
require 'odf/column'
|
22
|
-
require 'odf/container'
|
23
|
-
require 'odf/row'
|
24
|
-
|
25
|
-
module ODF
|
26
|
-
class Table < Container
|
27
|
-
contains :rows, :columns
|
28
|
-
|
29
|
-
def initialize(title)
|
30
|
-
@title = title
|
31
|
-
@last_row = 0
|
32
|
-
end
|
33
|
-
|
34
|
-
alias create_row row
|
35
|
-
def row(options={}, &contents)
|
36
|
-
create_row(next_row, options) {instance_eval(&contents) if block_given?}
|
37
|
-
end
|
38
|
-
|
39
|
-
def xml
|
40
|
-
Builder::XmlMarkup.new.table:table, 'table:name' => @title do |xml|
|
41
|
-
xml << columns_xml
|
42
|
-
xml << rows_xml
|
43
|
-
end
|
44
|
-
end
|
45
|
-
private
|
46
|
-
def next_row
|
47
|
-
@last_row += 1
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/lib/odf/text.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require 'rubygems'
|
19
|
-
|
20
|
-
require 'builder'
|
21
|
-
|
22
|
-
require 'odf/document'
|
23
|
-
require 'odf/master_page'
|
24
|
-
require 'odf/page_layout'
|
25
|
-
require 'odf/paragraph'
|
26
|
-
require 'odf/span'
|
27
|
-
require 'odf/hyperlink'
|
28
|
-
|
29
|
-
module ODF
|
30
|
-
class Text < Document
|
31
|
-
contains :paragraphs, :page_layouts, :master_pages
|
32
|
-
|
33
|
-
alias :p :paragraph
|
34
|
-
|
35
|
-
def xml
|
36
|
-
b = Builder::XmlMarkup.new
|
37
|
-
|
38
|
-
b.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'
|
39
|
-
b.tag! 'office:document-content', 'xmlns:office' => "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
|
40
|
-
'xmlns:table' => "urn:oasis:names:tc:opendocument:xmlns:table:1.0",
|
41
|
-
'xmlns:text' => "urn:oasis:names:tc:opendocument:xmlns:text:1.0",
|
42
|
-
'xmlns:oooc' => "http://openoffice.org/2004/calc",
|
43
|
-
'xmlns:style' => "urn:oasis:names:tc:opendocument:xmlns:style:1.0",
|
44
|
-
'xmlns:fo' => "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",
|
45
|
-
'xmlns:xlink' => "http://www.w3.org/1999/xlink" do
|
46
|
-
|xml|
|
47
|
-
xml.tag! 'office:styles' do
|
48
|
-
xml << default_styles_xml
|
49
|
-
end unless default_styles.empty?
|
50
|
-
xml.tag! 'office:automatic-styles' do
|
51
|
-
xml << styles_xml
|
52
|
-
xml << page_layouts_xml
|
53
|
-
end unless styles.empty? && page_layouts.empty?
|
54
|
-
xml.tag! 'office:master-styles' do
|
55
|
-
xml << master_pages_xml
|
56
|
-
end unless master_pages.empty?
|
57
|
-
xml.office:body do
|
58
|
-
xml.office:text do
|
59
|
-
xml << paragraphs_xml
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
data/rodf.gemspec
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: rodf 0.3.7 ruby lib
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = "rodf"
|
6
|
-
s.version = "0.3.7"
|
7
|
-
|
8
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
9
|
-
s.require_paths = ["lib"]
|
10
|
-
s.authors = ["Weston Ganger, Thiago Arrais, Foivos Zakkak"]
|
11
|
-
s.date = "2016-08-30"
|
12
|
-
s.description = "ODF generation library for Ruby"
|
13
|
-
s.email = "thiago.arrais@gmail.com"
|
14
|
-
s.extra_rdoc_files = ["CHANGELOG", "LICENSE.LGPL", "README.md", "lib/odf/cell.rb", "lib/odf/column.rb", "lib/odf/compatibility.rb", "lib/odf/container.rb", "lib/odf/data_style.rb", "lib/odf/document.rb", "lib/odf/hyperlink.rb", "lib/odf/master_page.rb", "lib/odf/page_layout.rb", "lib/odf/paragraph.rb", "lib/odf/paragraph_container.rb", "lib/odf/property.rb", "lib/odf/row.rb", "lib/odf/skeleton.rb", "lib/odf/skeleton/manifest.xml.erb", "lib/odf/skeleton/styles.pxml", "lib/odf/span.rb", "lib/odf/spreadsheet.rb", "lib/odf/style.rb", "lib/odf/style_section.rb", "lib/odf/tab.rb", "lib/odf/table.rb", "lib/odf/text.rb"]
|
15
|
-
s.files = ["CHANGELOG", "Gemfile", "LICENSE.LGPL", "Manifest", "README.md", "Rakefile", "lib/odf/cell.rb", "lib/odf/column.rb", "lib/odf/compatibility.rb", "lib/odf/container.rb", "lib/odf/data_style.rb", "lib/odf/document.rb", "lib/odf/hyperlink.rb", "lib/odf/master_page.rb", "lib/odf/page_layout.rb", "lib/odf/paragraph.rb", "lib/odf/paragraph_container.rb", "lib/odf/property.rb", "lib/odf/row.rb", "lib/odf/skeleton.rb", "lib/odf/skeleton/manifest.xml.erb", "lib/odf/skeleton/styles.pxml", "lib/odf/span.rb", "lib/odf/spreadsheet.rb", "lib/odf/style.rb", "lib/odf/style_section.rb", "lib/odf/tab.rb", "lib/odf/table.rb", "lib/odf/text.rb", "rodf.gemspec", "spec/cell_spec.rb", "spec/data_style_spec.rb", "spec/file_storage_spec.rb", "spec/hyperlink_spec.rb", "spec/master_page_spec.rb", "spec/page_layout_spec.rb", "spec/paragraph_spec.rb", "spec/property_spec.rb", "spec/row_spec.rb", "spec/skeleton_spec.rb", "spec/span_spec.rb", "spec/spec_helper.rb", "spec/spreadsheet_spec.rb", "spec/style_section_spec.rb", "spec/style_spec.rb", "spec/tab_spec.rb", "spec/table_spec.rb", "spec/text_spec.rb"]
|
16
|
-
s.homepage = "http://github.com/thiagoarrais/rodf/tree"
|
17
|
-
s.rdoc_options = ["--line-numbers", "--title", "Rodf", "--main", "README.md"]
|
18
|
-
s.rubyforge_project = "rodf"
|
19
|
-
s.rubygems_version = "2.5.1"
|
20
|
-
s.summary = "ODF generation library for Ruby"
|
21
|
-
|
22
|
-
if s.respond_to? :specification_version then
|
23
|
-
s.specification_version = 4
|
24
|
-
|
25
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
-
s.add_runtime_dependency(%q<builder>, ["~> 3.0"])
|
27
|
-
s.add_runtime_dependency(%q<rubyzip>, ["~> 1.0"])
|
28
|
-
s.add_runtime_dependency(%q<activesupport>, ["< 6.0", ">= 3.0"])
|
29
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.9"])
|
30
|
-
s.add_development_dependency(%q<rspec_hpricot_matchers>, ["~> 1.0"])
|
31
|
-
s.add_development_dependency(%q<echoe>, ["~> 4.6"])
|
32
|
-
else
|
33
|
-
s.add_dependency(%q<builder>, ["~> 3.0"])
|
34
|
-
s.add_dependency(%q<rubyzip>, ["~> 1.0"])
|
35
|
-
s.add_dependency(%q<activesupport>, ["< 6.0", ">= 3.0"])
|
36
|
-
s.add_dependency(%q<rspec>, ["~> 2.9"])
|
37
|
-
s.add_dependency(%q<rspec_hpricot_matchers>, ["~> 1.0"])
|
38
|
-
s.add_dependency(%q<echoe>, ["~> 4.6"])
|
39
|
-
end
|
40
|
-
else
|
41
|
-
s.add_dependency(%q<builder>, ["~> 3.0"])
|
42
|
-
s.add_dependency(%q<rubyzip>, ["~> 1.0"])
|
43
|
-
s.add_dependency(%q<activesupport>, ["< 6.0", ">= 3.0"])
|
44
|
-
s.add_dependency(%q<rspec>, ["~> 2.9"])
|
45
|
-
s.add_dependency(%q<rspec_hpricot_matchers>, ["~> 1.0"])
|
46
|
-
s.add_dependency(%q<echoe>, ["~> 4.6"])
|
47
|
-
end
|
48
|
-
end
|
data/spec/cell_spec.rb
DELETED
@@ -1,189 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
19
|
-
|
20
|
-
require 'date'
|
21
|
-
|
22
|
-
require 'odf/cell'
|
23
|
-
|
24
|
-
describe ODF::Cell do
|
25
|
-
it "should hold text content in a paragraph tag" do
|
26
|
-
output = ODF::Cell.new('Test').xml
|
27
|
-
output.should have_tag('//table:table-cell/*')
|
28
|
-
output.should have_tag('//text:p')
|
29
|
-
Hpricot(output).at('text:p').innerHTML.should == 'Test'
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should have string as default value type" do
|
33
|
-
[ODF::Cell.new('Test').xml, ODF::Cell.new(54).xml].each do |xml|
|
34
|
-
Hpricot(xml).at('table:table-cell')['office:value-type'].should=='string'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should allow value types to be specified" do
|
39
|
-
output = ODF::Cell.new(34.2, :type => :float).xml
|
40
|
-
Hpricot(output).at('table:table-cell')['office:value-type'].should=='float'
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should place strings in a paragraph tag and floats in value attribute" do
|
44
|
-
output = ODF::Cell.new('Test').xml
|
45
|
-
Hpricot(output).at('text:p').innerHTML.should == 'Test'
|
46
|
-
|
47
|
-
output = ODF::Cell.new(47, :type => :float).xml
|
48
|
-
output.should_not have_tag('//table:table-cell/*')
|
49
|
-
Hpricot(output).at('table:table-cell')['office:value'].should == '47'
|
50
|
-
|
51
|
-
output = ODF::Cell.new(34.2, :type => :string).xml
|
52
|
-
Hpricot(output).at('text:p').innerHTML.should == '34.2'
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should accept formulas" do
|
56
|
-
output = ODF::Cell.new(:type => :float,
|
57
|
-
:formula => "oooc:=SUM([.A1:.A4])").xml
|
58
|
-
|
59
|
-
elem = Hpricot(output).at('table:table-cell')
|
60
|
-
elem['office:value-type'].should == 'float'
|
61
|
-
elem['table:formula'].should == 'oooc:=SUM([.A1:.A4])'
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should accept matrix formulas" do
|
65
|
-
output = ODF::Cell.new(:type => :float, :matrix_formula => true,
|
66
|
-
:formula => "oooc:=SUM([.A1:.A4])").xml
|
67
|
-
|
68
|
-
elem = Hpricot(output).at('table:table-cell')
|
69
|
-
elem['table:number-matrix-columns-spanned'].should == '1'
|
70
|
-
elem['table:number-matrix-rows-spanned'].should == '1'
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should not make a matrix formula when asked not too" do
|
74
|
-
output = ODF::Cell.new(:type => :float, :matrix_formula => false,
|
75
|
-
:formula => "oooc:=SUM([.A1:.A4])").xml
|
76
|
-
|
77
|
-
elem = Hpricot(output).at('table:table-cell')
|
78
|
-
elem['table:number-matrix-columns-spanned'].should be_nil
|
79
|
-
elem['table:number-matrix-rows-spanned'].should be_nil
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should not have an empty paragraph" do
|
83
|
-
[ODF::Cell.new, ODF::Cell.new(''), ODF::Cell.new(' ')].each do |cell|
|
84
|
-
cell.xml.should_not have_tag('text:p')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should allow an style to be specified in the constructor" do
|
89
|
-
cell = ODF::Cell.new 45.8, :type => :float, :style => 'left-column-cell'
|
90
|
-
Hpricot(cell.xml).at('table:table-cell')['table:style-name'].
|
91
|
-
should == 'left-column-cell'
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should allow and style to be specified through a method call" do
|
95
|
-
cell = ODF::Cell.new 45.8, :type => :float
|
96
|
-
cell.style = 'left-column-cell'
|
97
|
-
Hpricot(cell.xml).at('table:table-cell')['table:style-name'].
|
98
|
-
should == 'left-column-cell'
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should span multiple cells when asked to" do
|
102
|
-
cell = ODF::Cell.new 'Spreadsheet title', :span => 4
|
103
|
-
doc = Hpricot(cell.xml)
|
104
|
-
doc.at('table:table-cell')['table:number-columns-spanned'].should == '4'
|
105
|
-
doc.search('table:table-cell').size.should == 4
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should have the URL set correctly when requested on a string" do
|
109
|
-
cell = ODF::Cell.new 'Example Link', :url => 'http://www.example.org'
|
110
|
-
doc = Hpricot(cell.xml)
|
111
|
-
doc.at('text:a')['xlink:href'].should == 'http://www.example.org'
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should ignore the URL requested on anything other than a string" do
|
115
|
-
cell = ODF::Cell.new(47.1, :type => :float, :url => 'http://www.example.org')
|
116
|
-
cell.xml.should_not have_tag('text:p')
|
117
|
-
cell.xml.should_not have_tag('text:a')
|
118
|
-
|
119
|
-
cell = ODF::Cell.new(Date.parse('15 Apr 2010'), :type => :date, :url => 'http://www.example.org')
|
120
|
-
cell.xml.should_not have_tag('text:p')
|
121
|
-
cell.xml.should_not have_tag('text:a')
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should have the date set correctly" do
|
125
|
-
cell = Hpricot(ODF::Cell.new(Date.parse('15 Apr 2010'), :type => :date).xml).
|
126
|
-
at('table:table-cell')
|
127
|
-
cell['office:value-type'].should == 'date'
|
128
|
-
cell['office:date-value'].should == '2010-04-15'
|
129
|
-
cell['office:value'].should be_nil
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should also accept strings as date values" do
|
133
|
-
Hpricot(ODF::Cell.new(Date.parse('16 Apr 2010'), :type => :date).xml).
|
134
|
-
at('table:table-cell')['office:date-value'] = '2010-04-16'
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should contain paragraph" do
|
138
|
-
c = ODF::Cell.new
|
139
|
-
c.paragraph "testing"
|
140
|
-
output = c.xml
|
141
|
-
|
142
|
-
output.should have_tag("//table:table-cell/*", :count => 1)
|
143
|
-
output.should have_tag("//text:p")
|
144
|
-
|
145
|
-
Hpricot(output).at('text:p').innerHTML.should == 'testing'
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should be able to hold multiple paragraphs" do
|
149
|
-
output = ODF::Cell.create do |c|
|
150
|
-
c.paragraph "first"
|
151
|
-
c.paragraph "second"
|
152
|
-
end
|
153
|
-
|
154
|
-
output.should have_tag("//table:table-cell/*", :count => 2)
|
155
|
-
output.should have_tag("//text:p")
|
156
|
-
|
157
|
-
ps = Hpricot(output).search('text:p')
|
158
|
-
ps[0].innerHTML.should == 'first'
|
159
|
-
ps[1].innerHTML.should == 'second'
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should not render value type for non-string nil values" do
|
163
|
-
Hpricot(ODF::Cell.new(nil, :type => :string).xml).
|
164
|
-
at('table:table-cell').innerHTML.should == ''
|
165
|
-
|
166
|
-
[:float, :date].each do |t|
|
167
|
-
cell = Hpricot(ODF::Cell.new(nil, :type => t).xml).at('table:table-cell')
|
168
|
-
cell.innerHTML.should == ''
|
169
|
-
cell['office:value'].should be_nil
|
170
|
-
cell['office:date-value'].should be_nil
|
171
|
-
cell['office:value-type'].should be_nil
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should accept parameterless blocks" do
|
176
|
-
output = ODF::Cell.create do
|
177
|
-
paragraph "first"
|
178
|
-
paragraph "second"
|
179
|
-
end
|
180
|
-
|
181
|
-
output.should have_tag("//table:table-cell/*", :count => 2)
|
182
|
-
output.should have_tag("//text:p")
|
183
|
-
|
184
|
-
ps = Hpricot(output).search('text:p')
|
185
|
-
ps[0].innerHTML.should == 'first'
|
186
|
-
ps[1].innerHTML.should == 'second'
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
data/spec/data_style_spec.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
19
|
-
|
20
|
-
require 'odf/data_style'
|
21
|
-
|
22
|
-
describe ODF::DataStyle do
|
23
|
-
it "should have sections" do
|
24
|
-
output = ODF::DataStyle.create 'year-to-day', :date do |s|
|
25
|
-
s.section :year, :style => 'long'
|
26
|
-
s.section :month, :style => 'long'
|
27
|
-
s.section :day
|
28
|
-
end
|
29
|
-
|
30
|
-
output.should have_tag('number:date-style')
|
31
|
-
output.should have_tag('number:year')
|
32
|
-
output.should have_tag('number:month')
|
33
|
-
output.should have_tag('number:day')
|
34
|
-
|
35
|
-
Hpricot(output).at('number:date-style')['style:name'].should == 'year-to-day'
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should allow short section names" do
|
39
|
-
output = ODF::DataStyle.create 'year-to-day', :date do |number|
|
40
|
-
number.year :style => 'long'
|
41
|
-
number.month :style => 'long'
|
42
|
-
number.day
|
43
|
-
end
|
44
|
-
|
45
|
-
output.should have_tag('number:year')
|
46
|
-
output.should have_tag('number:month')
|
47
|
-
output.should have_tag('number:day')
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should accept parameterless blocks" do
|
51
|
-
output = ODF::DataStyle.create 'year-to-day', :date do
|
52
|
-
section :year, :style => 'long'
|
53
|
-
section :month, :style => 'long'
|
54
|
-
section :day
|
55
|
-
end
|
56
|
-
|
57
|
-
output.should have_tag('number:date-style')
|
58
|
-
output.should have_tag('number:year')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
data/spec/file_storage_spec.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
19
|
-
|
20
|
-
require 'odf/text'
|
21
|
-
require "tempfile"
|
22
|
-
|
23
|
-
describe "file storage" do
|
24
|
-
|
25
|
-
before do
|
26
|
-
@default_internal = Encoding.default_internal
|
27
|
-
@tempfilename = Tempfile.new("text").path
|
28
|
-
end
|
29
|
-
|
30
|
-
after do
|
31
|
-
Encoding.default_internal = @default_internal
|
32
|
-
File.unlink @tempfilename if File.exist? @tempfilename
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should store files on disk" do
|
36
|
-
ODF::Text.file(@tempfilename) {}
|
37
|
-
|
38
|
-
File.exist?(@tempfilename).should be true
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should work with Encoding.default_internal" do
|
42
|
-
Encoding.default_internal = "UTF-8"
|
43
|
-
|
44
|
-
ODF::Text.file(@tempfilename) {}
|
45
|
-
File.exist?(@tempfilename).should be true
|
46
|
-
end
|
47
|
-
end
|