rtf 0.1.0 → 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/LICENSE +20 -0
- data/{doc/README → README.rdoc} +10 -2
- data/Rakefile +47 -0
- data/VERSION.yml +5 -0
- data/examples/example01.rb +0 -0
- data/examples/example02.rb +0 -0
- data/examples/example03.rb +4 -4
- data/examples/example03.rtf +0 -0
- data/examples/example04.rb +50 -0
- data/examples/rubyrtf.bmp +0 -0
- data/examples/rubyrtf.jpg +0 -0
- data/examples/rubyrtf.png +0 -0
- data/lib/rtf.rb +0 -0
- data/lib/rtf/colour.rb +0 -0
- data/lib/rtf/font.rb +0 -0
- data/lib/rtf/information.rb +2 -3
- data/lib/rtf/node.rb +294 -29
- data/lib/rtf/paper.rb +0 -0
- data/lib/rtf/style.rb +0 -0
- data/test/{CharacterStyleTest.rb → character_style_test.rb} +1 -7
- data/test/{ColourTableTest.rb → colour_table_test.rb} +92 -97
- data/test/{ColourTest.rb → colour_test.rb} +116 -122
- data/test/{CommandNodeTest.rb → command_node_test.rb} +1 -7
- data/test/{ContainerNodeTest.rb → container_node_test.rb} +3 -9
- data/test/{DocumentStyleTest.rb → document_style_test.rb} +1 -7
- data/test/{DocumentTest.rb → document_test.rb} +1 -7
- data/test/fixtures/bitmap1.bmp +0 -0
- data/test/fixtures/bitmap2.bmp +0 -0
- data/test/fixtures/jpeg1.jpg +0 -0
- data/test/fixtures/jpeg2.jpg +0 -0
- data/test/fixtures/png1.png +0 -0
- data/test/fixtures/png2.png +0 -0
- data/test/{FontTableTest.rb → font_table_test.rb} +1 -6
- data/test/{FontTest.rb → font_test.rb} +1 -6
- data/test/{FooterNodeTest.rb → footer_node_test.rb} +1 -7
- data/test/{HeaderNodeTest.rb → header_node_test.rb} +1 -7
- data/test/image_node_test.rb +125 -0
- data/test/{InformationTest.rb → information_test.rb} +1 -7
- data/test/{NodeTest.rb → node_test.rb} +4 -10
- data/test/{ParagraphStyleTest.rb → paragraph_style_test.rb} +1 -7
- data/test/{StyleTest.rb → style_test.rb} +1 -7
- data/test/{TableCellNodeTest.rb → table_cell_node_test.rb} +1 -7
- data/test/{TableNodeTest.rb → table_node_test.rb} +1 -7
- data/test/{TableRowNodeTest.rb → table_row_node_test.rb} +1 -7
- data/test/test_helper.rb +13 -0
- data/test/{TextNodeTest.rb → text_node_test.rb} +4 -10
- metadata +119 -70
- data/doc/makedoc.bat +0 -2
- data/test/run.bat +0 -2
- data/test/unittest.bat +0 -2
- data/test/unittest.rb +0 -21
@@ -1,12 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require 'rtf'
|
6
|
-
|
7
|
-
include RTF
|
8
|
-
|
9
|
-
# Information class unit test class.
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# Information class unit test class.
|
10
4
|
class ContainerNodeTest < Test::Unit::TestCase
|
11
5
|
def test01
|
12
6
|
nodes = []
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,125 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)+"/../lib")
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
# Colour class unit test class.
|
6
|
+
class ImageNodeTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@document = Document.new(Font.new(Font::ROMAN, 'Arial'))
|
9
|
+
end
|
10
|
+
def test_basics
|
11
|
+
image = ImageNode.new(@document, fixture_file_path("bitmap1.bmp"), 1)
|
12
|
+
|
13
|
+
assert(image.width == 20)
|
14
|
+
assert(image.height == 20)
|
15
|
+
assert(image.x_scaling == nil)
|
16
|
+
assert(image.y_scaling == nil)
|
17
|
+
assert(image.top_crop == nil)
|
18
|
+
assert(image.right_crop == nil)
|
19
|
+
assert(image.left_crop == nil)
|
20
|
+
assert(image.bottom_crop == nil)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_mutators
|
24
|
+
image = ImageNode.new(@document, fixture_file_path("jpeg2.jpg"), 1)
|
25
|
+
|
26
|
+
image.x_scaling = 75
|
27
|
+
assert(image.x_scaling == 75)
|
28
|
+
|
29
|
+
image.y_scaling = 60
|
30
|
+
assert(image.y_scaling == 60)
|
31
|
+
|
32
|
+
image.top_crop = 100
|
33
|
+
assert(image.top_crop == 100)
|
34
|
+
|
35
|
+
image.bottom_crop = 10
|
36
|
+
assert(image.bottom_crop == 10)
|
37
|
+
|
38
|
+
image.right_crop = 35
|
39
|
+
assert(image.right_crop == 35)
|
40
|
+
|
41
|
+
image.left_crop = 50
|
42
|
+
assert(image.left_crop == 50)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_image_reading
|
46
|
+
images = []
|
47
|
+
images << ImageNode.new(@document, fixture_file_path('bitmap1.bmp'), 1)
|
48
|
+
images << ImageNode.new(@document, fixture_file_path('bitmap2.bmp'), 2)
|
49
|
+
images << ImageNode.new(@document, fixture_file_path('jpeg1.jpg'), 3)
|
50
|
+
images << ImageNode.new(@document, fixture_file_path('jpeg2.jpg'), 4)
|
51
|
+
images << ImageNode.new(@document, fixture_file_path('png1.png'), 5)
|
52
|
+
images << ImageNode.new(@document, fixture_file_path('png2.png'), 6)
|
53
|
+
|
54
|
+
assert(images[0].width == 20)
|
55
|
+
assert(images[0].height == 20)
|
56
|
+
assert(images[1].width == 123)
|
57
|
+
assert(images[1].height == 456)
|
58
|
+
assert(images[2].width == 20)
|
59
|
+
assert(images[2].height == 20)
|
60
|
+
assert(images[3].width == 123)
|
61
|
+
assert(images[3].height == 456)
|
62
|
+
assert(images[4].width == 20)
|
63
|
+
assert(images[4].height == 20)
|
64
|
+
assert(images[5].width == 123)
|
65
|
+
assert(images[5].height == 456)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_rtf
|
69
|
+
image = ImageNode.new(@document, fixture_file_path('png1.png'), 1)
|
70
|
+
image.x_scaling = 100
|
71
|
+
image.y_scaling = 75
|
72
|
+
image.top_crop = 10
|
73
|
+
image.right_crop = 15
|
74
|
+
image.left_crop = 20
|
75
|
+
image.bottom_crop = 25
|
76
|
+
rtf = image.to_rtf
|
77
|
+
|
78
|
+
assert(rtf == "{\\*\\shppict{\\pict\\picscalex100\\picscaley75"\
|
79
|
+
"\\piccropl20\\piccropr15\\piccropt10\\piccropb25"\
|
80
|
+
"\\picw20\\pich20\\bliptag1\\pngblip\n"\
|
81
|
+
"89504e470d0a1a0a0000000d494844520000001400000014080200000002eb8a5a00000001735247\n"\
|
82
|
+
"4200aece1ce90000000467414d410000b18f0bfc6105000000206348524d00007a26000080840000\n"\
|
83
|
+
"fa00000080e8000075300000ea6000003a98000017709cba513c000003dd49444154384f1d545b6c\n"\
|
84
|
+
"145518fee6cccccecc9e99d9b9ed76bbb3bdd8ae5b8144144413a335f141259228d60096b485aa2d\n"\
|
85
|
+
"b4686b634bb65b6d682244e2050d46239af0c88b181ff1c507f4411ec4447cf1f2808118d05ab1ed\n"\
|
86
|
+
"de778fff6cf2e73c9c33dfff7ddf7f1929052d015945890326d002cac0bfc05f30d624066b131d40\n"\
|
87
|
+
"0d5001016c020c68b6cf75e06ed84ff87d7b79728c1b33091c8d63c2c55ecf7a30c8596640c8f040\n"\
|
88
|
+
"3639ae741c55bba6b29de3e196d9befccb3db9e7b62104fa81a7adf428f75fe3c6b289a282e31ce3\n"\
|
89
|
+
"26df9dec330058c81fe9cdbde12697625e31482e66320b7eefab99ae17fa23455b81e74d678a270a\n"\
|
90
|
+
"aa7a1258014e4838c6947d5e97476013fd93416659958a40015864da02320b6e7632871e60277028\n"\
|
91
|
+
"61cf73bec2f01ef02ef03e50843c12f7badacc7d93b6bb0cbc05bcd38e37915ae1e1dc5dd802ec00\n"\
|
92
|
+
"46e2ca5c4c59024eb7c11f004b908765a397c01c3d633a9f6f4ba2378a027801d6a4037abe0f1875\n"\
|
93
|
+
"b5195b2fc878bbfd7a46370b317ec8f1a91cc4bc75bca383ca40b9c9d52938a7957025917925c400\n"\
|
94
|
+
"22f2215f7bd1d1a734b6a0c845595d34ac71591bf2dd148135dc3b92cfcde5f9acc716b856b4adb9\n"\
|
95
|
+
"78ea989b1e0b9103b2c0431c53db070e06f6b0a11f3613cf4aca81747a30e92608ac62d7fec7761c\n"\
|
96
|
+
"792a37f948f7f4aed4c4b67b6676660fe6b3cfe423e480a307887a461628d7fd6484b14ec0a6cbb4\n"\
|
97
|
+
"2fdb1e540f5a082384e923dd09c782a521134067a40bbdc98403108fdb0eea105d1a860446639585\n"\
|
98
|
+
"fa30f87e48fb802781c781c1a845d676a0138c29376ffc214445b42aa2d114cda668d51aa2561135\n"\
|
99
|
+
"2de882fe2877a675ed148f7d1206e77de723db3b13b70be9cc4bc003514d1a42b444fdd6ed1bf57a\n"\
|
100
|
+
"bd5a2764bd2a6a655107f381dd9a7e52c197b6fa43dafa09f8dae1df6bea05df3901ec895ab95eaa\n"\
|
101
|
+
"374493f0ad288b20dadbfffd1981e37d504754f59cc37f8db355e0baa5adc9b8095cb6ad8f81c330\n"\
|
102
|
+
"787abdd41482a25ebab3592b95230ba2541595762b860d7ed1f3fe614a15f85bb785ac3520ffe206\n"\
|
103
|
+
"5f01af13b341b2095cad6c44199aa2bcb146f896a0c5eb267090ba045ca56d8c99b493ab904ac0b5\n"\
|
104
|
+
"b87911381e6d2669aed43784a891e8f266ad49262217f469379346659c95f06d60ae1bb15585dd22\n"\
|
105
|
+
"d95cfbd1887d0eccc34870aa504b54ee6cac6e6e545b44de765eae34a8d30c4361f25cc6bb6280aa\n"\
|
106
|
+
"754595aec5d59f5d7ed9323e04a6c162ea6fd77f6f891a152c025150cd5af54aaddc19d2e0535767\n"\
|
107
|
+
"2dfd8b98f48d19ff2e99bcca70c9d02ee81acdfa3020a1bbbf87ce28a0ea9a153991e0fa3463343b\n"\
|
108
|
+
"830a9b05ce029fb5e3538004d3ee4ed04fe47f31ae584cdee40aed0000000049454e44ae426082"\
|
109
|
+
"\n}}")
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_exceptions
|
113
|
+
begin
|
114
|
+
ImageNode.new(@document, 'lalala', 1)
|
115
|
+
flunk("Created an ImageNode for a non-existent file.")
|
116
|
+
rescue
|
117
|
+
end
|
118
|
+
|
119
|
+
begin
|
120
|
+
ImageNode.new(@document, 'ImageNodeTest.rb', 1)
|
121
|
+
flunk("Created an ImageNode from an unsupported file format.")
|
122
|
+
rescue
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -1,12 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require 'rtf'
|
6
|
-
|
7
|
-
include RTF
|
8
|
-
|
9
|
-
# Information class unit test class.
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# Information class unit test class.
|
10
4
|
class NodeTest < Test::Unit::TestCase
|
11
5
|
def test01
|
12
6
|
nodes = []
|
@@ -27,5 +21,5 @@ class NodeTest < Test::Unit::TestCase
|
|
27
21
|
assert(nodes[0].next_node == nil)
|
28
22
|
assert(nodes[1].previous_node == nil)
|
29
23
|
assert(nodes[1].next_node == nil)
|
30
|
-
end
|
24
|
+
end
|
31
25
|
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
|
+
require 'rtf'
|
6
|
+
include RTF
|
7
|
+
|
8
|
+
class Test::Unit::TestCase
|
9
|
+
|
10
|
+
def fixture_file_path(filename)
|
11
|
+
File.join(File.dirname(__FILE__), "fixtures", filename)
|
12
|
+
end
|
13
|
+
end
|
@@ -1,12 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require 'rtf'
|
6
|
-
|
7
|
-
include RTF
|
8
|
-
|
9
|
-
# Information class unit test class.
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# Information class unit test class.
|
10
4
|
class TextNodeTest < Test::Unit::TestCase
|
11
5
|
def setup
|
12
6
|
@node = Node.new(nil)
|
@@ -52,5 +46,5 @@ class TextNodeTest < Test::Unit::TestCase
|
|
52
46
|
flunk('Successfully created a TextNode with a nil parent.')
|
53
47
|
rescue => error
|
54
48
|
end
|
55
|
-
end
|
49
|
+
end
|
56
50
|
end
|
metadata
CHANGED
@@ -1,78 +1,127 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.11
|
3
|
-
specification_version: 1
|
4
2
|
name: rtf
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
|
7
|
-
|
8
|
-
summary: Ruby library to create rich text format documents.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: paw220470@yahoo.ie
|
12
|
-
homepage: http://rubyforge.org/projects/rtf/
|
13
|
-
rubyforge_project:
|
14
|
-
description: 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.
|
15
|
-
autorequire: rtf
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
-
|
22
|
-
- ">"
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 0.0.0
|
25
|
-
version:
|
4
|
+
prerelease:
|
5
|
+
version: 0.3.0
|
26
6
|
platform: ruby
|
27
|
-
signing_key:
|
28
|
-
cert_chain:
|
29
7
|
authors:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
- test/ColourTableTest.rb
|
42
|
-
- test/ColourTest.rb
|
43
|
-
- test/CommandNodeTest.rb
|
44
|
-
- test/ContainerNodeTest.rb
|
45
|
-
- test/DocumentStyleTest.rb
|
46
|
-
- test/DocumentTest.rb
|
47
|
-
- test/FontTableTest.rb
|
48
|
-
- test/FontTest.rb
|
49
|
-
- test/FooterNodeTest.rb
|
50
|
-
- test/HeaderNodeTest.rb
|
51
|
-
- test/InformationTest.rb
|
52
|
-
- test/NodeTest.rb
|
53
|
-
- test/ParagraphStyleTest.rb
|
54
|
-
- test/run.bat
|
55
|
-
- test/StyleTest.rb
|
56
|
-
- test/TableCellNodeTest.rb
|
57
|
-
- test/TableNodeTest.rb
|
58
|
-
- test/TableRowNodeTest.rb
|
59
|
-
- test/TextNodeTest.rb
|
60
|
-
- test/unittest.bat
|
61
|
-
- test/unittest.rb
|
62
|
-
- doc/makedoc.bat
|
63
|
-
- doc/README
|
64
|
-
- examples/example01.rb
|
65
|
-
- examples/example02.rb
|
66
|
-
- examples/example03.rb
|
67
|
-
- examples/example03.rtf
|
68
|
-
test_files:
|
69
|
-
- test/unittest.rb
|
70
|
-
rdoc_options:
|
71
|
-
- "--main"
|
72
|
-
- doc/README
|
73
|
-
extra_rdoc_files:
|
74
|
-
- doc/README
|
8
|
+
- Peter Wood
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-15 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: 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.
|
18
|
+
email: paw220470@yahoo.ie
|
75
19
|
executables: []
|
20
|
+
|
76
21
|
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- LICENSE
|
25
|
+
- README.rdoc
|
26
|
+
files:
|
27
|
+
- CHANGES
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- VERSION.yml
|
32
|
+
- examples/example01.rb
|
33
|
+
- examples/example02.rb
|
34
|
+
- examples/example03.rb
|
35
|
+
- examples/example03.rtf
|
36
|
+
- examples/example04.rb
|
37
|
+
- examples/rubyrtf.bmp
|
38
|
+
- examples/rubyrtf.jpg
|
39
|
+
- examples/rubyrtf.png
|
40
|
+
- lib/rtf.rb
|
41
|
+
- lib/rtf/colour.rb
|
42
|
+
- lib/rtf/font.rb
|
43
|
+
- lib/rtf/information.rb
|
44
|
+
- lib/rtf/node.rb
|
45
|
+
- lib/rtf/paper.rb
|
46
|
+
- lib/rtf/style.rb
|
47
|
+
- test/character_style_test.rb
|
48
|
+
- test/colour_table_test.rb
|
49
|
+
- test/colour_test.rb
|
50
|
+
- test/command_node_test.rb
|
51
|
+
- test/container_node_test.rb
|
52
|
+
- test/document_style_test.rb
|
53
|
+
- test/document_test.rb
|
54
|
+
- test/fixtures/bitmap1.bmp
|
55
|
+
- test/fixtures/bitmap2.bmp
|
56
|
+
- test/fixtures/jpeg1.jpg
|
57
|
+
- test/fixtures/jpeg2.jpg
|
58
|
+
- test/fixtures/png1.png
|
59
|
+
- test/fixtures/png2.png
|
60
|
+
- test/font_table_test.rb
|
61
|
+
- test/font_test.rb
|
62
|
+
- test/footer_node_test.rb
|
63
|
+
- test/header_node_test.rb
|
64
|
+
- test/image_node_test.rb
|
65
|
+
- test/information_test.rb
|
66
|
+
- test/node_test.rb
|
67
|
+
- test/paragraph_style_test.rb
|
68
|
+
- test/style_test.rb
|
69
|
+
- test/table_cell_node_test.rb
|
70
|
+
- test/table_node_test.rb
|
71
|
+
- test/table_row_node_test.rb
|
72
|
+
- test/test_helper.rb
|
73
|
+
- test/text_node_test.rb
|
74
|
+
has_rdoc: true
|
75
|
+
homepage: http://github.com/thechrisoshow/rtf
|
76
|
+
licenses: []
|
77
|
+
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
77
95
|
requirements: []
|
78
|
-
|
96
|
+
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 1.5.2
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Ruby library to create rich text format documents.
|
102
|
+
test_files:
|
103
|
+
- examples/example01.rb
|
104
|
+
- examples/example02.rb
|
105
|
+
- examples/example03.rb
|
106
|
+
- examples/example04.rb
|
107
|
+
- test/character_style_test.rb
|
108
|
+
- test/colour_table_test.rb
|
109
|
+
- test/colour_test.rb
|
110
|
+
- test/command_node_test.rb
|
111
|
+
- test/container_node_test.rb
|
112
|
+
- test/document_style_test.rb
|
113
|
+
- test/document_test.rb
|
114
|
+
- test/font_table_test.rb
|
115
|
+
- test/font_test.rb
|
116
|
+
- test/footer_node_test.rb
|
117
|
+
- test/header_node_test.rb
|
118
|
+
- test/image_node_test.rb
|
119
|
+
- test/information_test.rb
|
120
|
+
- test/node_test.rb
|
121
|
+
- test/paragraph_style_test.rb
|
122
|
+
- test/style_test.rb
|
123
|
+
- test/table_cell_node_test.rb
|
124
|
+
- test/table_node_test.rb
|
125
|
+
- test/table_row_node_test.rb
|
126
|
+
- test/test_helper.rb
|
127
|
+
- test/text_node_test.rb
|