rodf 0.3.6 → 0.3.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26bc83e35a41f6d2b90e6dbaa15465364223ef37
4
- data.tar.gz: 49bfa1ee2a941d2cac1e26b19ac9545bc7275060
3
+ metadata.gz: b6df39b5334145e202ec1e0994066867281ff199
4
+ data.tar.gz: b3aa43af22b6ff114d617ac829ca8b6f666e2d1d
5
5
  SHA512:
6
- metadata.gz: 5eb5f596ede184c968dfb948f3aa62c0001d0401a7144e9445bbfa0c1c23f709cf5f2d9a8da533161d07ad7f0e1629c348ce572bdc3dd6ec96bea1e5bc825c2b
7
- data.tar.gz: 3696a52edc521282ea76341b1288b0c226cd2bd1a78753494b61d06fca2dc12ce17a6a41e6199feb1fbe4c755f8722b0de8229e403997456f716f9586943db2d
6
+ metadata.gz: c2e0fea2bb28a9b6255f2944b250a1e2e013edffdcdba0fd9626146ec9f4ad53b8b7e000657cb2eea967f4ee0bf77875535236215cf12c00671e5bba03191504
7
+ data.tar.gz: d089d0a704c5339380b17827140a152ceff5c63dcdc9d00a4043e808f8b3c017cafd9fdba65f89325b43aaee2c13c95ae6d4d73c3249678b048622ca1ec3782c
data/CHANGELOG CHANGED
@@ -1,3 +1,4 @@
1
+ v0.3.7 Update dependencies for Rails 5
1
2
  v0.3.6. Resulting ODF files as bitstrings
2
3
  v0.3.5. Allows current libraries
3
4
  v0.3.4. Procedural cell styling
@@ -14,4 +15,3 @@ v0.1.3. Dependency fix (by Merul Patel)
14
15
  v0.1.2. Cell span
15
16
  v0.1.1. Basic spreadsheet styling support
16
17
  v0.1. First version with very basic support for spreadsheet generation
17
-
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'http://rubygems.org/'
2
2
 
3
3
  gem "builder", "~> 3.0"
4
4
  gem "rubyzip", "~> 1.0"
5
- gem "activesupport", ">= 3.0", "< 5.0"
5
+ gem "activesupport", ">= 3.0", "< 6.0"
6
6
  gem "hpricot", "~> 0.8.6"
7
7
  gem "rspec", "~> 2.9"
8
8
  gem "rspec_hpricot_matchers" , "~> 1.0"
data/Manifest CHANGED
@@ -2,7 +2,7 @@ CHANGELOG
2
2
  Gemfile
3
3
  LICENSE.LGPL
4
4
  Manifest
5
- README.rdoc
5
+ README.md
6
6
  Rakefile
7
7
  lib/odf/cell.rb
8
8
  lib/odf/column.rb
@@ -30,6 +30,7 @@ lib/odf/text.rb
30
30
  rodf.gemspec
31
31
  spec/cell_spec.rb
32
32
  spec/data_style_spec.rb
33
+ spec/file_storage_spec.rb
33
34
  spec/hyperlink_spec.rb
34
35
  spec/master_page_spec.rb
35
36
  spec/page_layout_spec.rb
@@ -0,0 +1,100 @@
1
+ # rODF
2
+
3
+ This is a library for writing to ODF output from Ruby. It currently only
4
+ supports creating spreadsheets (ODS) and text documents (ODT). Slide shows (ODP)
5
+ may be added some time in the future.
6
+
7
+ Some knowledge of the [ODF spec](http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html) is required.
8
+
9
+ This is NOT an ODF reading library.
10
+
11
+ ### Installation
12
+
13
+ You should be able to install the latest stable version by saying something like
14
+
15
+ gem install rodf
16
+
17
+ ### How do I use it?
18
+
19
+ rODF works pretty much like Builder, but with ODF-aware constructs. Try this:
20
+
21
+ require 'odf/spreadsheet'
22
+
23
+ ODF::Spreadsheet.file("my-spreadsheet.ods") do
24
+ table 'My first table from Ruby' do
25
+ row {cell 'Hello, rODF world!' }
26
+ end
27
+ end
28
+
29
+ Some basic formatting is also possible:
30
+
31
+ require 'odf/spreadsheet'
32
+
33
+ ODF::Spreadsheet.file("my-spreadsheet.ods") do
34
+ style 'red-cell', :family => :cell do
35
+ property :text, 'font-weight' => 'bold', 'color' => '#ff0000'
36
+ end
37
+ table 'Red text table' do
38
+ row {cell 'Red', :style => 'red-cell' }
39
+ end
40
+ end
41
+
42
+ Some basic conditional formatting is also possible:
43
+
44
+ require 'odf/spreadsheet'
45
+
46
+ ODF::Spreadsheet.file("my-spreadsheet.ods") do
47
+
48
+ office_style 'red-cell', :family => :cell do
49
+ property :text, 'font-weight' => 'bold', 'color' => '#ff0000'
50
+ end
51
+
52
+ office_style 'green-cell', :family => :cell do
53
+ property :text, 'font-weight' => 'bold', 'color' => '#00ff00'
54
+ end
55
+
56
+ # conditional formating must be defined as style and the value of
57
+ # apply-style-name must be an office_style
58
+ style 'cond1', :family => :cell do
59
+
60
+ property :conditional,
61
+ 'condition' => 'cell-content()<0',
62
+ 'apply-style-name' => 'red-cell'
63
+
64
+ property :conditional,
65
+ 'condition' => 'cell-content()>0',
66
+ 'apply-style-name' => 'green-cell'
67
+ end
68
+
69
+ table 'Red text table' do
70
+ row {cell 'Red force', :style => 'red-cell' }
71
+ row {cell '-4', :type => :float, :style => 'cond1' }
72
+ row {cell '0', :type => :float, :style => 'cond1' }
73
+ row {cell '5', :type => :float, :style => 'cond1' }
74
+ end
75
+ end
76
+
77
+ ### Procedural style
78
+
79
+ The declarative style shown above is just syntatic sugar. A more procedural
80
+ style can also be used. Like so:
81
+
82
+ require 'odf/spreadsheet'
83
+
84
+ ss = ODF::Spreadsheet.new
85
+ t = ss.table 'My first table from Ruby'
86
+ r = t.row
87
+ c = r.cell 'Hello, rODF world!'
88
+
89
+ ss.write_to 'my-spreadsheet.ods'
90
+
91
+ Both styles can be mixed and matched at will:
92
+
93
+ require 'odf/spreadsheet'
94
+
95
+ ss = ODF::Spreadsheet.new
96
+ ss.table 'My first table from Ruby' do
97
+ row { cell 'Hello, rODF world!' }
98
+ end
99
+
100
+ ss.write_to 'my-spreadsheet.ods'
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ task :test => :spec
7
7
 
8
8
  require 'echoe'
9
9
  Echoe.new('rodf') do |gem|
10
- gem.author = ["Thiago Arrais", "Foivos Zakkak"]
10
+ gem.author = ["Weston Ganger", "Thiago Arrais", "Foivos Zakkak"]
11
11
  gem.email = "thiago.arrais@gmail.com"
12
12
  gem.url = "http://github.com/thiagoarrais/rodf/tree"
13
13
  gem.summary = "ODF generation library for Ruby"
@@ -15,7 +15,7 @@ Echoe.new('rodf') do |gem|
15
15
  gem.runtime_dependencies = [
16
16
  ["builder", "~> 3.0"],
17
17
  ["rubyzip", "~> 1.0"],
18
- ["activesupport", ">= 3.0", "< 5.0"]]
18
+ ["activesupport", ">= 3.0", "< 6.0"]]
19
19
  gem.development_dependencies = [
20
20
  ["rspec", "~> 2.9"],
21
21
  ["rspec_hpricot_matchers" , "~> 1.0"],
@@ -16,7 +16,7 @@
16
16
  # along with rODF. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
  require 'rubygems'
19
- gem 'activesupport', '>= 3.0', '< 5.0'
19
+ gem 'activesupport', '>= 3.0', '< 6.0'
20
20
 
21
21
  require 'active_support/inflector'
22
22
 
@@ -33,7 +33,7 @@ module ODF
33
33
  end
34
34
 
35
35
  def write_to(ods_file_name)
36
- File.open(ods_file_name, 'w') { |f| f << self.bytes }
36
+ File.open(ods_file_name, 'wb') { |f| f << self.bytes }
37
37
  end
38
38
 
39
39
  def bytes
@@ -24,11 +24,58 @@ module ODF
24
24
  :text => 'text-properties',
25
25
  :column => 'table-column-properties',
26
26
  :row => 'table-row-properties',
27
+ :page_layout => 'page-layout-properties',
28
+ :header_footer => 'header-footer-properties',
29
+ :list_level => 'list-level-properties',
27
30
  :conditional => 'map'}
28
31
  TRANSLATED_SPECS = [:border_color, :border_style, :border_width]
29
- STYLE_ATTRIBUTES = ['column-width', 'rotation-angle', 'text-underline-type',
30
- 'tab-stop-distance', 'condition', 'apply-style-name',
31
- 'base-cell-address']
32
+
33
+ ATTRIBUTES_TO_NAMESPACES = [[
34
+ ['column-width', 'rotation-angle', 'text-underline-type', 'tab-stop-distance',
35
+ 'condition', 'apply-style-name', 'base-cell-address', 'row-height',
36
+ 'country-asian', 'country-complex', 'font-charset', 'font-charset-asian',
37
+ 'font-charset-complex', 'font-family-asian', 'font-family-complex', 'font-family-generic',
38
+ 'font-family-generic-asian', 'font-family-generic-complex', 'font-name', 'font-name-asian',
39
+ 'font-name-complex', 'font-pitch', 'font-pitch-asian', 'font-pitch-complex', 'font-relief',
40
+ 'font-size-asian', 'font-size-complex', 'font-size-rel', 'font-size-rel-asian',
41
+ 'font-size-rel-complex', 'font-style-asian', 'font-style-complex', 'font-style-name',
42
+ 'font-style-name-asian', 'font-style-name-complex', 'font-weight-asian', 'font-weight-complex',
43
+ 'language-asian', 'language-complex', 'letter-kerning', 'rfc-language-tag',
44
+ 'rfc-language-tag-asian', 'rfc-language-tag-complex', 'script-asian', 'script-complex',
45
+ 'script-type', 'text-blinking', 'text-combine', 'text-combine-end-char',
46
+ 'text-combine-start-char', 'text-emphasize', 'text-line-through-color',
47
+ 'text-line-through-mode', 'text-line-through-style', 'text-line-through-text',
48
+ 'text-line-through-text-style', 'text-line-through-type', 'text-line-through-width',
49
+ 'text-outline', 'text-overline-color', 'text-overline-mode', 'text-overline-style',
50
+ 'text-overline-type', 'text-overline-width', 'text-position', 'text-rotation-angle',
51
+ 'text-rotation-scale', 'text-scale', 'text-underline-color', 'text-underline-mode',
52
+ 'text-underline-style', 'text-underline-width', 'use-window-font-color',
53
+ 'border-line-width', 'border-line-width-bottom', 'border-line-width-left',
54
+ 'border-line-width-right', 'border-line-width-top', 'cell-protect', 'decimal-places',
55
+ 'diagonal-bl-tr', 'diagonal-bl-tr-widths', 'diagonal-tl-br', 'diagonal-tl-br-widths',
56
+ 'direction', 'glyph-orientation-vertical', 'print-content', 'repeat-content',
57
+ 'rotation-align', 'shadow', 'shrink-to-fit', 'text-align-source',
58
+ 'vertical-align', 'writing-mode', 'min-row-height', 'use-optimal-row-height',
59
+ 'rel-column-width', 'use-optimal-column-width', 'auto-text-indent', 'background-transparency',
60
+ 'font-independent-line-spacing', 'join-border', 'justify-single-word', 'line-break',
61
+ 'line-height-at-least', 'line-spacing', 'page-number', 'punctuation-wrap', 'register-true',
62
+ 'snap-to-layout-grid', 'text-autospace',
63
+ 'writing-mode-automatic',
64
+ 'first-page-number', 'footnote-max-height', 'layout-grid-base-height', 'layout-grid-base-width',
65
+ 'layout-grid-color', 'layout-grid-display', 'layout-grid-lines', 'layout-grid-mode',
66
+ 'layout-grid-print', 'layout-grid-ruby-below', 'layout-grid-ruby-height', 'layout-grid-snap-to',
67
+ 'layout-grid-standard-mode', 'num-format', 'num-letter-sync', 'num-prefix', 'num-suffix',
68
+ 'paper-tray-name', 'print', 'print-orientation', 'print-page-order',
69
+ 'register-truth-ref-style-name', 'scale-to', 'scale-to-pages', 'table-centering',
70
+ 'dynamic-spacing',
71
+ 'ruby-align', 'ruby-position',
72
+ 'editable', 'protect',
73
+ 'may-break-between-rows', 'rel-width', 'width',
74
+ 'vertical-pos', 'vertical-rel'], 'style'],
75
+ [['height', 'y'], 'svg'],
76
+ [['dont-balance-text-columns', 'list-level-position-and-space-mode', 'min-label-distance',
77
+ 'min-label-width', 'space-before'], 'text'],
78
+ [['align', 'border-model', 'display'], 'table']]
32
79
 
33
80
  def initialize(type, specs={})
34
81
  @name = 'style:' + (PROPERTY_NAMES[type] || "#{type}-properties")
@@ -37,11 +84,17 @@ module ODF
37
84
 
38
85
  def xml
39
86
  specs = @specs.inject({}) do |acc, kv|
40
- prefix = STYLE_ATTRIBUTES.include?(kv.first) ? 'style' : 'fo'
41
- acc.merge prefix + ':' + kv.first => kv.last
87
+ acc.merge Property.lookup_namespace_for(kv.first) + ':' + kv.first => kv.last
42
88
  end
43
89
  Builder::XmlMarkup.new.tag! @name, specs
44
90
  end
91
+
92
+ class << self
93
+ def lookup_namespace_for(property_name)
94
+ as = ATTRIBUTES_TO_NAMESPACES.select {|a| a[0].include? property_name}
95
+ as.empty? ? 'fo' : as[0][1]
96
+ end
97
+ end
45
98
  private
46
99
  def translate(specs)
47
100
  result = specs.clone
@@ -32,8 +32,8 @@ module ODF
32
32
  end
33
33
 
34
34
  alias create_row row
35
- def row(&contents)
36
- create_row(next_row) {instance_eval(&contents) if block_given?}
35
+ def row(options={}, &contents)
36
+ create_row(next_row, options) {instance_eval(&contents) if block_given?}
37
37
  end
38
38
 
39
39
  def xml
@@ -1,21 +1,22 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # stub: rodf 0.3.7 ruby lib
2
3
 
3
4
  Gem::Specification.new do |s|
4
5
  s.name = "rodf"
5
- s.version = "0.3.6"
6
+ s.version = "0.3.7"
6
7
 
7
8
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Thiago Arrais, Foivos Zakkak"]
9
- s.date = "2014-10-09"
9
+ s.require_paths = ["lib"]
10
+ s.authors = ["Weston Ganger, Thiago Arrais, Foivos Zakkak"]
11
+ s.date = "2016-08-30"
10
12
  s.description = "ODF generation library for Ruby"
11
13
  s.email = "thiago.arrais@gmail.com"
12
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE.LGPL", "README.rdoc", "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"]
13
- s.files = ["CHANGELOG", "Gemfile", "LICENSE.LGPL", "Manifest", "README.rdoc", "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/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"]
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"]
14
16
  s.homepage = "http://github.com/thiagoarrais/rodf/tree"
15
- s.rdoc_options = ["--line-numbers", "--title", "Rodf", "--main", "README.rdoc"]
16
- s.require_paths = ["lib"]
17
+ s.rdoc_options = ["--line-numbers", "--title", "Rodf", "--main", "README.md"]
17
18
  s.rubyforge_project = "rodf"
18
- s.rubygems_version = "2.0.3"
19
+ s.rubygems_version = "2.5.1"
19
20
  s.summary = "ODF generation library for Ruby"
20
21
 
21
22
  if s.respond_to? :specification_version then
@@ -24,14 +25,14 @@ Gem::Specification.new do |s|
24
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
26
  s.add_runtime_dependency(%q<builder>, ["~> 3.0"])
26
27
  s.add_runtime_dependency(%q<rubyzip>, ["~> 1.0"])
27
- s.add_runtime_dependency(%q<activesupport>, ["< 5.0", ">= 3.0"])
28
+ s.add_runtime_dependency(%q<activesupport>, ["< 6.0", ">= 3.0"])
28
29
  s.add_development_dependency(%q<rspec>, ["~> 2.9"])
29
30
  s.add_development_dependency(%q<rspec_hpricot_matchers>, ["~> 1.0"])
30
31
  s.add_development_dependency(%q<echoe>, ["~> 4.6"])
31
32
  else
32
33
  s.add_dependency(%q<builder>, ["~> 3.0"])
33
34
  s.add_dependency(%q<rubyzip>, ["~> 1.0"])
34
- s.add_dependency(%q<activesupport>, ["< 5.0", ">= 3.0"])
35
+ s.add_dependency(%q<activesupport>, ["< 6.0", ">= 3.0"])
35
36
  s.add_dependency(%q<rspec>, ["~> 2.9"])
36
37
  s.add_dependency(%q<rspec_hpricot_matchers>, ["~> 1.0"])
37
38
  s.add_dependency(%q<echoe>, ["~> 4.6"])
@@ -39,7 +40,7 @@ Gem::Specification.new do |s|
39
40
  else
40
41
  s.add_dependency(%q<builder>, ["~> 3.0"])
41
42
  s.add_dependency(%q<rubyzip>, ["~> 1.0"])
42
- s.add_dependency(%q<activesupport>, ["< 5.0", ">= 3.0"])
43
+ s.add_dependency(%q<activesupport>, ["< 6.0", ">= 3.0"])
43
44
  s.add_dependency(%q<rspec>, ["~> 2.9"])
44
45
  s.add_dependency(%q<rspec_hpricot_matchers>, ["~> 1.0"])
45
46
  s.add_dependency(%q<echoe>, ["~> 4.6"])
@@ -0,0 +1,47 @@
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
@@ -27,22 +27,32 @@ describe ODF::Property do
27
27
  elem['fo:font-weight'].should == 'bold'
28
28
  end
29
29
 
30
- it "should prefix column-width property with style namespace" do
31
- property = ODF::Property.new :column, 'column-width' => '2cm'
32
-
33
- property.xml.should have_tag('//style:table-column-properties')
34
-
35
- elem = Hpricot(property.xml).at('//style:table-column-properties')
36
- elem['style:column-width'].should == '2cm'
37
- end
38
-
39
- it "should prefix rotation-angle property with style namespace" do
40
- property = ODF::Property.new :cell, 'rotation-angle' => '-90'
41
-
42
- property.xml.should have_tag('//style:table-cell-properties')
43
-
44
- elem = Hpricot(property.xml).at('//style:table-cell-properties')
45
- elem['style:rotation-angle'].should == '-90'
30
+ it "should prefix style properties with looked up namespace" do
31
+ Hpricot(ODF::Property.new(:cell, 'rotation-angle' => '-90').xml).
32
+ at('//style:table-cell-properties')['style:rotation-angle'].should == '-90'
33
+ Hpricot(ODF::Property.new(:row, 'row-height' => '2cm').xml).
34
+ at('//style:table-row-properties')['style:row-height'].should == '2cm'
35
+ Hpricot(ODF::Property.new(:column, 'column-width' => '2cm').xml).
36
+ at('//style:table-column-properties')['style:column-width'].should == '2cm'
37
+ Hpricot(ODF::Property.new(:text, 'text-underline-type' => 'single').xml).
38
+ at('style:text-properties')['style:text-underline-type'].should == 'single'
39
+ Hpricot(ODF::Property.new(:paragraph, 'tab-stop-distance' => '0.4925in').xml).
40
+ at('style:paragraph-properties')['style:tab-stop-distance'].should == '0.4925in'
41
+ Hpricot(ODF::Property.new(:page_layout, 'border-line-width' => '2px').xml).
42
+ at('style:page-layout-properties')['style:border-line-width'].should == '2px'
43
+ Hpricot(ODF::Property.new(:header_footer, 'border-line-width' => '2px').xml).
44
+ at('style:header-footer-properties')['style:border-line-width'].should == '2px'
45
+ Hpricot(ODF::Property.new(:ruby, 'ruby-position' => 'above').xml).
46
+ at('style:ruby-properties')['style:ruby-position'].should == 'above'
47
+ Hpricot(ODF::Property.new(:section, 'editable' => true).xml).
48
+ at('style:section-properties')['style:editable'].should == 'true'
49
+ Hpricot(ODF::Property.new(:table, 'align' => 'left').xml).
50
+ at('style:table-properties')['table:align'].should == 'left'
51
+ Hpricot(ODF::Property.new(:list_level, 'space-before' => '2em').xml).
52
+ at('style:list-level-properties')['text:space-before'].should == '2em'
53
+ # style:graphic-properties
54
+ # style:chart-properties
55
+ # style:drawing-page-properties
46
56
  end
47
57
 
48
58
  it "should generate row properties tag" do
@@ -125,19 +135,136 @@ describe ODF::Property do
125
135
  elem['fo:border-left'].should == "0.1in solid #ffff00"
126
136
  end
127
137
 
128
- it "should prefix underline property with style namespace" do
129
- Hpricot(ODF::Property.new(:text, 'text-underline-type' => 'single').xml).
130
- at('style:text-properties')['style:text-underline-type'].should == 'single'
131
- end
132
-
133
138
  it "should support paragraph properties" do
134
139
  ODF::Property.new(:paragraph).xml.
135
140
  should have_tag('style:paragraph-properties')
136
141
  end
137
142
 
138
- it "should should prefix tab stop distance property with style namespace" do
139
- Hpricot(ODF::Property.new(:paragraph, 'tab-stop-distance' => '0.4925in').xml).
140
- at('style:paragraph-properties')['style:tab-stop-distance'].should == '0.4925in'
143
+ it "should know the namespace for style:text-properties style properties" do
144
+ #see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416402_253892949
145
+ ['country-asian', 'country-complex', 'font-charset', 'font-charset-asian',
146
+ 'font-charset-complex', 'font-family-asian', 'font-family-complex', 'font-family-generic',
147
+ 'font-family-generic-asian', 'font-family-generic-complex', 'font-name', 'font-name-asian',
148
+ 'font-name-complex', 'font-pitch', 'font-pitch-asian', 'font-pitch-complex', 'font-relief',
149
+ 'font-size-asian', 'font-size-complex', 'font-size-rel', 'font-size-rel-asian',
150
+ 'font-size-rel-complex', 'font-style-asian', 'font-style-complex', 'font-style-name',
151
+ 'font-style-name-asian', 'font-style-name-complex', 'font-weight-asian', 'font-weight-complex',
152
+ 'language-asian', 'language-complex', 'letter-kerning', 'rfc-language-tag',
153
+ 'rfc-language-tag-asian', 'rfc-language-tag-complex', 'script-asian', 'script-complex',
154
+ 'script-type', 'text-blinking', 'text-combine', 'text-combine-end-char',
155
+ 'text-combine-start-char', 'text-emphasize', 'text-line-through-color',
156
+ 'text-line-through-mode', 'text-line-through-style', 'text-line-through-text',
157
+ 'text-line-through-text-style', 'text-line-through-type', 'text-line-through-width',
158
+ 'text-outline', 'text-overline-color', 'text-overline-mode', 'text-overline-style',
159
+ 'text-overline-type', 'text-overline-width', 'text-position', 'text-rotation-angle',
160
+ 'text-rotation-scale', 'text-scale', 'text-underline-color', 'text-underline-mode',
161
+ 'text-underline-style', 'text-underline-type', 'text-underline-width', 'use-window-font-color'].
162
+ each do |prop|
163
+ ODF::Property.lookup_namespace_for(prop).should == 'style'
164
+ end
165
+ end
166
+
167
+ it "should know the namespace for style:table-cell-properties style properties" do
168
+ #see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416518_253892949
169
+ ['border-line-width', 'border-line-width-bottom', 'border-line-width-left',
170
+ 'border-line-width-right', 'border-line-width-top', 'cell-protect', 'decimal-places',
171
+ 'diagonal-bl-tr', 'diagonal-bl-tr-widths', 'diagonal-tl-br', 'diagonal-tl-br-widths',
172
+ 'direction', 'glyph-orientation-vertical', 'print-content', 'repeat-content',
173
+ 'rotation-align', 'rotation-angle', 'shadow', 'shrink-to-fit', 'text-align-source',
174
+ 'vertical-align', 'writing-mode'].
175
+ each do |prop|
176
+ ODF::Property.lookup_namespace_for(prop).should == 'style'
177
+ end
178
+ end
179
+
180
+ it "should know the namespace for style:table-cell-properties style properties" do
181
+ #see http://docs.oasis-open.org/office/v1.2/os/opendocument-v1.2-os-part1.html#__refheading__1416516_253892949
182
+ ['min-row-height', 'row-height', 'use-optimal-row-height'].each do |prop|
183
+ ODF::Property.lookup_namespace_for(prop).should == 'style'
184
+ end
185
+ end
186
+
187
+ it "should know the namespace for style:table-row-properties style properties" do
188
+ # see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416514_253892949
189
+ ['column-width', 'rel-column-width', 'use-optimal-column-width'].each do |prop|
190
+ ODF::Property.lookup_namespace_for(prop).should == 'style'
191
+ end
192
+ end
193
+
194
+ it "should know the namespace for style:paragraph-properties style properties" do
195
+ # see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416494_253892949
196
+ ['auto-text-indent', 'background-transparency', 'border-line-width', 'border-line-width-bottom',
197
+ 'border-line-width-left', 'border-line-width-right', 'border-line-width-top',
198
+ 'font-independent-line-spacing', 'join-border', 'justify-single-word', 'line-break',
199
+ 'line-height-at-least', 'line-spacing', 'page-number', 'punctuation-wrap', 'register-true',
200
+ 'shadow', 'snap-to-layout-grid', 'tab-stop-distance', 'text-autospace', 'vertical-align',
201
+ 'writing-mode', 'writing-mode-automatic'].
202
+ each do |prop|
203
+ ODF::Property.lookup_namespace_for(prop).should == 'style'
204
+ end
205
+ end
206
+
207
+ it "should know the namespace for style:page-layout-properties style properties" do
208
+ # see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416486_253892949
209
+ ['border-line-width', 'border-line-width-bottom', 'border-line-width-left', 'border-line-width-right',
210
+ 'border-line-width-top', 'first-page-number', 'footnote-max-height', 'layout-grid-base-height',
211
+ 'layout-grid-base-width', 'layout-grid-color', 'layout-grid-display', 'layout-grid-lines',
212
+ 'layout-grid-mode', 'layout-grid-print', 'layout-grid-ruby-below', 'layout-grid-ruby-height',
213
+ 'layout-grid-snap-to', 'layout-grid-standard-mode', 'num-format', 'num-letter-sync',
214
+ 'num-prefix', 'num-suffix', 'paper-tray-name', 'print', 'print-orientation', 'print-page-order',
215
+ 'register-truth-ref-style-name', 'scale-to', 'scale-to-pages', 'shadow', 'table-centering',
216
+ 'writing-mode'].
217
+ each do |prop|
218
+ ODF::Property.lookup_namespace_for(prop).should == 'style'
219
+ end
220
+ end
221
+
222
+ it "should know the namespace for style:header-footer-properties style and svg properties" do
223
+ # see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416492_253892949
224
+ ['border-line-width', 'border-line-width-bottom', 'border-line-width-left', 'border-line-width-right',
225
+ 'border-line-width-top', 'dynamic-spacing', 'shadow'].
226
+ each do |prop|
227
+ ODF::Property.lookup_namespace_for(prop).should == 'style'
228
+ end
229
+ ODF::Property.lookup_namespace_for('height').should == 'svg'
230
+ end
231
+
232
+ it "should know the namespace for style:ruby-properties style properties" do
233
+ # see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416502_253892949
234
+ ['ruby-align', 'ruby-position'].each do |prop|
235
+ ODF::Property.lookup_namespace_for(prop).should == 'style'
236
+ end
237
+ end
238
+
239
+ it "should know the namespace for style:section-properties style and text properties" do
240
+ # see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#element-style_section-properties
241
+ ['editable', 'protect', 'writing-mode'].each do |prop|
242
+ ODF::Property.lookup_namespace_for(prop).should == 'style'
243
+ end
244
+ ODF::Property.lookup_namespace_for('dont-balance-text-columns').should == 'text'
245
+ end
246
+
247
+ it "should know the namespace for style:table-properties style and table properties" do
248
+ # see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#element-style_table-properties
249
+ ['may-break-between-rows', 'page-number', 'rel-width', 'shadow', 'width', 'writing-mode'].
250
+ each do |prop|
251
+ ODF::Property.lookup_namespace_for(prop).should == 'style'
252
+ end
253
+ ['align', 'border-model', 'display'].each do |prop|
254
+ ODF::Property.lookup_namespace_for(prop).should == 'table'
255
+ end
256
+ end
257
+
258
+ it "should know the namespace for style:list-level-properties style, svg and text properties" do
259
+ ['font-name', 'vertical-pos', 'vertical-rel'].each do |prop|
260
+ ODF::Property.lookup_namespace_for(prop).should == 'style'
261
+ end
262
+ ODF::Property.lookup_namespace_for('y').should == 'svg'
263
+ ['list-level-position-and-space-mode', 'min-label-distance', 'min-label-width',
264
+ 'space-before'].
265
+ each do |prop|
266
+ ODF::Property.lookup_namespace_for(prop).should == 'text'
267
+ end
141
268
  end
142
269
  end
143
270
 
@@ -74,4 +74,17 @@ describe ODF::Table do
74
74
  output.should have_tag('//table:table-row')
75
75
  output.should have_tag('//table:table-cell')
76
76
  end
77
+
78
+ it "should have allow row styles" do
79
+ output = ODF::Table.create('MyTable') do
80
+ row style: :bold do
81
+ cell
82
+ end
83
+ row style: :underline do
84
+ cell
85
+ end
86
+ end
87
+ output.should include('table:table-row table:style-name="bold"')
88
+ output.should include('table:table-row table:style-name="underline"')
89
+ end
77
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
- - Thiago Arrais, Foivos Zakkak
7
+ - Weston Ganger, Thiago Arrais, Foivos Zakkak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-09 00:00:00.000000000 Z
11
+ date: 2016-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: '3.0'
48
48
  - - "<"
49
49
  - !ruby/object:Gem::Version
50
- version: '5.0'
50
+ version: '6.0'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: '3.0'
58
58
  - - "<"
59
59
  - !ruby/object:Gem::Version
60
- version: '5.0'
60
+ version: '6.0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -107,7 +107,7 @@ extensions: []
107
107
  extra_rdoc_files:
108
108
  - CHANGELOG
109
109
  - LICENSE.LGPL
110
- - README.rdoc
110
+ - README.md
111
111
  - lib/odf/cell.rb
112
112
  - lib/odf/column.rb
113
113
  - lib/odf/compatibility.rb
@@ -136,7 +136,7 @@ files:
136
136
  - Gemfile
137
137
  - LICENSE.LGPL
138
138
  - Manifest
139
- - README.rdoc
139
+ - README.md
140
140
  - Rakefile
141
141
  - lib/odf/cell.rb
142
142
  - lib/odf/column.rb
@@ -164,6 +164,7 @@ files:
164
164
  - rodf.gemspec
165
165
  - spec/cell_spec.rb
166
166
  - spec/data_style_spec.rb
167
+ - spec/file_storage_spec.rb
167
168
  - spec/hyperlink_spec.rb
168
169
  - spec/master_page_spec.rb
169
170
  - spec/page_layout_spec.rb
@@ -188,7 +189,7 @@ rdoc_options:
188
189
  - "--title"
189
190
  - Rodf
190
191
  - "--main"
191
- - README.rdoc
192
+ - README.md
192
193
  require_paths:
193
194
  - lib
194
195
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -203,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
204
  version: '1.2'
204
205
  requirements: []
205
206
  rubyforge_project: rodf
206
- rubygems_version: 2.0.3
207
+ rubygems_version: 2.5.1
207
208
  signing_key:
208
209
  specification_version: 4
209
210
  summary: ODF generation library for Ruby
@@ -1,98 +0,0 @@
1
- = rODF
2
-
3
- This is a library for writing to ODF output with Ruby. It currently only
4
- supports creating spreadsheets (ODS) and text documents (ODT). Slide shows (ODP)
5
- may be added some time in the future.
6
-
7
- This is NOT an ODF reading library.
8
-
9
- === Installation
10
-
11
- You should be able to install the latest stable version by saying something like
12
-
13
- sudo gem install rodf
14
-
15
- === How do I use it?
16
-
17
- rODF works pretty much like Builder, but with ODF-aware constructs. Try this:
18
-
19
- require 'odf/spreadsheet'
20
-
21
- ODF::Spreadsheet.file("my-spreadsheet.ods") do
22
- table 'My first table from Ruby' do
23
- row {cell 'Hello, rODF world!' }
24
- end
25
- end
26
-
27
- Some basic formatting is also possible:
28
-
29
- require 'odf/spreadsheet'
30
-
31
- ODF::Spreadsheet.file("my-spreadsheet.ods") do
32
- style 'red-cell', :family => :cell do
33
- property :text, 'font-weight' => 'bold', 'color' => '#ff0000'
34
- end
35
- table 'Red text table' do
36
- row {cell 'Red', :style => 'red-cell' }
37
- end
38
- end
39
-
40
- Some basic conditional formatting is also possible:
41
-
42
- require 'odf/spreadsheet'
43
-
44
- ODF::Spreadsheet.file("my-spreadsheet.ods") do
45
-
46
- office_style 'red-cell', :family => :cell do
47
- property :text, 'font-weight' => 'bold', 'color' => '#ff0000'
48
- end
49
-
50
- office_style 'green-cell', :family => :cell do
51
- property :text, 'font-weight' => 'bold', 'color' => '#00ff00'
52
- end
53
-
54
- # conditional formating must be defined as style and the value of
55
- # apply-style-name must be an office_style
56
- style 'cond1', :family => :cell do
57
-
58
- property :conditional,
59
- 'condition' => 'cell-content()<0',
60
- 'apply-style-name' => 'red-cell'
61
-
62
- property :conditional,
63
- 'condition' => 'cell-content()>0',
64
- 'apply-style-name' => 'green-cell'
65
- end
66
-
67
- table 'Red text table' do
68
- row {cell 'Red force', :style => 'red-cell' }
69
- row {cell '-4', :type => :float, :style => 'cond1' }
70
- row {cell '0', :type => :float, :style => 'cond1' }
71
- row {cell '5', :type => :float, :style => 'cond1' }
72
- end
73
- end
74
-
75
- ==== Procedural style
76
-
77
- The declarative style shown above is just syntatic sugar. A more procedural
78
- style can also be used. Like so:
79
-
80
- require 'odf/spreadsheet'
81
-
82
- ss = ODF::Spreadsheet.new
83
- t = ss.table 'My first table from Ruby'
84
- r = t.row
85
- c = r.cell 'Hello, rODF world!'
86
-
87
- ss.write_to 'my-spreadsheet.ods'
88
-
89
- Both styles can be mixed and matched at will:
90
-
91
- require 'odf/spreadsheet'
92
-
93
- ss = ODF::Spreadsheet.new
94
- ss.table 'My first table from Ruby' do
95
- row { cell 'Hello, rODF world!' }
96
- end
97
-
98
- ss.write_to 'my-spreadsheet.ods'