ruport 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/AUTHORS +6 -0
  2. data/Rakefile +4 -4
  3. data/TODO +3 -2
  4. data/bin/rope +2 -103
  5. data/examples/pdf_complex_report.rb +53 -0
  6. data/lib/ruport/config.rb +7 -7
  7. data/lib/ruport/data/collection.rb +8 -7
  8. data/lib/ruport/data/groupable.rb +3 -2
  9. data/lib/ruport/data/record.rb +13 -16
  10. data/lib/ruport/data/table.rb +89 -18
  11. data/lib/ruport/format/csv.rb +29 -0
  12. data/lib/ruport/format/html.rb +40 -0
  13. data/lib/ruport/format/latex.rb +50 -0
  14. data/lib/ruport/format/pdf.rb +78 -0
  15. data/lib/ruport/format/plugin.rb +20 -65
  16. data/lib/ruport/format/svg.rb +39 -0
  17. data/lib/ruport/format/text.rb +77 -0
  18. data/lib/ruport/format/xml.rb +32 -0
  19. data/lib/ruport/format.rb +1 -159
  20. data/lib/ruport/generator.rb +158 -0
  21. data/lib/ruport/layout/component.rb +7 -0
  22. data/lib/ruport/layout.rb +1 -0
  23. data/lib/ruport/query.rb +3 -3
  24. data/lib/ruport/renderer/graph.rb +48 -0
  25. data/lib/ruport/renderer/table.rb +132 -0
  26. data/lib/ruport/renderer.rb +193 -0
  27. data/lib/ruport/report/graph.rb +2 -2
  28. data/lib/ruport/report.rb +94 -96
  29. data/lib/ruport/system_extensions.rb +3 -6
  30. data/lib/ruport.rb +6 -4
  31. data/test/samples/dates.csv +1409 -0
  32. data/test/samples/foo.rtxt +3 -0
  33. data/test/test_collection.rb +0 -14
  34. data/test/test_config.rb +6 -6
  35. data/test/test_graph_renderer.rb +97 -0
  36. data/test/test_groupable.rb +1 -0
  37. data/test/test_query.rb +325 -324
  38. data/test/test_record.rb +3 -2
  39. data/test/test_renderer.rb +74 -0
  40. data/test/test_report.rb +29 -26
  41. data/test/test_table.rb +54 -29
  42. data/test/test_table_renderer.rb +93 -0
  43. data/test/test_text_table.rb +61 -0
  44. data/test/unit.log +24 -0
  45. metadata +41 -63
  46. data/CHANGELOG +0 -587
  47. data/examples/basic_grouping.rb +0 -19
  48. data/examples/fieldless_table.rb +0 -13
  49. data/examples/latex_table.rb +0 -17
  50. data/examples/line_graph.rb +0 -22
  51. data/examples/line_graph_report.rb +0 -23
  52. data/examples/line_plotter.rb +0 -46
  53. data/examples/long.txt +0 -24
  54. data/examples/new_plugin.rb +0 -24
  55. data/examples/report.rb +0 -35
  56. data/examples/sample_invoice_report.rb +0 -32
  57. data/examples/simple_mail.rb +0 -15
  58. data/examples/simple_table_interface.rb +0 -20
  59. data/examples/sql_erb.rb +0 -20
  60. data/examples/template.rb +0 -15
  61. data/examples/text_processors.rb +0 -13
  62. data/lib/ruport/format/engine/document.rb +0 -28
  63. data/lib/ruport/format/engine/graph.rb +0 -18
  64. data/lib/ruport/format/engine/invoice.rb +0 -23
  65. data/lib/ruport/format/engine/table.rb +0 -54
  66. data/lib/ruport/format/engine.rb +0 -108
  67. data/lib/ruport/format/plugin/csv_plugin.rb +0 -26
  68. data/lib/ruport/format/plugin/html_plugin.rb +0 -32
  69. data/lib/ruport/format/plugin/latex_plugin.rb +0 -50
  70. data/lib/ruport/format/plugin/pdf_plugin.rb +0 -126
  71. data/lib/ruport/format/plugin/svg_plugin.rb +0 -61
  72. data/lib/ruport/format/plugin/text_plugin.rb +0 -77
  73. data/lib/ruport/meta_tools.rb +0 -66
  74. data/lib/ruport/report/invoice.rb +0 -29
  75. data/test/_test_groupable.rb +0 -0
  76. data/test/test_format.rb +0 -39
  77. data/test/test_format_engine.rb +0 -264
  78. data/test/test_graph.rb +0 -93
  79. data/test/test_invoice.rb +0 -32
  80. data/test/test_latex.rb +0 -20
  81. data/test/test_meta_tools.rb +0 -14
  82. data/test/test_plugin.rb +0 -277
  83. data/test/ts_all.rb +0 -21
data/CHANGELOG DELETED
@@ -1,587 +0,0 @@
1
- The current version of Ruby Reports is 0.6.1
2
-
3
- changes since 0.6.0
4
-
5
- - Fixed Table.load() bug. (Now accepts block properly)
6
- - 100% C0 coverage for Query via Mocha. (Thanks Marshall!)
7
- - Row by row Query iteration no longer grabs entire result set first
8
- - Major performance enhancements to Groupable
9
- - Reformatted and enhanced API documentation
10
- - Added simple table interface example
11
-
12
- changes since 0.5.4
13
-
14
- From Ruport News (http://www.stonecode.org/blog/?cat=14)
15
-
16
- * added ERb support inside SQL queries
17
- * a new LaTeX plugin for the table formatting engine
18
- * support for summation in data tables
19
- * new grouping functionality based on the tagging system
20
- * very large performance enhancements in HTML and text rendering
21
- * better integration with FasterCSV
22
- * some simple interfaces for graphs and data tables
23
- * syntactic sugar (shortcuts) for common tasks
24
- * support for rerunning reports on timeouts and errors
25
-
26
- changes since 0.5.3
27
-
28
- - Fixed a bug where Table#<< would fail silently if an object could not be
29
- converted to a Record
30
-
31
- - Fixed a bug where setting column names after a table was initialized without
32
- them caused Table to break.
33
-
34
- - Example added for basic grouping functionality
35
-
36
- - Table#column_names= reworked to address a performance concern.
37
-
38
- - Collection#[] moved to Table#[], since Set#[] is not implemented.
39
-
40
- - Quieted some warnings discovered by pat eyler
41
-
42
- changes since 0.5.2
43
-
44
- - Fixed a bug in Format Engine which required a data attribute to be specified.
45
- (will still provide an accessor for this, but no more do you *need* it)
46
-
47
- - Fixed a bug in rope's build.rb that prevented generation of multiple reports.
48
-
49
- - Fixed a bug in the way reorder() was working that was causing many
50
- unneccessary copies of column_names to be made
51
-
52
- - Fixed a bug in TextPlugin that caused it to throw an error when trying to
53
- print an empty table. (Now returns empty string)
54
-
55
- - Since Plugin#rendering_options and Plugin#options serve a different purpose
56
- and when combined, cause problems, they have been split out into two different
57
- instance variables. This does not effect their intended use from the
58
- interface side.
59
-
60
- changes since 0.5.1
61
-
62
- - Fixed a bug in our requires
63
-
64
- changes since 0.5.0
65
-
66
- - Broke plugins and engines out into their own files
67
-
68
- - Fixed a bug which prevented TextPlugin from working right in Windows
69
-
70
- changes since 0.4.99
71
-
72
- - SVG::Graph has been dropped in favor of Scruffy for graphing support.
73
-
74
- - You can now define helpers for specific engines.
75
-
76
- - All known obsolete documentation has been removed
77
-
78
- - Collection#as now takes a block (Making it work like DataSet#as used to)
79
-
80
- - Some cleanup and fixes to examples/
81
-
82
- changes since 0.4.23
83
-
84
- - Removed the legacy Format::Document|Element|Page|OpenNode classes
85
-
86
- - Added lots of API documentation
87
-
88
- - actions now will throw an error if they are already defined.
89
- (Temporary collision remedy)
90
-
91
- - You can now dup Sets
92
-
93
- - Unit tests should no longer explode when PDF::Writer is not installed
94
-
95
- - Added a simplistic Rake task for building the recipe book
96
-
97
- - Added intuitive error message for invalid plugins
98
-
99
- - Fixed an error in Tag duplication for Data::Record
100
-
101
- - Ruport now has charting support via SVG::Graph
102
-
103
- - reordering now has intuitive error messages
104
-
105
- - Trimmed down system_extensions.rb to only include the relevant terminal
106
- geometry code
107
-
108
- - Record/Table reordering can now be expressed either as a splatted list or an
109
- array. Eg %w[a b c] and "a","b","c" are both acceptable as arguments.
110
-
111
- changes since 0.4.21
112
-
113
- - JH's invoice engine integrated
114
-
115
- - Added rope, a tool for building a friendly environment for reports that use
116
- Ruport.
117
-
118
- - Fixed very broken Ruport::Query (DataSet aftermath)
119
- We need to figure out a way to test this class better.
120
-
121
- - Added Data::Table#add_column which is useful for calculated fields. (#19)
122
-
123
- - Data::Table.reorder now works properly.
124
- (Can use integer indices or attributes)
125
-
126
- - Moved Data::Table.to_format to Collection, but be warned that the plugins must
127
- support the collection you call them on. (Set is not fully supported yet)
128
-
129
- - Renamed Query#to_dataset to Query#to_table
130
-
131
- - Array#to_table now supports just passing an array of column_names if you do
132
- not need other keyword arguments. This makes the interface support to_ds
133
- style calls.
134
-
135
- changes since 0.4.19
136
- - Added a rake task to run rcov
137
-
138
- - Removed DataSet / DataRow. Farewell good friends
139
-
140
- - Added Array#to_table, dropped Array#to_ds
141
-
142
- - You can now convert Sets to Tables and vice-versa
143
-
144
- - acts_as_reportable converted to use Data::Table
145
-
146
- - Data::Record's constructor can now take a hash
147
-
148
- - Added initial Data::Set implementation
149
-
150
- - Added smart Data::Table.to_format method_missing functionality
151
-
152
- changes since 0.4.17
153
-
154
- - Made method_missing a lot more friendly all around.
155
-
156
- - Made minor interface changes.
157
-
158
- - Data::Table and Data::Record now dup correctly
159
-
160
- - Fixed some serious issues between Data::Table and TextPlugin
161
-
162
- - Report#eval_template now returns an ERb string instead of printing to STDOUT
163
-
164
- - Added Data::Table#split which allows basic grouping operations
165
-
166
- - Added Report#load_csv convenience method
167
-
168
- - Tightened up Data::Table#<< to ensure column_names match record attributes
169
-
170
- - Fixed appending a Record in Data::Table#<<
171
-
172
- changes since 0.4.15
173
-
174
- - Fixed a packaging bug
175
-
176
- changes since 0.4.13
177
-
178
- - Began building a new data handling system, which is much faster than
179
- DataSet/DataRow and takes up less memory. It is also very young, though.
180
- (See Data::Table and Data::Record)
181
-
182
- - Added init_plugin hooks
183
-
184
- - Added DataSet#rename_columns
185
-
186
- - Added taggable mixin
187
-
188
- - Added an options accessor to help solve ticket #8
189
-
190
- - Alioth now has a powerful hook back into the engine from plugins via helpers
191
-
192
- - added action / attribute methods for format engine / plugin via MetaTools
193
-
194
- - added accessor style methods to DataRow via method_missing
195
-
196
- - added prune method for Table formatting.
197
-
198
- changes since 0.4.11
199
-
200
- - Added high level hook Report#text_processor which essentially works like
201
- Format.register_filter
202
-
203
- - Report can now run single or multiple reports and do things such as send them
204
- via email or write/append them to files.
205
-
206
- - Report has been overhauled to have a simple DSL
207
-
208
- - Mailfactory is now a gem dependency. If you install via setup.rb or building
209
- the gem yourself, you only need it if you plan to use Ruport::Mailer
210
-
211
- - Report#query now has an 'as' method that allows direct translation of a query
212
- to a particular format, e.g.
213
-
214
- query "select * from ruport", :as => :pdf
215
-
216
- - Lots of bug fixes and cleanup
217
-
218
- - Ruport is now on Trac.
219
- http://stonecode.svnrepository.com/ruport/
220
-
221
- - I apparently never knew how to use inject.
222
- Injects are all functional now.
223
-
224
- - Fixed a bug in DataSet that made fields not get duped properly
225
-
226
- changes since 0.4.9
227
-
228
- - DataSet#column_names and DataRow#column_names have been added as alias to
229
- fields.
230
-
231
- - Plugins are now safely copied when used via DataSet#as or the generated
232
- Format::simple_interface(Format.table,Format.document,etc)
233
-
234
- - Dropped insert_row / insert_column from Format::Engine::Table.
235
- These are no longer needed.
236
-
237
- - Reworked format engine unit tests to decouple from specific plugins.
238
-
239
- - vendored SystemExtensions from HighLine to get terminal_width /
240
- terminal_height functions
241
-
242
- - DataSet#add_columns and DataSet#add_columns! has been added
243
-
244
- - Added pre and post hooks for Plugins. Individual plugins choose if and
245
- how to implement them.
246
-
247
- - Parser is gone
248
-
249
- - Format::Builder is gone
250
-
251
- - fixed a bug in rails support. :columns now works properly.
252
-
253
- - fieldnames can now be disabled in CSV loading
254
-
255
- - DataSet.load now loads empty cells as nil instead "" by default
256
-
257
- - fixed HTML table output in HTMLPlugin
258
-
259
- - Select / Remove columns now accepts ordinal indexes
260
-
261
- changes since 0.4.5:
262
-
263
- - Added acts_as_reportable for ActiveRecord / rails. whoo
264
-
265
- - Mailer now can handle attachments and html emails.
266
- API Breakage. Needs mailfactory unless you use the hooks for other
267
- mailers.
268
-
269
- - Added a rewrite_column action to the tabular engine
270
-
271
- - Added Ruport.configure shortcut interface
272
-
273
- - went back to the old style of output for DataSet.to_s
274
- Modified TextPlugin to accomplish this
275
-
276
- - Crackrock feature: Engine forwards enumerable methods to it's data.
277
-
278
- - DataSets and DataRows can now be created without specifying field names.
279
-
280
- - Added uport.rb . I needed to steal from RubyGems :)
281
-
282
- - Fixed some requires
283
-
284
- - Temporarily removed mail support from Ruport::Report
285
-
286
- - Added Ruport::Mailer#deliver simple mail interface
287
-
288
- - Ruport::Report::Mailer is now Ruport::Mailer
289
-
290
- changes since 0.4.4:
291
-
292
- - DataRow constructor now matches DataSet style.
293
-
294
- - DataSet picked up a ton of array-like functionality
295
-
296
- - DataSet#load now optionally accepts a block that acts something
297
- like inject.
298
-
299
- - Added a DataSet#select_columns!() method
300
-
301
- - What the heck was Format#filter_ruby? It's gone now
302
-
303
- - DataSet#as() now hooked to the new formatting system.
304
- note API breakage in block forms
305
-
306
- - DataSet set operations (DF)
307
-
308
- - Much smarter DataSet#<< (Dudley Flanders)
309
-
310
- - Ruport now has pseudo keyword support in DataSets.
311
- (Thanks to Dudley Flanders!)
312
-
313
- changes since 0.4.2:
314
-
315
- - Fixed a packaging bug.
316
-
317
- changes since 0.4.0:
318
-
319
- - Brand new formatting system.
320
- See: http://ruport.infogami.com/Formatting_System_HOWTO
321
-
322
- - DataSet#<< now returns self, e.g.
323
- some_data << [1,2,3] << [4,5,6]
324
-
325
- - Removed fascist opt_require feature and Ruport::Base
326
-
327
- - Fixed bug in DataRow constructor which destroyed arrays.
328
-
329
- - Examples now included in gems
330
-
331
- changes since 0.3.8:
332
-
333
- - added DataRow#to_h
334
-
335
- - Ruport::Format.register_filter now passes the content it will modify via a
336
- block. e.g.
337
-
338
- Ruport::Format.register_filter :reverser { |content| content.reverse }
339
-
340
- - Modified the license terms of Ruport so that it uses specifically the GPLv2.
341
- Further versions of Ruport may not be distributed under later versions of the
342
- GPL without explicit permission.
343
-
344
- - DataSet#[]= now passes rvals to DataRow constructor with fields from the
345
- DataSet it is called on.
346
-
347
- - Optional dependencies should now be forceably protected by opt_require.
348
-
349
- - Fixed a problem with Ruport.complain that caused it to force you to use a
350
- logger to make it work.
351
-
352
- - DataRow#eql? is fixed and now has a test covering it.
353
-
354
- - DataRow/DataSet can now be dup'ed / cloned
355
- (But may still have some dragons)
356
-
357
- - DataRow#+ now returns DataRows instead of arrays
358
-
359
- - Format::Builder rendering methods can now be registered through
360
- Format::Builder.register_rendering_method()
361
-
362
- - DataRow["somekeythatdoesntexist"] no longer throws an error
363
- (now returns nil)
364
-
365
- - Now some_data_row[:foo] and some_data_row["foo"] are equivalent
366
-
367
- - Fixed Query so it throws appropriate errors. No more magic nil. (I hope)
368
-
369
- - Ruport::Config.default_source now defaults to nil
370
-
371
- - Ruport::Config now has improved error detection.
372
-
373
- - additional Test coverage, documentation and logging.
374
-
375
- - DataSet#sigma (a.k.a DataSet#sum) added for summations.
376
-
377
- - Format::Builder#render_pdf renamed to Format:Builder#render_pdf_document
378
-
379
- - Format::Builder#render_pdf_table added. (Thanks Simon Claret!)
380
-
381
- - Fixed bug in remove_columns
382
-
383
- key features of Ruport 0.3.8:
384
-
385
- - New configuration system
386
-
387
- - New query model
388
-
389
- - New formatting system
390
-
391
- - Total API redesign
392
-
393
- - Lots more API documentation
394
-
395
- - A parser adapted from Parse::Input
396
-
397
- - ruport executable was deprecated
398
-
399
- [ Code was redesigned completely after 0.2.9 ]
400
-
401
- changes since Ruport 0.2.9:
402
-
403
- - Report::SQL dropped.
404
-
405
- - Fixed a bug in query that made ODBC driver not work at ALL!
406
- (AFAIK, this bug was ONLY in Ruport 0.2.9)
407
-
408
- - removed render() from the engine and implemented DataSet#render_as()
409
- example:
410
- @report = render(data) do |builder| builder.format = :some_format end
411
- is now: @report = data.render_as(:some_format)
412
- which takes an optional block that works as before.
413
-
414
- - removed method DataSet#select_field() because it was the same as
415
- DataSet#select_fields() and of limited utility.
416
-
417
- - added method DataSet#remove_fields and DataSet#remove_fields!
418
- to make data manipulation easier.
419
-
420
- - added DataSet#empty?
421
-
422
- - added DataSet#clone which will actually deep copy a DataSet.
423
-
424
- - cleaned up incredibly annoying DataSet constructor so you can now pass
425
- field names and data to new()
426
-
427
- - Report::DataSet now documented
428
-
429
- - added hacks.rb which will include a random collection of potentially
430
- useful functions. (Already cool for making Ruport easy to use with irb).
431
-
432
- - added Document class and unit tests. Needs to be completed.
433
-
434
- - added Report::DataSet.clone for making deep copies of DataSets.
435
-
436
- - added Element, Section, Page, and Document formatting classes.
437
-
438
- - restructured unit tests, adding ts_format and ts_report
439
- and moving all non-testcase data into test/samples
440
-
441
- - restuctured library, adding ruport/format.rb and ruport/report.rb
442
- made format and report into classes, with nested classes within.
443
-
444
- - Moved the Report::Engine class into Report
445
-
446
- - reorginized DataSet#<< to be more efficient. Thanks Francis!
447
-
448
- - added OpenNode. Which is a little scary.
449
-
450
- - Francis Hwang has added SqlSplit, which has been tied into query.
451
- Now multiple statement SQL dumps can be processed by ruport.
452
-
453
- - DataSet can now safely execute commands that return no rows.
454
- (This was a bug in RubyDBI which ruport now has a workaround for)
455
-
456
- - require "ruportlib" becomes require "ruport"
457
-
458
-
459
- changes since Ruport 0.2.5:
460
-
461
- - Added a new examples package with a 666 line walkthrough and more enjoyable
462
- demonstratons
463
-
464
- - Added support for multiple DSN's via add_dsn and select_dsn
465
-
466
- - Added Tagging support for DataSets.
467
-
468
- - Added DataSet#select_field and DataSet#select_fields to simplify grabbing
469
- data by column
470
-
471
- - Report::DataSet now implements to_s, for pretty printing goodness.
472
-
473
- - render_text now implemented in Format::Builder
474
-
475
- - Format::Builder now accepts headers and footers.
476
-
477
- - Format::Builder now can generate complete html via output_type
478
-
479
- - Ruport now uses FasterCSV, which is now a dependency. Yay! Dependencies!
480
- (But it IS 9x faster than the CSV lib that ships with Ruby)
481
-
482
- - Added tests to the gem spec... so you can use -t now.
483
-
484
- - DataRow#+ implemented.
485
-
486
- - Format::Builder#range implemented. (Can now format partial DataSets)
487
-
488
- - Fixed a bug in the unit tests that required Ruport to be installed.
489
- Now you can test BEFORE you install. (Sorry about that one...)
490
-
491
- - Commands that return no rows no longer crash the application
492
- (But writing to the database is still not fun nor easy)
493
-
494
- - templates/ folder now more aptly named scripts/
495
-
496
- - Report::Engine#query now returns a DataSet so chaining is possible
497
-
498
- changes since Ruport 0.2.2:
499
-
500
- - Report::DataSet and Report::DataRow are now enumerable
501
-
502
- - DataSet#eql? fixed
503
-
504
- - Format::Builder has been added to handle formatting
505
- (Supports CSV / HTML currently)
506
-
507
- - Format::Builder is easily extendable via send("render_#{@type}")
508
-
509
- - DataSet#to_html convenience method added
510
-
511
- - DataSet#fields can now be arbitrary objects (does not need to be Strings)
512
-
513
- - Dropped DataRow#middle? because it was useless. (And poorly named)
514
-
515
- - FakeMailer added for testing goodness.
516
-
517
- - Dropped select() and execute() in favor of query()
518
-
519
- changes since Ruport 0.2.0:
520
-
521
- - Report becomes Engine
522
- - MockDB becomes FakeDB
523
- - MockReport becomes MockEngine
524
-
525
- - Modules are added so now,
526
-
527
- Ruport::Report::Engine,
528
- Ruport::Report::DataSet is the full name of these classes.
529
-
530
- - 'require ruportlib' runs include Ruport,
531
- so you can type Report::Engine.new instead of Ruport::Report::Engine.new
532
-
533
- - The assert that was supposed to be an assert_equal that
534
- David Black caught was fixed.
535
-
536
- - Examples are updated and now on the RubyForge FRS in many formats.
537
- (With .DS_Store and other garbage files removed! ;) )
538
-
539
- - Formatting of code was cleaned up and improved.
540
-
541
- - Generates a test.rb that does not use deprecated functions now.
542
-
543
- changes since Ruport 0.1.0:
544
-
545
- CLEANUP / ORGANIZATION:
546
-
547
- - Parseinput dependency removed for now
548
-
549
- - setup.rb support removed
550
-
551
- - gem install will now only install a single executable
552
-
553
- - dropped undocumented YAML override feature
554
-
555
- - Query class now called Report
556
-
557
- - Project split into two parts lib/ruport/db and lib/ruport/format
558
-
559
- - dropped questionable ruport_query manager function
560
-
561
- - finally turned on expandtab and tabstop=2 for Ruby style ;)
562
-
563
- FEATURES:
564
-
565
- - require 'ruportlib' lets ruport be used as a library
566
-
567
- - MockDB and MockReport added to simplify testing
568
-
569
- - DataRow and DataSet added to provide munging with ease
570
- (to_csv, DataSet.load("some.csv"), etc
571
-
572
- - DataSet.load() can restore DataSet's that were YAML.dump()'ed
573
-
574
- - load_file now supports absolute and relative paths
575
-
576
- - added many automation features to templates
577
-
578
- - added @pre and @post to Report which accept lambdas to execute
579
- before and after generate_report()
580
-
581
- - logger added.
582
-
583
- - some friendly error messages added
584
-
585
- - new method query() will eventually replace select() / execute()
586
-
587
- - {examples}[http://ruport.rubyforge.org/] available for download
@@ -1,19 +0,0 @@
1
- require "ruport"
2
- a = [ ['a',7],['b',5],['c',11],
3
- ['d',9],['a',3],['b',2], ['e',4] ].to_table(%w[letter num])
4
- puts "Initial Data:\n#{a}"
5
-
6
-
7
- # group by column values
8
- b = a.split(:group => "letter")
9
- totals = [].to_table(%w[group sum])
10
- b.each_group { |x| totals << [x,b[x].sum("num")] }
11
- puts "After column grouping:\n#{totals}"
12
-
13
- # group by tag name
14
- a.create_tag_group(:num_even) { |r| (r.num % 2).zero? }
15
- a.create_tag_group(:num_odd) { |r| (r.num % 2).nonzero? }
16
- c = a.group_by_tag
17
- totals.data.clear
18
- c.each_group { |x| totals << [x,c[x].sum("num")] }
19
- puts "After tag grouping:\n#{totals}"
@@ -1,13 +0,0 @@
1
- require "ruport"
2
- include Ruport
3
-
4
- # this shows how you can create your own plugin with some default rendering
5
- # options as a shortcut.
6
-
7
- class Format::Plugin::FieldlessCSVPlugin < Format::Plugin::CSVPlugin
8
- rendering_options :show_field_names => false
9
- plugin_name :fieldless_csv
10
- register_on :table_engine
11
- end
12
-
13
- puts [[1,2,3]].to_table(%w[a b c]).to_fieldless_csv
@@ -1,17 +0,0 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../lib/")
2
- require "ruport"
3
-
4
- # build up a Table - this could be built in a range of ways
5
- # Check the API documentation and recipe book for more information
6
- data = [[1,4,7,9], [6,2,3,0]].to_table(%w[a b c d])
7
-
8
- # Build the report object
9
- report = Ruport::Format.table_object(:plugin => :latex, :data => data)
10
-
11
- # By default, the latex plugin will return plain text latex source
12
- # changing the format option asks Ruport to attempt to render
13
- # the source into a PDF using pdflatex
14
- report.options = { :format => :pdf }
15
-
16
- # save the resulting report to a file on the filesystem
17
- File.open( "table.tex","w") { |f| f.puts report.render }
@@ -1,22 +0,0 @@
1
- $: << File.dirname(__FILE__) + "/../lib/"
2
- require "ruport"
3
-
4
- # Start with a Ruport::Table object. This could easily come from
5
- # activerecord or any of the other ways to build a Table. See the ruport
6
- # recipes book for some ideas
7
- data = [[5, 7, 9, 12, 14, 16, 18]].to_table(%w[jan feb mar apr may jun jul])
8
-
9
- # initialize the graph with our table object
10
- graph = Ruport::Format.graph_object :plugin => :svg, :data => data
11
-
12
- # there are currently only a handful of options for customising the
13
- # appearance of the graph. The ones listed here are all of them at
14
- # the current time.
15
- graph.width = 700
16
- graph.height = 500
17
- graph.title = "A Simple Line Graph"
18
- graph.style = :line # other options: bar, smiles, area, stacked
19
-
20
- # render the graph and print it to stdout. To save the output to a file, try:
21
- # ruby line_graph.rb > pirates.svg
22
- puts graph.render
@@ -1,23 +0,0 @@
1
- require "ruport"
2
- class GraphSample < Ruport::Report
3
-
4
- include Graph
5
-
6
- prepare do
7
- @data = [[5,7,9,12,14,16,18]].to_table(%w[jan feb mar apr may jun jul])
8
- end
9
-
10
- generate do
11
- render_graph do |g|
12
- g.data = @data
13
- g.width = 700
14
- g.height = 500
15
- g.title = "A Simple Line Graph"
16
- g.style = :line
17
- end
18
- end
19
- end
20
-
21
- GraphSample.run { |r| puts r.results }
22
-
23
-