ruport-util 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ end
18
18
 
19
19
  spec = Gem::Specification.new do |spec|
20
20
  spec.name = "ruport-util"
21
- spec.version = "0.5.0"
21
+ spec.version = "0.6.0"
22
22
  spec.platform = Gem::Platform::RUBY
23
23
  spec.summary = "A set of tools and helper libs for Ruby Reports"
24
24
  spec.files = Dir.glob("{example,lib,test,bin}/**/**/*") +
data/example/foo.svg ADDED
@@ -0,0 +1,83 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <?DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" type=""?>
3
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" height="300" width="500">
4
+ <g id="scruffy_graph">
5
+ <g transform="translate(0.0, 0.0)" id="background">
6
+ <defs>
7
+ <linearGradient y2="100%" x1="0%" x2="0%" id="BackgroundGradient" y1="0%">
8
+ <stop stop-color="black" offset="5%"/>
9
+ <stop stop-color="#4A465A" offset="95%"/>
10
+ </linearGradient>
11
+ </defs>
12
+ <rect x="0" y="0" height="300.0" width="500.0" fill="url(#BackgroundGradient)"/>
13
+ </g>
14
+ <g transform="translate(25.0, 6.0)" id="title">
15
+ <text x="225.0" font-size="21.0" text-anchor="middle" y="21.0" class="title" stroke-width="0" fill="white" stroke="none"></text>
16
+ </g>
17
+ <g transform="translate(10.0, 78.0)" id="view">
18
+ <g>
19
+ <g transform="translate(0.0, 3.96)" id="values">
20
+ <text x="80.1" font-size="14.0976" text-anchor="end" y="176.22" fill="white">0</text>
21
+ <text x="80.1" font-size="14.0976" text-anchor="end" y="132.165" fill="white">18</text>
22
+ <text x="80.1" font-size="14.0976" text-anchor="end" y="88.11" fill="white">35</text>
23
+ <text x="80.1" font-size="14.0976" text-anchor="end" y="44.055" fill="white">52</text>
24
+ <text x="80.1" font-size="14.0976" text-anchor="end" y="0.0" fill="white">70</text>
25
+ </g>
26
+ <g transform="translate(89.0, 0.0)" id="grid">
27
+ <line y2="0.0" x1="0" x2="356.0" style="stroke: white; stroke-width: 2;" y1="0.0"/>
28
+ <line y2="44.055" x1="0" x2="356.0" style="stroke: white; stroke-width: 2;" y1="44.055"/>
29
+ <line y2="88.11" x1="0" x2="356.0" style="stroke: white; stroke-width: 2;" y1="88.11"/>
30
+ <line y2="132.165" x1="0" x2="356.0" style="stroke: white; stroke-width: 2;" y1="132.165"/>
31
+ <line y2="176.22" x1="0" x2="356.0" style="stroke: white; stroke-width: 2;" y1="176.22"/>
32
+ </g>
33
+ <g transform="translate(89.0, 182.16)" id="labels">
34
+ <text x="0.0" font-size="14.256" text-anchor="middle" y="15.84" fill="white">a</text>
35
+ <text x="89.0" font-size="14.256" text-anchor="middle" y="15.84" fill="white">b</text>
36
+ <text x="178.0" font-size="14.256" text-anchor="middle" y="15.84" fill="white">c</text>
37
+ <text x="267.0" font-size="14.256" text-anchor="middle" y="15.84" fill="white">d</text>
38
+ <text x="356.0" font-size="14.256" text-anchor="middle" y="15.84" fill="white">e</text>
39
+ </g>
40
+ <g transform="translate(89.0, 0.0)" id="graphs">
41
+ <g class="graph_layer" id="component_graphs_graph_0">
42
+ <g class="shadow" transform="translate(0.8811, 0.8811)">
43
+ <polyline points="0.0,173.702571428571 89.0,171.185142857143 178.0,168.667714285714 267.0,166.150285714286 356.0,163.632857142857" stroke-width="3.5244" style="fill-opacity: 0; stroke-opacity: 0.35" fill="transparent" stroke="black"/>
44
+ <circle cx="0.0" cy="175.288551428571" style="stroke-width: 3.5244; stroke: black; opacity: 0.35;" r="3.5244"/>
45
+ <circle cx="89.0" cy="172.771122857143" style="stroke-width: 3.5244; stroke: black; opacity: 0.35;" r="3.5244"/>
46
+ <circle cx="178.0" cy="170.253694285714" style="stroke-width: 3.5244; stroke: black; opacity: 0.35;" r="3.5244"/>
47
+ <circle cx="267.0" cy="167.736265714286" style="stroke-width: 3.5244; stroke: black; opacity: 0.35;" r="3.5244"/>
48
+ <circle cx="356.0" cy="165.218837142857" style="stroke-width: 3.5244; stroke: black; opacity: 0.35;" r="3.5244"/>
49
+ </g>
50
+ <polyline points="0.0,173.702571428571 89.0,171.185142857143 178.0,168.667714285714 267.0,166.150285714286 356.0,163.632857142857" stroke-width="3.5244" fill="none" stroke="#6886B4"/>
51
+ <circle cx="0.0" cy="173.702571428571" style="stroke-width: 3.5244; stroke: #6886B4; fill: #6886B4" r="3.5244"/>
52
+ <circle cx="89.0" cy="171.185142857143" style="stroke-width: 3.5244; stroke: #6886B4; fill: #6886B4" r="3.5244"/>
53
+ <circle cx="178.0" cy="168.667714285714" style="stroke-width: 3.5244; stroke: #6886B4; fill: #6886B4" r="3.5244"/>
54
+ <circle cx="267.0" cy="166.150285714286" style="stroke-width: 3.5244; stroke: #6886B4; fill: #6886B4" r="3.5244"/>
55
+ <circle cx="356.0" cy="163.632857142857" style="stroke-width: 3.5244; stroke: #6886B4; fill: #6886B4" r="3.5244"/>
56
+ </g>
57
+ <g class="graph_layer" id="component_graphs_graph_1">
58
+ <g class="shadow" transform="translate(0.8811, 0.8811)">
59
+ <polyline points="0.0,148.528285714286 89.0,120.836571428571 178.0,0.0 267.0,171.185142857143 356.0,128.388857142857" stroke-width="3.5244" style="fill-opacity: 0; stroke-opacity: 0.35" fill="transparent" stroke="black"/>
60
+ <circle cx="0.0" cy="150.114265714286" style="stroke-width: 3.5244; stroke: black; opacity: 0.35;" r="3.5244"/>
61
+ <circle cx="89.0" cy="122.422551428571" style="stroke-width: 3.5244; stroke: black; opacity: 0.35;" r="3.5244"/>
62
+ <circle cx="178.0" cy="1.58598" style="stroke-width: 3.5244; stroke: black; opacity: 0.35;" r="3.5244"/>
63
+ <circle cx="267.0" cy="172.771122857143" style="stroke-width: 3.5244; stroke: black; opacity: 0.35;" r="3.5244"/>
64
+ <circle cx="356.0" cy="129.974837142857" style="stroke-width: 3.5244; stroke: black; opacity: 0.35;" r="3.5244"/>
65
+ </g>
66
+ <polyline points="0.0,148.528285714286 89.0,120.836571428571 178.0,0.0 267.0,171.185142857143 356.0,128.388857142857" stroke-width="3.5244" fill="none" stroke="#FDD84E"/>
67
+ <circle cx="0.0" cy="148.528285714286" style="stroke-width: 3.5244; stroke: #FDD84E; fill: #FDD84E" r="3.5244"/>
68
+ <circle cx="89.0" cy="120.836571428571" style="stroke-width: 3.5244; stroke: #FDD84E; fill: #FDD84E" r="3.5244"/>
69
+ <circle cx="178.0" cy="0.0" style="stroke-width: 3.5244; stroke: #FDD84E; fill: #FDD84E" r="3.5244"/>
70
+ <circle cx="267.0" cy="171.185142857143" style="stroke-width: 3.5244; stroke: #FDD84E; fill: #FDD84E" r="3.5244"/>
71
+ <circle cx="356.0" cy="128.388857142857" style="stroke-width: 3.5244; stroke: #FDD84E; fill: #FDD84E" r="3.5244"/>
72
+ </g>
73
+ </g>
74
+ </g>
75
+ </g>
76
+ <g transform="translate(25.0, 39.0)" id="legend">
77
+ <rect x="180.0" y="4.5" height="9.0" width="10.8" fill="#6886B4"/>
78
+ <text x="198.0" font-size="14.4" y="14.4" fill="white">foo</text>
79
+ <rect x="234.0" y="4.5" height="9.0" width="10.8" fill="#FDD84E"/>
80
+ <text x="252.0" font-size="14.4" y="14.4" fill="white">bar</text>
81
+ </g>
82
+ </g>
83
+ </svg>
data/example/form.pdf ADDED
@@ -0,0 +1,160 @@
1
+ %PDF-1.3
2
+ %����
3
+
4
+ 1 0 obj
5
+ << /Type /Catalog
6
+ /Outlines 2 0 R
7
+ /Pages 3 0 R>>
8
+ endobj
9
+ 2 0 obj
10
+ << /Type /Outlines >>
11
+ endobj
12
+ 3 0 obj
13
+ << /Type /Pages
14
+ /Kids [6 0 R
15
+ ]
16
+ /Count 1
17
+ /Resources <<
18
+ /ProcSet 4 0 R
19
+ /Font <<
20
+ /F1 8 0 R
21
+ /F2 10 0 R >>
22
+ >>
23
+ /MediaBox [0 0 612.0 792.0]
24
+ >>
25
+ endobj
26
+ 4 0 obj
27
+ [/PDF /Text ]
28
+ endobj
29
+ 5 0 obj
30
+ <<
31
+ /CreationDate (D:200705301332)
32
+ /Creator (form.rb)
33
+ /Producer (PDF::Writer for Ruby)
34
+ >>
35
+ endobj
36
+ 6 0 obj
37
+ << /Type /Page
38
+ /Parent 3 0 R
39
+ /Contents 7 0 R
40
+ >>
41
+ endobj
42
+ 7 0 obj
43
+ <<
44
+ /Length 1381 >>
45
+ stream
46
+
47
+ 0.000 0.000 0.000 rg
48
+ 0.000 0.000 0.000 RG
49
+ BT 257.992 737.504 Td /F1 16.0 Tf 0 Tr (Sample Form) Tj ET
50
+ BT 135.000 636.440 Td /F2 10.0 Tf 0 Tr (Name:) Tj /F1 10.0 Tf 0 Tr ( Gregory Brown) Tj ET
51
+ 1 w
52
+ 125.000 650.000 m
53
+ 325.000 650.000 l S
54
+ 1 w
55
+ 125.000 628.440 m
56
+ 325.000 628.440 l S
57
+ 1 w
58
+ 125.000 650.000 m
59
+ 125.000 628.440 l S
60
+ BT 335.000 636.440 Td /F2 10.0 Tf 0 Tr (User ID:) Tj /F1 10.0 Tf 0 Tr ( sandal) Tj ET
61
+ 1 w
62
+ 325.000 650.000 m
63
+ 475.000 650.000 l S
64
+ 1 w
65
+ 475.000 650.000 m
66
+ 475.000 628.440 l S
67
+ 1 w
68
+ 325.000 628.440 m
69
+ 475.000 628.440 l S
70
+ 1 w
71
+ 325.000 650.000 m
72
+ 325.000 628.440 l S
73
+ BT 135.000 616.440 Td /F2 10.0 Tf 0 Tr (Email:) Tj /F1 10.0 Tf 0 Tr ( gregory.t.brown@gmail.com) Tj ET
74
+ 1 w
75
+ 475.000 630.000 m
76
+ 475.000 608.440 l S
77
+ 1 w
78
+ 125.000 608.440 m
79
+ 475.000 608.440 l S
80
+ 1 w
81
+ 125.000 630.000 m
82
+ 125.000 608.440 l S
83
+ BT 280.000 588.440 Td /F1 10.0 Tf 0 Tr (Favorite Fruit: ) Tj ET
84
+ 1 w
85
+ 350.000 597.000 m
86
+ 362.000 597.000 l S
87
+ 1 w
88
+ 362.000 597.000 m
89
+ 362.000 585.000 l S
90
+ 1 w
91
+ 350.000 585.000 m
92
+ 362.000 585.000 l S
93
+ 1 w
94
+ 350.000 597.000 m
95
+ 350.000 585.000 l S
96
+ BT 370.000 588.440 Td /F1 10.0 Tf 0 Tr (Apple) Tj ET
97
+ 1 w
98
+ 410.000 597.000 m
99
+ 422.000 597.000 l S
100
+ 1 w
101
+ 422.000 597.000 m
102
+ 422.000 585.000 l S
103
+ 1 w
104
+ 410.000 585.000 m
105
+ 422.000 585.000 l S
106
+ 1 w
107
+ 410.000 597.000 m
108
+ 410.000 585.000 l S
109
+ 410.000 597.000 m
110
+ 422.000 585.000 l
111
+ 422.000 597.000 m
112
+ 410.000 585.000 l S
113
+ BT 430.000 588.440 Td /F1 10.0 Tf 0 Tr (Banana) Tj ET
114
+ endstream
115
+ endobj
116
+
117
+ 8 0 obj
118
+ << /Type /Font
119
+ /Subtype /Type1
120
+ /Name /F1
121
+ /BaseFont /Helvetica
122
+ /Encoding /WinAnsiEncoding
123
+ >>
124
+ endobj
125
+ 9 0 obj
126
+ << /Type /Encoding
127
+ /BaseEncoding /WinAnsiEncoding
128
+
129
+ >>
130
+ endobj
131
+ 10 0 obj
132
+ << /Type /Font
133
+ /Subtype /Type1
134
+ /Name /F2
135
+ /BaseFont /Helvetica-Bold
136
+ /Encoding 9 0 R
137
+ >>
138
+ endobj
139
+ xref
140
+ 0 11
141
+ 0000000000 65535 f
142
+ 0000000015 00000 n
143
+ 0000000079 00000 n
144
+ 0000000116 00000 n
145
+ 0000000269 00000 n
146
+ 0000000298 00000 n
147
+ 0000000402 00000 n
148
+ 0000000465 00000 n
149
+ 0000001899 00000 n
150
+ 0000002006 00000 n
151
+ 0000002075 00000 n
152
+
153
+ trailer
154
+ << /Size 11
155
+ /Root 1 0 R
156
+ /Info 5 0 R
157
+ >>
158
+ startxref
159
+ 2177
160
+ %%EOF
data/example/form.rb ADDED
@@ -0,0 +1,46 @@
1
+ require "ruport"
2
+ require "ruport/util"
3
+
4
+ class SimpleForm < Ruport::Renderer
5
+
6
+ stage :form_header, :form_body
7
+ finalize :form
8
+
9
+ required_option :name, :userid, :fruit, :email
10
+
11
+ class PDF < Ruport::Formatter::PDF
12
+ renders :pdf, :for => SimpleForm
13
+ include Ruport::Util::FormHelpers
14
+
15
+ def build_form_header
16
+ add_text "Sample Form", :font_size => 16, :justification => :center
17
+ end
18
+
19
+ def build_form_body
20
+ options.text_format = { :font_size => 10 }
21
+ form_field "Name:", options.name, :y => 650, :x => 125, :width => 200,
22
+ :border => [1,0,1,1]
23
+ form_field "User ID:", options.userid, :y => 650, :width => 150, :x => 325
24
+ form_field "Email:", options.email, :y => 630, :width => 350, :x => 125,
25
+ :border => [0,1,1]
26
+
27
+ draw_text "Favorite Fruit: ", :left => 280, :y => 600
28
+ option_box :apple, options.fruit, :label => "Apple", :y => 600, :x => 340
29
+ option_box :banana, options.fruit, :label => "Banana", :y => 600, :x => 400
30
+
31
+ end
32
+
33
+ def finalize_form
34
+ render_pdf
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
41
+ puts SimpleForm.render_pdf { |r|
42
+ r.name = "Gregory Brown"
43
+ r.userid = "sandal"
44
+ r.fruit = :banana
45
+ r.email = "gregory.t.brown@gmail.com"
46
+ }
@@ -1,4 +1,3 @@
1
- require "rubygems"
2
1
  require "ruport"
3
2
 
4
3
  require "ruport/util"
@@ -1,6 +1,5 @@
1
- require "rubygems"
2
1
  require "ruport"
3
- require "ruport/util/invoice"
2
+ require "ruport/util"
4
3
 
5
4
  class SampleReport < Ruport::Report
6
5
  include Invoice
data/example/mailer.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "ruport"
2
- require "ruport/util/mailer"
2
+ require "ruport/util"
3
3
  require "fileutils"
4
4
  class MyReport < Ruport::Report
5
5
  def prepare
@@ -1,6 +1,5 @@
1
- require "rubygems"
2
1
  require "ruport"
3
- require "ruport/util/report_manager"
2
+ require "ruport/util"
4
3
 
5
4
  class MyReport < Ruport::Report
6
5
 
data/example/out.pdf ADDED
@@ -0,0 +1,229 @@
1
+ %PDF-1.3
2
+ %����
3
+
4
+ 1 0 obj
5
+ << /Type /Catalog
6
+ /Outlines 2 0 R
7
+ /Pages 3 0 R>>
8
+ endobj
9
+ 2 0 obj
10
+ << /Type /Outlines >>
11
+ endobj
12
+ 3 0 obj
13
+ << /Type /Pages
14
+ /Kids [6 0 R
15
+ ]
16
+ /Count 1
17
+ /Resources <<
18
+ /ProcSet 4 0 R
19
+ /Font <<
20
+ /F1 8 0 R
21
+ /F2 10 0 R >>
22
+ >>
23
+ /MediaBox [0 0 612.0 792.0]
24
+ >>
25
+ endobj
26
+ 4 0 obj
27
+ [/PDF /Text ]
28
+ endobj
29
+ 5 0 obj
30
+ <<
31
+ /CreationDate (D:200705301339)
32
+ /Creator (invoice_report.rb)
33
+ /Producer (PDF::Writer for Ruby)
34
+ >>
35
+ endobj
36
+ 6 0 obj
37
+ << /Type /Page
38
+ /Parent 3 0 R
39
+ /Contents [
40
+ 7 0 R
41
+ 11 0 R
42
+ 12 0 R
43
+ ]
44
+ >>
45
+ endobj
46
+ 7 0 obj
47
+ <<
48
+ /Length 2223 >>
49
+ stream
50
+
51
+ 0.000 0.000 0.000 rg
52
+ 0.000 0.000 0.000 RG
53
+ q
54
+ 1.000 1.000 1.000 rg
55
+ 49.000 756.000 m
56
+ 243.000 756.000 l
57
+ 244.500 756.000 246.000 754.500 246.000 753.000 c
58
+ 246.000 709.000 l
59
+ 246.000 707.500 244.500 706.000 243.000 706.000 c
60
+ 49.000 706.000 l
61
+ 47.500 706.000 46.000 707.500 46.000 709.000 c
62
+ 46.000 753.000 l
63
+ 46.000 754.500 47.500 756.000 49.000 756.000 c
64
+ 246.000 706.000 m B
65
+ 1 w
66
+ Q
67
+ BT 87.640 744.440 Td /F1 10.0 Tf 0 Tr (Stone Code Productions
68
+ ) Tj ET
69
+ BT 108.480 732.880 Td /F1 10.0 Tf 0 Tr (43 Neagle Street) Tj ET
70
+ q
71
+ 1.000 1.000 1.000 rg
72
+ 49.000 701.000 m
73
+ 243.000 701.000 l
74
+ 244.500 701.000 246.000 699.500 246.000 698.000 c
75
+ 246.000 654.000 l
76
+ 246.000 652.500 244.500 651.000 243.000 651.000 c
77
+ 49.000 651.000 l
78
+ 47.500 651.000 46.000 652.500 46.000 654.000 c
79
+ 46.000 698.000 l
80
+ 46.000 699.500 47.500 701.000 49.000 701.000 c
81
+ 246.000 651.000 m B
82
+ 1 w
83
+ Q
84
+ BT 108.215 689.440 Td /F1 10.0 Tf 0 Tr (Gregory Brown
85
+ ) Tj ET
86
+ BT 112.095 677.880 Td /F1 10.0 Tf 0 Tr (200 Foo Ave.
87
+ ) Tj ET
88
+ q
89
+ 0.800 0.800 0.800 rg
90
+ 381.000 756.000 m
91
+ 571.000 756.000 l
92
+ 573.500 756.000 576.000 753.500 576.000 751.000 c
93
+ 576.000 741.000 l
94
+ 576.000 738.500 573.500 736.000 571.000 736.000 c
95
+ 381.000 736.000 l
96
+ 378.500 736.000 376.000 738.500 376.000 741.000 c
97
+ 376.000 751.000 l
98
+ 376.000 753.500 378.500 756.000 381.000 756.000 c
99
+ 576.000 736.000 m B
100
+ 1 w
101
+ Q
102
+ BT 386.724 743.284 Td /F2 11.0 Tf 0 Tr (Invoice for 12.15.2006 - 12.31.2006) Tj ET
103
+ q
104
+ 1.000 1.000 1.000 rg
105
+ 381.000 731.000 m
106
+ 571.000 731.000 l
107
+ 573.500 731.000 576.000 728.500 576.000 726.000 c
108
+ 576.000 656.000 l
109
+ 576.000 653.500 573.500 651.000 571.000 651.000 c
110
+ 381.000 651.000 l
111
+ 378.500 651.000 376.000 653.500 376.000 656.000 c
112
+ 376.000 726.000 l
113
+ 376.000 728.500 378.500 731.000 381.000 731.000 c
114
+ 576.000 651.000 m B
115
+ 376.000 711.000 m
116
+ 576.000 711.000 l S
117
+ 0.000 0.000 0.000 rg
118
+ BT 431.830 716.440 Td /F2 10.0 Tf 0 Tr (Billing Information) Tj ET
119
+ 1 w
120
+ Q
121
+ BT 447.665 699.440 Td /F2 10.0 Tf 0 Tr (Some info
122
+ ) Tj ET
123
+ BT 435.995 687.880 Td /F2 10.0 Tf 0 Tr (about your order) Tj ET
124
+ 0.800 0.800 0.800 RG
125
+ BT 66.000 584.128 Td /F1 12.0 Tf 0 Tr (Item Number) Tj ET
126
+ BT 232.274 584.128 Td /F1 12.0 Tf 0 Tr (Description) Tj ET
127
+ BT 407.650 584.128 Td /F1 12.0 Tf 0 Tr (Price) Tj ET
128
+ q
129
+ 0.800 0.800 0.800 rg
130
+ 61.000 562.068 480.000 15.560 re f
131
+ 1 w
132
+ Q
133
+ endstream
134
+ endobj
135
+
136
+ 8 0 obj
137
+ << /Type /Font
138
+ /Subtype /Type1
139
+ /Name /F1
140
+ /BaseFont /Helvetica
141
+ /Encoding /WinAnsiEncoding
142
+ >>
143
+ endobj
144
+ 9 0 obj
145
+ << /Type /Encoding
146
+ /BaseEncoding /WinAnsiEncoding
147
+
148
+ >>
149
+ endobj
150
+ 10 0 obj
151
+ << /Type /Font
152
+ /Subtype /Type1
153
+ /Name /F2
154
+ /BaseFont /Helvetica-Bold
155
+ /Encoding 9 0 R
156
+ >>
157
+ endobj
158
+ 11 0 obj
159
+ <<
160
+ /Length 631 >>
161
+ stream
162
+
163
+ BT 66.000 566.318 Td /F1 10.0 Tf 0 Tr (101) Tj ET
164
+ BT 232.274 566.318 Td /F1 10.0 Tf 0 Tr (Erlang The Movie) Tj ET
165
+ BT 407.650 566.318 Td /F1 10.0 Tf 0 Tr ($1000.00) Tj ET
166
+ BT 66.000 550.758 Td /F1 10.0 Tf 0 Tr (102) Tj ET
167
+ BT 232.274 550.758 Td /F1 10.0 Tf 0 Tr (Erlang The Book) Tj ET
168
+ BT 407.650 550.758 Td /F1 10.0 Tf 0 Tr ($45.95) Tj ET
169
+ 0.000 0.000 0.000 RG
170
+ 1 w
171
+ 61.000 600.000 m
172
+ 61.000 546.508 l S
173
+ 1 w
174
+ 227.274 600.000 m
175
+ 227.274 546.508 l S
176
+ 402.650 600.000 m
177
+ 402.650 546.508 l S
178
+ 1 w
179
+ 541.000 600.000 m
180
+ 541.000 546.508 l S
181
+ 60.500 600.000 m
182
+ 541.500 600.000 l S
183
+ 61.000 579.878 m
184
+ 541.000 579.878 l S
185
+ 60.500 546.508 m
186
+ 541.500 546.508 l S
187
+ endstream
188
+ endobj
189
+
190
+ 12 0 obj
191
+ <<
192
+ /Length 154 >>
193
+ stream
194
+
195
+ q
196
+ 0.000 0.000 0.000 RG
197
+ 1 w 0 J 0 j [ ] 0 d
198
+ 56.000 60.000 m
199
+ 551.000 60.000 l S
200
+ BT 256.265 38.440 Td /F1 10.0 Tf 0 Tr (Hello Mike! Hello Joe!) Tj ET
201
+ 1 w
202
+ Q
203
+ endstream
204
+ endobj
205
+
206
+ xref
207
+ 0 13
208
+ 0000000000 65535 f
209
+ 0000000015 00000 n
210
+ 0000000079 00000 n
211
+ 0000000116 00000 n
212
+ 0000000269 00000 n
213
+ 0000000298 00000 n
214
+ 0000000412 00000 n
215
+ 0000000493 00000 n
216
+ 0000002769 00000 n
217
+ 0000002876 00000 n
218
+ 0000002945 00000 n
219
+ 0000003047 00000 n
220
+ 0000003731 00000 n
221
+
222
+ trailer
223
+ << /Size 13
224
+ /Root 1 0 R
225
+ /Info 5 0 R
226
+ >>
227
+ startxref
228
+ 3938
229
+ %%EOF
@@ -19,42 +19,6 @@ module Ruport
19
19
  end
20
20
 
21
21
  module_function :Graph
22
-
23
- class Graph < Ruport::Data::Table
24
-
25
- class Line < Ruport::Data::Record
26
- attr_accessor :name
27
-
28
- def initialize_copy(from)
29
- @name = from.name.dup if from.name
30
- end
31
- end
32
-
33
- def initialize(options={})
34
- super({:record_class => Line}.merge(options))
35
- end
36
-
37
- def add_line(row_data,options={})
38
- self << row_data
39
- self[-1].name = options[:name]
40
- end
41
-
42
- def dup
43
- obj = self.class.new(:column_names => column_names)
44
- data.each { |r| obj.add_line(r.to_a,:name => r.name)}
45
- return obj
46
- end
47
-
48
- def as(format,*args,&block)
49
- Ruport::Renderer::Graph.render(format,*args,&block)
50
- end
51
-
52
- def method_missing(id,*args,&block)
53
- id.to_s =~ /^to_(.*)/
54
- $1 ? as($1.to_sym,{:data => self}.merge(args[0]||{}),&block) : super
55
- end
56
-
57
- end
58
22
 
59
23
  # This class implements the basic graphing engine for Ruport.
60
24
  #
@@ -84,6 +48,35 @@ module Ruport
84
48
 
85
49
  finalize :graph
86
50
 
51
+ end
52
+
53
+ class Graph < Ruport::Data::Table
54
+
55
+ renders_with Renderer::Graph
56
+
57
+ class Line < Ruport::Data::Record
58
+ attr_accessor :name
59
+
60
+ def initialize_copy(from)
61
+ @name = from.name.dup if from.name
62
+ end
63
+ end
64
+
65
+ def initialize(options={})
66
+ super({:record_class => Line}.merge(options))
67
+ end
68
+
69
+ def add_line(row_data,options={})
70
+ self << row_data
71
+ self[-1].name = options[:name]
72
+ end
73
+
74
+ def dup
75
+ obj = self.class.new(:column_names => column_names)
76
+ data.each { |r| obj.add_line(r.to_a,:name => r.name)}
77
+ return obj
78
+ end
79
+
87
80
  end
88
81
 
89
82
  class Formatter::SVG < Formatter
@@ -0,0 +1,121 @@
1
+ module Ruport
2
+ module Util
3
+ module FormHelpers
4
+
5
+ def form_field(label,text,opts={})
6
+ padding = Array(opts.delete(:padding) || 0)
7
+ padding_top = padding[0]
8
+ padding_right = padding[1] || padding_top
9
+ padding_bottom = padding[2] || padding_top
10
+ padding_left = padding[3] || padding_right
11
+
12
+ x = opts.delete(:x) || left_boundary
13
+ y = opts.delete(:y) || cursor
14
+ width = opts.delete(:width) || full_width(x)
15
+ height = opts.delete(:height)
16
+
17
+ old_cursor = cursor
18
+ old_font = pdf_writer.font_size
19
+
20
+ move_cursor_to(y - 2 - padding_top)
21
+ if opts[:style] == "vertical"
22
+ draw_text "<b>#{label}</b>\n#{text}", :left => x + 10 + padding_left
23
+ height ||= pdf_writer.font_height * (text.count("\n") + 2) + 10 +
24
+ padding_top + padding_bottom
25
+ else
26
+ draw_text "<b>#{label}</b> #{text}", :left => x + 10 + padding_left
27
+ height ||= pdf_writer.font_height + 10 + padding_top + padding_bottom
28
+ end
29
+ draw_border(x,y,width,height,opts)
30
+
31
+ if opts[:maintain_cursor]
32
+ move_cursor_to(old_cursor)
33
+ else
34
+ move_cursor(-8 - padding_bottom)
35
+ end
36
+ pdf_writer.font_size = old_font
37
+ end
38
+
39
+ def option_box(opt,choice,opts={})
40
+ x = opts[:x] || left_boundary
41
+ y = opts[:y] || cursor
42
+ width = opts[:width] || 12
43
+ height = opts[:height] || 12
44
+
45
+ old_cursor = cursor
46
+ old_font = pdf_writer.font_size
47
+
48
+ if opt.eql?(choice)
49
+ checked_box(x + 10, y - 3, width, height)
50
+ else
51
+ unchecked_box(x + 10, y - 3, width, height)
52
+ end
53
+ draw_text opts[:label], :left => x + 10 + width + 8,
54
+ :y => y if opts[:label]
55
+
56
+ opts[:maintain_cursor] ? move_cursor_to(old_cursor) : move_cursor(-8)
57
+ pdf_writer.font_size = old_font
58
+ end
59
+
60
+ def checked_box(x,y,width=12,height=12)
61
+ draw_border(x,y,width,height)
62
+ pdf_writer.line(x, y, x + width, y - height)
63
+ pdf_writer.line(x + width, y, x, y - height)
64
+ pdf_writer.stroke
65
+ end
66
+
67
+ def unchecked_box(x,y,width=12,height=12)
68
+ draw_border(x,y,width,height)
69
+ end
70
+
71
+ # Draws a box at the specified x and y coordinates (top left corner),
72
+ # with the specified width and height
73
+ def draw_border(x,y,width,height,opts={})
74
+ border = Array(opts[:border] || 1)
75
+ border_top = border[0]
76
+ border_right = border[1] || border_top
77
+ border_bottom = border[2] || border_top
78
+ border_left = border[3] || border_right
79
+
80
+ draw_line(x, y, x + width, y,
81
+ border_top) if border_top > 0
82
+ draw_line(x + width, y, x + width, y - height,
83
+ border_right) if border_right > 0
84
+ draw_line(x, y - height, x + width, y - height,
85
+ border_bottom) if border_bottom > 0
86
+ draw_line(x, y, x, y - height,
87
+ border_left) if border_left > 0
88
+ end
89
+
90
+ def draw_line(x1,y1,x2,y2,thickness)
91
+ ss = PDF::Writer::StrokeStyle.new(thickness)
92
+ pdf_writer.stroke_style(ss)
93
+ pdf_writer.line(x1,y1,x2,y2)
94
+ pdf_writer.stroke
95
+ end
96
+
97
+ # draws a horizontal line at y from x1 to x2
98
+ def horizontal_line_at(y,x1,x2)
99
+ pdf_writer.line(x1,y,x2,y)
100
+ pdf_writer.stroke
101
+ end
102
+
103
+ def full_width(x=nil)
104
+ x ? right_boundary - x : right_boundary - left_boundary
105
+ end
106
+
107
+ end
108
+ end
109
+ end
110
+
111
+ module Ruport
112
+ class Formatter::PDF
113
+ alias_method :original_draw_text, :draw_text
114
+
115
+ def draw_text(text,text_opts)
116
+ y_pos = cursor
117
+ original_draw_text(text,text_opts)
118
+ move_cursor_to(y_pos) if text_opts[:maintain_cursor]
119
+ end
120
+ end
121
+ end
data/lib/ruport/util.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Ruport
2
2
  module Util
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
6
6
  require "ruport/util/report"
@@ -10,3 +10,4 @@ require "ruport/util/report_manager"
10
10
  require "ruport/util/mailer"
11
11
  require "ruport/util/bench"
12
12
  require "ruport/util/generator"
13
+ require "ruport/util/pdf/form"
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ruport-util
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.0
7
- date: 2007-05-14 00:00:00 -04:00
6
+ version: 0.6.0
7
+ date: 2007-05-30 00:00:00 -04:00
8
8
  summary: A set of tools and helper libs for Ruby Reports
9
9
  require_paths:
10
10
  - lib
@@ -29,10 +29,14 @@ post_install_message:
29
29
  authors:
30
30
  - Gregory Brown
31
31
  files:
32
+ - example/foo.svg
33
+ - example/form.pdf
34
+ - example/form.rb
32
35
  - example/graph_report.rb
33
36
  - example/invoice_report.rb
34
37
  - example/mailer.rb
35
38
  - example/managed_report.rb
39
+ - example/out.pdf
36
40
  - lib/ruport
37
41
  - lib/ruport/util
38
42
  - lib/ruport/util.rb
@@ -41,8 +45,10 @@ files:
41
45
  - lib/ruport/util/graph.rb
42
46
  - lib/ruport/util/invoice.rb
43
47
  - lib/ruport/util/mailer.rb
48
+ - lib/ruport/util/pdf
44
49
  - lib/ruport/util/report.rb
45
50
  - lib/ruport/util/report_manager.rb
51
+ - lib/ruport/util/pdf/form.rb
46
52
  - test/init.rb
47
53
  - test/samples
48
54
  - test/test_graph_renderer.rb