clbustos-rtf 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +5 -0
- data/README +6 -9
- data/Rakefile +4 -3
- data/VERSION.yml +2 -2
- data/lib/rtf/information.rb +2 -3
- data/lib/rtf/node.rb +31 -29
- metadata +28 -23
- data/.gitignore +0 -3
- data/ruby-rtf.gemspec +0 -29
data/CHANGES
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
== CHANGES
|
2
|
+
|
3
|
+
0.3.0
|
4
|
+
* Resolve problems on Ruby 1.9.1 with ImageNode#read_source. Peter uses IO#getc, which returns a String on Ruby 1.9.1, not a Integer, so I replaced with getbyte. [clbustos]
|
5
|
+
* Deleted duplicated definition of ImageNode#style= with attr_writer and def. [clbustos]
|
data/README
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
== Ruby Rich Text Format (RTF) Library
|
1
|
+
== Ruby Rich Text Format (RTF) Library
|
2
2
|
The RTF library provides a pure Ruby set of functionality that can be used to
|
3
3
|
programmatically create RTF documents. The main aim in developing this library
|
4
4
|
is to ease the complexity involved in assembling RTF documents although some
|
@@ -18,13 +18,6 @@ In creating this library I set out to make it reasonably easy to create RTF
|
|
18
18
|
documents in code. Having said that I'm certain that it is possible to generate
|
19
19
|
invalid RTF documents with this library.
|
20
20
|
|
21
|
-
=== This version
|
22
|
-
|
23
|
-
A bug fix fork of thechrisoshow/rtf[http://github.com/thechrisoshow/rtf] , which is a gitified version of original ruby-rft[http://rubyforge.org/projects/ruby-rtf/]
|
24
|
-
|
25
|
-
* Resolve problems on Ruby 1.9.1 with ImageNode#read_source. Peter uses IO#getc, which returns a String on Ruby 1.9.1, not a Integer, so I replaced with getbyte.
|
26
|
-
* Deleted duplicated definition of ImageNode#style= with attr_writer and def.
|
27
|
-
|
28
21
|
=== Known Issues
|
29
22
|
I've tried to assemble a reasonably extensive (although I won't claim
|
30
23
|
exhaustive) unit test for the library. Despite that, this is an early release of
|
@@ -183,7 +176,11 @@ is installed with the library gem (if you're reading this you may already be
|
|
183
176
|
looking at this documentation). Another source of information is the examples
|
184
177
|
directory, so check that out too.
|
185
178
|
|
179
|
+
CONTRIBUTORS
|
180
|
+
Claudio Bustos
|
181
|
+
Chris O'Sullivan
|
182
|
+
|
186
183
|
COPYRIGHT
|
187
184
|
=========
|
188
185
|
|
189
|
-
Copyright (c) 2009 Peter Wood. See LICENSE for details.
|
186
|
+
Copyright (c) 2009-2010 Peter Wood. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -11,10 +11,11 @@ begin
|
|
11
11
|
s.description = 'Ruby RTF is a library that can be used to create '\
|
12
12
|
'rich text format (RTF) documents. RTF is a text '\
|
13
13
|
'based standard for laying out document content.'
|
14
|
-
s.authors = ["Peter Wood"
|
14
|
+
s.authors = ["Peter Wood"]
|
15
|
+
s.files = FileList["[A-Z]*", "{examples,lib,test}/**/*"]
|
15
16
|
end
|
16
17
|
rescue LoadError
|
17
|
-
puts "Jeweler not available. Install it with: sudo gem install
|
18
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
18
19
|
end
|
19
20
|
|
20
21
|
require 'rake/rdoctask'
|
@@ -22,7 +23,7 @@ Rake::RDocTask.new do |rdoc|
|
|
22
23
|
rdoc.rdoc_dir = 'rdoc'
|
23
24
|
rdoc.title = 'ruby-rtf'
|
24
25
|
rdoc.options << '--line-numbers' << '--inline-source'
|
25
|
-
rdoc.rdoc_files.include('
|
26
|
+
rdoc.rdoc_files.include('[A-Z]*')
|
26
27
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
28
|
end
|
28
29
|
|
data/VERSION.yml
CHANGED
data/lib/rtf/information.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'stringio'
|
4
|
-
require '
|
5
|
-
|
4
|
+
require 'date'
|
6
5
|
module RTF
|
7
6
|
# This class represents an information group for a RTF document.
|
8
7
|
class Information
|
@@ -56,7 +55,7 @@ module RTF
|
|
56
55
|
if setting.instance_of?(Time)
|
57
56
|
@created = setting
|
58
57
|
else
|
59
|
-
|
58
|
+
datetime = Date._parse(setting.to_s).values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday)
|
60
59
|
if datetime == nil
|
61
60
|
RTFError.fire("Invalid document creation date/time information "\
|
62
61
|
"specified.")
|
data/lib/rtf/node.rb
CHANGED
@@ -63,11 +63,8 @@ module RTF
|
|
63
63
|
# This class represents a specialisation of the Node class to refer to a Node
|
64
64
|
# that simply contains text.
|
65
65
|
class TextNode < Node
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
# Attribute mutator.
|
70
|
-
attr_writer :text
|
66
|
+
# Actual text
|
67
|
+
attr_accessor :text
|
71
68
|
|
72
69
|
# This is the constructor for the TextNode class.
|
73
70
|
#
|
@@ -131,11 +128,8 @@ module RTF
|
|
131
128
|
class ContainerNode < Node
|
132
129
|
include Enumerable
|
133
130
|
|
134
|
-
#
|
135
|
-
|
136
|
-
|
137
|
-
# Attribute mutator.
|
138
|
-
attr_writer :children
|
131
|
+
# Children elements of the node
|
132
|
+
attr_accessor :children
|
139
133
|
|
140
134
|
# This is the constructor for the ContainerNode class.
|
141
135
|
#
|
@@ -208,11 +202,14 @@ module RTF
|
|
208
202
|
# is concrete enough to be used on its own but will also be used as the
|
209
203
|
# base class for some specific command node types.
|
210
204
|
class CommandNode < ContainerNode
|
211
|
-
#
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
205
|
+
# String containing the prefix text for the command
|
206
|
+
attr_accessor :prefix
|
207
|
+
# String containing the suffix text for the command
|
208
|
+
attr_accessor :suffix
|
209
|
+
# A boolean to indicate whether the prefix and suffix should
|
210
|
+
# be written to separate lines whether the node is converted
|
211
|
+
# to RTF. Defaults to true
|
212
|
+
attr_accessor :split
|
216
213
|
|
217
214
|
# This is the constructor for the CommandNode class.
|
218
215
|
#
|
@@ -522,12 +519,9 @@ module RTF
|
|
522
519
|
# specialised container nodes that contain only TableRowNodes and have their
|
523
520
|
# size specified when they are created an cannot be resized after that.
|
524
521
|
class TableNode < ContainerNode
|
525
|
-
#
|
526
|
-
|
527
|
-
|
528
|
-
# Attribute mutator.
|
529
|
-
attr_writer :cell_margin
|
530
|
-
|
522
|
+
# Cell margin. Default to 100
|
523
|
+
attr_accessor :cell_margin
|
524
|
+
|
531
525
|
# This is a constructor for the TableNode class.
|
532
526
|
#
|
533
527
|
# ==== Parameters
|
@@ -536,12 +530,22 @@ module RTF
|
|
536
530
|
# columns:: The number of columns in the table.
|
537
531
|
# *widths:: One or more integers specifying the widths of the table
|
538
532
|
# columns.
|
539
|
-
def initialize(parent,
|
533
|
+
def initialize(parent, *args, &block)
|
534
|
+
if args.size>=2
|
535
|
+
rows=args.shift
|
536
|
+
columns=args.shift
|
537
|
+
widths=args
|
540
538
|
super(parent) do
|
541
539
|
entries = []
|
542
540
|
rows.times {entries.push(TableRowNode.new(self, columns, *widths))}
|
543
541
|
entries
|
544
542
|
end
|
543
|
+
|
544
|
+
elsif block
|
545
|
+
block.arity<1 ? self.instance_eval(&block) : block.call(self)
|
546
|
+
else
|
547
|
+
raise "You should use 0 or >2 args"
|
548
|
+
end
|
545
549
|
@cell_margin = 100
|
546
550
|
end
|
547
551
|
|
@@ -669,7 +673,7 @@ module RTF
|
|
669
673
|
end
|
670
674
|
end
|
671
675
|
|
672
|
-
#
|
676
|
+
# Attribute accessors
|
673
677
|
def length
|
674
678
|
entries.size
|
675
679
|
end
|
@@ -745,13 +749,11 @@ module RTF
|
|
745
749
|
class TableCellNode < CommandNode
|
746
750
|
# A definition for the default width for the cell.
|
747
751
|
DEFAULT_WIDTH = 300
|
748
|
-
|
752
|
+
# Width of cell
|
753
|
+
attr_accessor :width
|
749
754
|
# Attribute accessor.
|
750
|
-
attr_reader :
|
751
|
-
|
752
|
-
# Attribute mutator.
|
753
|
-
attr_writer :width
|
754
|
-
|
755
|
+
attr_reader :shading_colour, :style
|
756
|
+
|
755
757
|
# This is the constructor for the TableCellNode class.
|
756
758
|
#
|
757
759
|
# ==== Parameters
|
metadata
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clbustos-rtf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Peter Wood
|
8
|
-
- Claudio Bustos
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
16
|
|
13
|
-
date: 2010-03
|
17
|
+
date: 2010-05-03 00:00:00 -04:00
|
14
18
|
default_executable:
|
15
19
|
dependencies: []
|
16
20
|
|
@@ -24,7 +28,7 @@ extra_rdoc_files:
|
|
24
28
|
- LICENSE
|
25
29
|
- README
|
26
30
|
files:
|
27
|
-
-
|
31
|
+
- CHANGES
|
28
32
|
- LICENSE
|
29
33
|
- README
|
30
34
|
- Rakefile
|
@@ -44,7 +48,6 @@ files:
|
|
44
48
|
- lib/rtf/node.rb
|
45
49
|
- lib/rtf/paper.rb
|
46
50
|
- lib/rtf/style.rb
|
47
|
-
- ruby-rtf.gemspec
|
48
51
|
- test/character_style_test.rb
|
49
52
|
- test/colour_table_test.rb
|
50
53
|
- test/colour_test.rb
|
@@ -85,44 +88,46 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
88
|
requirements:
|
86
89
|
- - ">="
|
87
90
|
- !ruby/object:Gem::Version
|
91
|
+
segments:
|
92
|
+
- 0
|
88
93
|
version: "0"
|
89
|
-
version:
|
90
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
95
|
requirements:
|
92
96
|
- - ">="
|
93
97
|
- !ruby/object:Gem::Version
|
98
|
+
segments:
|
99
|
+
- 0
|
94
100
|
version: "0"
|
95
|
-
version:
|
96
101
|
requirements: []
|
97
102
|
|
98
103
|
rubyforge_project: ruby-statsample
|
99
|
-
rubygems_version: 1.3.
|
104
|
+
rubygems_version: 1.3.6
|
100
105
|
signing_key:
|
101
106
|
specification_version: 3
|
102
107
|
summary: Ruby library to create rich text format documents.
|
103
108
|
test_files:
|
104
|
-
- test/
|
105
|
-
- test/
|
106
|
-
- test/container_node_test.rb
|
107
|
-
- test/table_cell_node_test.rb
|
108
|
-
- test/character_style_test.rb
|
109
|
+
- test/table_row_node_test.rb
|
110
|
+
- test/font_table_test.rb
|
109
111
|
- test/paragraph_style_test.rb
|
112
|
+
- test/document_style_test.rb
|
110
113
|
- test/font_test.rb
|
114
|
+
- test/header_node_test.rb
|
115
|
+
- test/node_test.rb
|
116
|
+
- test/colour_table_test.rb
|
117
|
+
- test/test_helper.rb
|
111
118
|
- test/document_test.rb
|
119
|
+
- test/footer_node_test.rb
|
120
|
+
- test/command_node_test.rb
|
112
121
|
- test/style_test.rb
|
113
|
-
- test/
|
122
|
+
- test/character_style_test.rb
|
114
123
|
- test/text_node_test.rb
|
115
|
-
- test/table_node_test.rb
|
116
|
-
- test/colour_table_test.rb
|
117
124
|
- test/image_node_test.rb
|
118
|
-
- test/document_style_test.rb
|
119
|
-
- test/test_helper.rb
|
120
|
-
- test/footer_node_test.rb
|
121
|
-
- test/table_row_node_test.rb
|
122
125
|
- test/colour_test.rb
|
123
|
-
- test/
|
124
|
-
- test/
|
125
|
-
-
|
126
|
+
- test/container_node_test.rb
|
127
|
+
- test/information_test.rb
|
128
|
+
- test/table_node_test.rb
|
129
|
+
- test/table_cell_node_test.rb
|
126
130
|
- examples/example02.rb
|
131
|
+
- examples/example01.rb
|
127
132
|
- examples/example03.rb
|
128
133
|
- examples/example04.rb
|
data/.gitignore
DELETED
data/ruby-rtf.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{ruby-rtf}
|
5
|
-
s.version = "0.2.0"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Peter Wood"]
|
9
|
-
s.date = %q{2009-02-23}
|
10
|
-
s.description = %q{Ruby RTF is a library that can be used to create rich text format (RTF) documents. RTF is a text based standard for laying out document content.}
|
11
|
-
s.email = %q{paw220470@yahoo.ie}
|
12
|
-
s.files = ["VERSION.yml", "lib/rtf", "lib/rtf/colour.rb", "lib/rtf/font.rb", "lib/rtf/information.rb", "lib/rtf/node.rb", "lib/rtf/paper.rb", "lib/rtf/style.rb", "lib/rtf.rb", "test/character_style_test.rb", "test/colour_table_test.rb", "test/colour_test.rb", "test/command_node_test.rb", "test/container_node_test.rb", "test/document_style_test.rb", "test/document_test.rb", "test/fixtures", "test/fixtures/bitmap1.bmp", "test/fixtures/bitmap2.bmp", "test/fixtures/jpeg1.jpg", "test/fixtures/jpeg2.jpg", "test/fixtures/png1.png", "test/fixtures/png2.png", "test/font_table_test.rb", "test/font_test.rb", "test/footer_node_test.rb", "test/header_node_test.rb", "test/image_node_test.rb", "test/information_test.rb", "test/node_test.rb", "test/paragraph_style_test.rb", "test/style_test.rb", "test/table_cell_node_test.rb", "test/table_node_test.rb", "test/table_row_node_test.rb", "test/test_helper.rb", "test/text_node_test.rb"]
|
13
|
-
s.has_rdoc = true
|
14
|
-
s.homepage = %q{http://github.com/thechrisoshow/ruby-rtf}
|
15
|
-
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
|
16
|
-
s.require_paths = ["lib"]
|
17
|
-
s.rubygems_version = %q{1.3.1}
|
18
|
-
s.summary = %q{Ruby library to create rich text format documents.}
|
19
|
-
|
20
|
-
if s.respond_to? :specification_version then
|
21
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
22
|
-
s.specification_version = 2
|
23
|
-
|
24
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
25
|
-
else
|
26
|
-
end
|
27
|
-
else
|
28
|
-
end
|
29
|
-
end
|