ruport 0.8.1 → 0.8.2
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.
- data/Rakefile +1 -1
- data/examples/line_graph.rb +38 -0
- data/lib/ruport.rb +1 -1
- data/lib/ruport/format/pdf.rb +24 -8
- data/lib/ruport/format/svg.rb +1 -2
- data/lib/ruport/format/text.rb +4 -1
- data/lib/ruport/renderer/graph.rb +0 -2
- metadata +91 -90
data/Rakefile
CHANGED
|
@@ -23,7 +23,7 @@ end
|
|
|
23
23
|
|
|
24
24
|
spec = Gem::Specification.new do |spec|
|
|
25
25
|
spec.name = LEAN ? "lean-ruport" : "ruport"
|
|
26
|
-
spec.version = "0.8.
|
|
26
|
+
spec.version = "0.8.2"
|
|
27
27
|
spec.platform = Gem::Platform::RUBY
|
|
28
28
|
spec.summary = "A generalized Ruby report generation and templating engine."
|
|
29
29
|
spec.files = Dir.glob("{examples,lib,test,bin}/**/**/*") +
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require "ruport"
|
|
2
|
+
table = Table(%w[jan feb mar apr may jun jul]) do |t|
|
|
3
|
+
t << [5,7,9,12,14,16,18]
|
|
4
|
+
t << [21,3,8,19,13,15,1]
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
table[0].tag :ghosts
|
|
8
|
+
table[1].tag "pirates"
|
|
9
|
+
|
|
10
|
+
results = Ruport::Renderer::Graph.render_svg do |r|
|
|
11
|
+
|
|
12
|
+
r.data = table
|
|
13
|
+
|
|
14
|
+
r.options.title = "Simple Line Graph"
|
|
15
|
+
|
|
16
|
+
r.layout do |l|
|
|
17
|
+
l.width = 700
|
|
18
|
+
l.height = 500
|
|
19
|
+
l.theme = r.plugin.themes[:keynote]
|
|
20
|
+
l.style = :line
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
File.open("line_graph.svg","w") { |f| f << results }
|
|
25
|
+
|
|
26
|
+
PAGE = <<-END_HTML
|
|
27
|
+
<html>
|
|
28
|
+
<body>
|
|
29
|
+
<embed
|
|
30
|
+
src="line_graph.svg"
|
|
31
|
+
width="700"
|
|
32
|
+
height="500"
|
|
33
|
+
/>
|
|
34
|
+
</body>
|
|
35
|
+
<html>
|
|
36
|
+
END_HTML
|
|
37
|
+
|
|
38
|
+
File.open("line_graph.html","w") { |f| f << PAGE }
|
data/lib/ruport.rb
CHANGED
data/lib/ruport/format/pdf.rb
CHANGED
|
@@ -184,21 +184,37 @@ module Ruport::Format
|
|
|
184
184
|
pdf_writer.add_object(wm, :all_pages)
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
|
|
188
|
+
# moves the PDF::Writer cursor by dy points
|
|
189
|
+
# NOTE: In PDF::Writer, 0 is at the bottom of the page.
|
|
190
|
+
def move_cursor(dy)
|
|
191
|
+
pdf_writer.y += dy
|
|
190
192
|
end
|
|
191
193
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
+
# moves the PDF::Writer cursor to the y position specified
|
|
195
|
+
def move_cursor_to(y)
|
|
196
|
+
pdf_writer.y = y
|
|
194
197
|
end
|
|
195
198
|
|
|
196
|
-
|
|
197
|
-
|
|
199
|
+
# moves the cursor down by dy, executes the block, and moves the cursor
|
|
200
|
+
# again.
|
|
201
|
+
#
|
|
202
|
+
# Example:
|
|
203
|
+
#
|
|
204
|
+
# # Add a padding of 5 to a text element
|
|
205
|
+
#
|
|
206
|
+
# pad(5) { add_text "hello" }
|
|
207
|
+
#
|
|
208
|
+
def pad(dy,&block)
|
|
209
|
+
move_cursor -dy
|
|
198
210
|
block.call
|
|
199
|
-
move_cursor -
|
|
211
|
+
move_cursor -dy
|
|
200
212
|
end
|
|
201
213
|
|
|
214
|
+
# Used by Renderer::Table to draw a SimpleTable.
|
|
215
|
+
# table_width, max_table_width and orientation can all be set via the
|
|
216
|
+
# <tt>layout</tt> object
|
|
217
|
+
#
|
|
202
218
|
def draw_table
|
|
203
219
|
m = "Sorry, cant build PDFs from array like things (yet)"
|
|
204
220
|
raise m if data.column_names.empty?
|
data/lib/ruport/format/svg.rb
CHANGED
|
@@ -35,13 +35,12 @@ module Ruport::Format
|
|
|
35
35
|
@graph.title ||= options.title
|
|
36
36
|
@graph.theme = layout.theme if layout.theme
|
|
37
37
|
@graph.point_markers ||= data.column_names
|
|
38
|
-
|
|
39
38
|
end
|
|
40
39
|
|
|
41
40
|
# Generates an SVG using Scruffy.
|
|
42
41
|
def build_graph
|
|
43
42
|
data.each_with_index do |r,i|
|
|
44
|
-
add_line(r.to_a,r.tags.to_a[0] || "series #{i+1}")
|
|
43
|
+
add_line(r.to_a,r.tags.to_a[0].to_s || "series #{i+1}")
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
output << @graph.render(:size => [layout.width, layout.height])
|
data/lib/ruport/format/text.rb
CHANGED
|
@@ -69,8 +69,11 @@ module Ruport
|
|
|
69
69
|
|
|
70
70
|
# Truncates a string so that it does not exceed Text#width
|
|
71
71
|
def fit_to_width(s)
|
|
72
|
+
# workaround for Rails setting terminal_width to 1
|
|
73
|
+
width < 2 ? max_width = 80 : max_width = width
|
|
74
|
+
|
|
72
75
|
s.split("\n").each { |r|
|
|
73
|
-
r.gsub!(/\A.{#{
|
|
76
|
+
r.gsub!(/\A.{#{max_width+1},}/) { |m| m[0,max_width-2] + ">>" }
|
|
74
77
|
}.join("\n") + "\n"
|
|
75
78
|
end
|
|
76
79
|
|
metadata
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
|
-
rubygems_version: 0.9.
|
|
2
|
+
rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: ruport
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: 0.8.
|
|
7
|
-
date: 2007-02-
|
|
6
|
+
version: 0.8.2
|
|
7
|
+
date: 2007-02-11 00:00:00 -05:00
|
|
8
8
|
summary: A generalized Ruby report generation and templating engine.
|
|
9
9
|
require_paths:
|
|
10
10
|
- lib
|
|
@@ -29,126 +29,127 @@ post_install_message:
|
|
|
29
29
|
authors:
|
|
30
30
|
- Gregory Brown
|
|
31
31
|
files:
|
|
32
|
+
- examples/rope_examples
|
|
33
|
+
- examples/RWEmerson.jpg
|
|
32
34
|
- examples/centered_pdf_text_box.rb
|
|
33
|
-
- examples/invoice.rb
|
|
34
|
-
- examples/invoice_report.rb
|
|
35
35
|
- examples/line_plotter.rb
|
|
36
|
+
- examples/invoice_report.rb
|
|
37
|
+
- examples/line_graph.rb
|
|
36
38
|
- examples/pdf_complex_report.rb
|
|
39
|
+
- examples/invoice.rb
|
|
37
40
|
- examples/pdf_table_with_title.rb
|
|
38
|
-
- examples/rope_examples
|
|
39
|
-
- examples/RWEmerson.jpg
|
|
40
|
-
- examples/rope_examples/itunes
|
|
41
41
|
- examples/rope_examples/sales_report
|
|
42
|
-
- examples/rope_examples/itunes
|
|
43
|
-
- examples/rope_examples/
|
|
44
|
-
- examples/rope_examples/
|
|
45
|
-
- examples/rope_examples/
|
|
46
|
-
- examples/rope_examples/
|
|
47
|
-
- examples/rope_examples/itunes/Rakefile
|
|
48
|
-
- examples/rope_examples/itunes/README
|
|
49
|
-
- examples/rope_examples/itunes/sql
|
|
50
|
-
- examples/rope_examples/itunes/templates
|
|
51
|
-
- examples/rope_examples/itunes/test
|
|
52
|
-
- examples/rope_examples/itunes/util
|
|
53
|
-
- examples/rope_examples/itunes/config/ruport_config.rb
|
|
54
|
-
- examples/rope_examples/itunes/data/mix.txt
|
|
55
|
-
- examples/rope_examples/itunes/lib/helpers.rb
|
|
56
|
-
- examples/rope_examples/itunes/lib/init.rb
|
|
57
|
-
- examples/rope_examples/itunes/lib/reports
|
|
58
|
-
- examples/rope_examples/itunes/lib/reports.rb
|
|
59
|
-
- examples/rope_examples/itunes/lib/reports/playlist.rb
|
|
60
|
-
- examples/rope_examples/itunes/log/ruport.log
|
|
61
|
-
- examples/rope_examples/itunes/test/test_playlist.rb
|
|
62
|
-
- examples/rope_examples/itunes/util/build
|
|
63
|
-
- examples/rope_examples/itunes/util/sql_exec
|
|
42
|
+
- examples/rope_examples/itunes
|
|
43
|
+
- examples/rope_examples/sales_report/sql
|
|
44
|
+
- examples/rope_examples/sales_report/test
|
|
45
|
+
- examples/rope_examples/sales_report/output
|
|
46
|
+
- examples/rope_examples/sales_report/log
|
|
64
47
|
- examples/rope_examples/sales_report/config
|
|
65
|
-
- examples/rope_examples/sales_report/data
|
|
66
48
|
- examples/rope_examples/sales_report/lib
|
|
67
|
-
- examples/rope_examples/sales_report/
|
|
68
|
-
- examples/rope_examples/sales_report/
|
|
49
|
+
- examples/rope_examples/sales_report/data
|
|
50
|
+
- examples/rope_examples/sales_report/util
|
|
51
|
+
- examples/rope_examples/sales_report/templates
|
|
69
52
|
- examples/rope_examples/sales_report/Rakefile
|
|
70
53
|
- examples/rope_examples/sales_report/README
|
|
71
|
-
- examples/rope_examples/sales_report/
|
|
72
|
-
- examples/rope_examples/sales_report/
|
|
73
|
-
- examples/rope_examples/sales_report/
|
|
74
|
-
- examples/rope_examples/sales_report/
|
|
54
|
+
- examples/rope_examples/sales_report/test/test_sales.rb
|
|
55
|
+
- examples/rope_examples/sales_report/output/books.pdf
|
|
56
|
+
- examples/rope_examples/sales_report/output/books.txt
|
|
57
|
+
- examples/rope_examples/sales_report/log/ruport.log
|
|
75
58
|
- examples/rope_examples/sales_report/config/ruport_config.rb
|
|
76
|
-
- examples/rope_examples/sales_report/lib/helpers.rb
|
|
77
|
-
- examples/rope_examples/sales_report/lib/init.rb
|
|
78
59
|
- examples/rope_examples/sales_report/lib/reports
|
|
79
60
|
- examples/rope_examples/sales_report/lib/reports.rb
|
|
61
|
+
- examples/rope_examples/sales_report/lib/helpers.rb
|
|
62
|
+
- examples/rope_examples/sales_report/lib/init.rb
|
|
80
63
|
- examples/rope_examples/sales_report/lib/reports/sales.rb
|
|
81
|
-
- examples/rope_examples/sales_report/log/ruport.log
|
|
82
|
-
- examples/rope_examples/sales_report/output/books.pdf
|
|
83
|
-
- examples/rope_examples/sales_report/output/books.txt
|
|
84
|
-
- examples/rope_examples/sales_report/test/test_sales.rb
|
|
85
64
|
- examples/rope_examples/sales_report/util/build
|
|
86
65
|
- examples/rope_examples/sales_report/util/sql_exec
|
|
66
|
+
- examples/rope_examples/itunes/sql
|
|
67
|
+
- examples/rope_examples/itunes/test
|
|
68
|
+
- examples/rope_examples/itunes/output
|
|
69
|
+
- examples/rope_examples/itunes/log
|
|
70
|
+
- examples/rope_examples/itunes/config
|
|
71
|
+
- examples/rope_examples/itunes/lib
|
|
72
|
+
- examples/rope_examples/itunes/data
|
|
73
|
+
- examples/rope_examples/itunes/util
|
|
74
|
+
- examples/rope_examples/itunes/templates
|
|
75
|
+
- examples/rope_examples/itunes/Rakefile
|
|
76
|
+
- examples/rope_examples/itunes/README
|
|
77
|
+
- examples/rope_examples/itunes/test/test_playlist.rb
|
|
78
|
+
- examples/rope_examples/itunes/log/ruport.log
|
|
79
|
+
- examples/rope_examples/itunes/config/ruport_config.rb
|
|
80
|
+
- examples/rope_examples/itunes/lib/reports
|
|
81
|
+
- examples/rope_examples/itunes/lib/reports.rb
|
|
82
|
+
- examples/rope_examples/itunes/lib/helpers.rb
|
|
83
|
+
- examples/rope_examples/itunes/lib/init.rb
|
|
84
|
+
- examples/rope_examples/itunes/lib/reports/playlist.rb
|
|
85
|
+
- examples/rope_examples/itunes/data/mix.txt
|
|
86
|
+
- examples/rope_examples/itunes/util/build
|
|
87
|
+
- examples/rope_examples/itunes/util/sql_exec
|
|
87
88
|
- lib/ruport
|
|
88
|
-
- lib/ruport.rb
|
|
89
89
|
- lib/uport.rb
|
|
90
|
-
- lib/ruport
|
|
91
|
-
- lib/ruport/config.rb
|
|
92
|
-
- lib/ruport/data
|
|
93
|
-
- lib/ruport/data.rb
|
|
90
|
+
- lib/ruport.rb
|
|
94
91
|
- lib/ruport/format
|
|
95
|
-
- lib/ruport/
|
|
96
|
-
- lib/ruport/
|
|
92
|
+
- lib/ruport/query
|
|
93
|
+
- lib/ruport/renderer
|
|
94
|
+
- lib/ruport/data
|
|
95
|
+
- lib/ruport/report
|
|
97
96
|
- lib/ruport/layout
|
|
98
97
|
- lib/ruport/layout.rb
|
|
99
|
-
- lib/ruport/
|
|
100
|
-
- lib/ruport/
|
|
98
|
+
- lib/ruport/attempt.rb
|
|
99
|
+
- lib/ruport/generator.rb
|
|
100
|
+
- lib/ruport/format.rb
|
|
101
|
+
- lib/ruport/system_extensions.rb
|
|
101
102
|
- lib/ruport/query.rb
|
|
102
|
-
- lib/ruport/
|
|
103
|
+
- lib/ruport/config.rb
|
|
103
104
|
- lib/ruport/renderer.rb
|
|
104
|
-
- lib/ruport/
|
|
105
|
+
- lib/ruport/mailer.rb
|
|
106
|
+
- lib/ruport/data.rb
|
|
105
107
|
- lib/ruport/report.rb
|
|
106
|
-
- lib/ruport/system_extensions.rb
|
|
107
|
-
- lib/ruport/data/groupable.rb
|
|
108
|
-
- lib/ruport/data/record.rb
|
|
109
|
-
- lib/ruport/data/table.rb
|
|
110
|
-
- lib/ruport/data/taggable.rb
|
|
111
|
-
- lib/ruport/format/csv.rb
|
|
112
|
-
- lib/ruport/format/html.rb
|
|
113
108
|
- lib/ruport/format/latex.rb
|
|
114
|
-
- lib/ruport/format/pdf.rb
|
|
115
109
|
- lib/ruport/format/plugin.rb
|
|
116
110
|
- lib/ruport/format/svg.rb
|
|
117
|
-
- lib/ruport/format/text.rb
|
|
118
111
|
- lib/ruport/format/xml.rb
|
|
119
|
-
- lib/ruport/
|
|
112
|
+
- lib/ruport/format/html.rb
|
|
113
|
+
- lib/ruport/format/text.rb
|
|
114
|
+
- lib/ruport/format/pdf.rb
|
|
115
|
+
- lib/ruport/format/csv.rb
|
|
120
116
|
- lib/ruport/query/sql_split.rb
|
|
121
117
|
- lib/ruport/renderer/graph.rb
|
|
122
118
|
- lib/ruport/renderer/table.rb
|
|
119
|
+
- lib/ruport/data/record.rb
|
|
120
|
+
- lib/ruport/data/groupable.rb
|
|
121
|
+
- lib/ruport/data/taggable.rb
|
|
122
|
+
- lib/ruport/data/table.rb
|
|
123
123
|
- lib/ruport/report/graph.rb
|
|
124
|
-
-
|
|
124
|
+
- lib/ruport/layout/component.rb
|
|
125
125
|
- test/samples
|
|
126
|
-
- test/
|
|
127
|
-
- test/test_format_text.rb
|
|
128
|
-
- test/test_graph_renderer.rb
|
|
126
|
+
- test/test_record.rb
|
|
129
127
|
- test/test_groupable.rb
|
|
130
|
-
- test/
|
|
128
|
+
- test/test_table.rb
|
|
129
|
+
- test/test_graph_renderer.rb
|
|
130
|
+
- test/test_ruport.rb
|
|
131
|
+
- test/test_format_text.rb
|
|
132
|
+
- test/_test_database.rb
|
|
131
133
|
- test/test_query.rb
|
|
132
|
-
- test/
|
|
134
|
+
- test/test_config.rb
|
|
135
|
+
- test/test_taggable.rb
|
|
133
136
|
- test/test_renderer.rb
|
|
134
|
-
- test/
|
|
135
|
-
- test/test_ruport.rb
|
|
137
|
+
- test/test_mailer.rb
|
|
136
138
|
- test/test_sql_split.rb
|
|
137
|
-
- test/
|
|
139
|
+
- test/test_report.rb
|
|
138
140
|
- test/test_table_renderer.rb
|
|
139
|
-
- test/
|
|
140
|
-
- test/samples/
|
|
141
|
+
- test/samples/test.yaml
|
|
142
|
+
- test/samples/query_test.sql
|
|
141
143
|
- test/samples/data.csv
|
|
144
|
+
- test/samples/foo.rtxt
|
|
142
145
|
- test/samples/data.tsv
|
|
143
|
-
- test/samples/dates.csv
|
|
144
|
-
- test/samples/document.xml
|
|
145
146
|
- test/samples/erb_test.sql
|
|
146
|
-
- test/samples/foo.rtxt
|
|
147
|
-
- test/samples/query_test.sql
|
|
148
|
-
- test/samples/ruport_test.sql
|
|
149
147
|
- test/samples/stonecodeblog.sql
|
|
148
|
+
- test/samples/ruport_test.sql
|
|
149
|
+
- test/samples/addressbook.csv
|
|
150
|
+
- test/samples/dates.csv
|
|
151
|
+
- test/samples/document.xml
|
|
150
152
|
- test/samples/test.sql
|
|
151
|
-
- test/samples/test.yaml
|
|
152
153
|
- bin/rope
|
|
153
154
|
- Rakefile
|
|
154
155
|
- setup.rb
|
|
@@ -157,20 +158,20 @@ files:
|
|
|
157
158
|
- TODO
|
|
158
159
|
- AUTHORS
|
|
159
160
|
test_files:
|
|
160
|
-
- test/
|
|
161
|
-
- test/test_format_text.rb
|
|
162
|
-
- test/test_graph_renderer.rb
|
|
161
|
+
- test/test_record.rb
|
|
163
162
|
- test/test_groupable.rb
|
|
164
|
-
- test/
|
|
163
|
+
- test/test_table.rb
|
|
164
|
+
- test/test_graph_renderer.rb
|
|
165
|
+
- test/test_ruport.rb
|
|
166
|
+
- test/test_format_text.rb
|
|
165
167
|
- test/test_query.rb
|
|
166
|
-
- test/
|
|
168
|
+
- test/test_config.rb
|
|
169
|
+
- test/test_taggable.rb
|
|
167
170
|
- test/test_renderer.rb
|
|
168
|
-
- test/
|
|
169
|
-
- test/test_ruport.rb
|
|
171
|
+
- test/test_mailer.rb
|
|
170
172
|
- test/test_sql_split.rb
|
|
171
|
-
- test/
|
|
173
|
+
- test/test_report.rb
|
|
172
174
|
- test/test_table_renderer.rb
|
|
173
|
-
- test/test_taggable.rb
|
|
174
175
|
rdoc_options:
|
|
175
176
|
- --title
|
|
176
177
|
- Ruport Documentation
|