ruport 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/AUTHORS CHANGED
@@ -35,9 +35,11 @@ Daniel Berger:
35
35
  Marshall T. Vandegrift:
36
36
  - Fixed a bug in Record's struct-like accessors (method_missing)
37
37
  - Provided performance enhancements and tests for query.rb
38
+ - Improved alignment for Text Tables.
38
39
 
39
40
  Stefan Mahlitz:
40
41
  - Table#sort_rows_by
41
42
 
42
- llasram@gmail.com
43
- - Improved alignment for Text Tables.
43
+ Mike Milner:
44
+ - mock object for Mailer
45
+ - mock objects for Report (#130)
data/README CHANGED
@@ -109,14 +109,14 @@
109
109
  # up to date information.
110
110
  #
111
111
  # - You can sign up and/or view the archives here:
112
- # http://stonecode.svnrepository.com/ruport/trac.cgi/browser/trunk/test/test_table.rb
112
+ # http://groups.google.com/group/ruby-reports
113
113
  #
114
114
  # Please do not hesitate to use this list! I am happily accepting patches and
115
115
  # documentation, as well as encouraging design discussions and also am quite
116
116
  # curious about what people use or want to use ruport for.
117
117
  #
118
118
  # I will announce Ruport releases on RubyTalk, on the Ruport mailing list, on
119
- # Freshmeat, and RAAt. If you would like to
119
+ # Freshmeat, and RAA. If you would like to
120
120
  # keep an eye out for releases, please monitor one of those places.
121
121
  #
122
122
  # - You may download Ruport's source from the project page:
@@ -125,7 +125,8 @@
125
125
  # - The latest stable API documentation is available at:
126
126
  # http://reporting.stonecode.org/docs
127
127
  #
128
- # There also will be some tutorials on rubyreports.org
128
+ # There are also some tutorial available:
129
+ # http://stonecode.svnrepository.com/ruport/trac.cgi/wiki/TutorialsAndArticles
129
130
  #
130
131
  # If you are interested in developing Ruport, please *never* study code in
131
132
  # official releases. As this software is in it's early stages, it's essential
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.7.1"
26
+ spec.version = "0.7.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}/**/**/*") +
data/lib/ruport.rb CHANGED
@@ -9,12 +9,10 @@
9
9
  #
10
10
  # See LICENSE and COPYING for details
11
11
  #
12
-
13
12
  module Ruport
14
13
 
15
- VERSION = "0.7.1"
14
+ VERSION = "0.7.2"
16
15
 
17
- #
18
16
  # This method is Ruport's logging and error interface. It can generate
19
17
  # warnings or raise fatal errors, logging +message+ to the file defined by
20
18
  # <tt>Config::log_file</tt>.
@@ -54,7 +52,6 @@ module Ruport
54
52
  # Alias for <tt>Ruport.log</tt>.
55
53
  def self.complain(*args); Ruport.log(*args) end
56
54
 
57
- #
58
55
  # This method yields a <tt>Ruport::Config</tt> object, allowing you to
59
56
  # set the configuration options for your application.
60
57
  #
data/lib/ruport/config.rb CHANGED
@@ -11,7 +11,7 @@
11
11
  #
12
12
  require "ostruct"
13
13
  module Ruport
14
- #
14
+
15
15
  # === Overview
16
16
  #
17
17
  # This class serves as the configuration system for Ruport.
@@ -29,7 +29,7 @@ module Ruport
29
29
  # Ruport.configure do |config|
30
30
  #
31
31
  # config.log_file 'foo.log'
32
- # config.enable_paranoia
32
+ # config.debug_mode = true
33
33
  #
34
34
  # config.source :default,
35
35
  # :dsn => "dbi:mysql:somedb:db.blixy.org",
@@ -69,7 +69,7 @@ module Ruport
69
69
  #
70
70
  module Config
71
71
  module_function
72
- #
72
+
73
73
  # :call-seq:
74
74
  # source(source_name, options)
75
75
  #
@@ -96,13 +96,12 @@ module Ruport
96
96
  check_source(sources[args.first],args.first)
97
97
  end
98
98
 
99
- #
100
99
  # :call-seq:
101
100
  # mailer(mailer_name, options)
102
101
  #
103
102
  # Creates or retrieves a mailer configuration. Available options:
104
103
  # <b><tt>:host</tt></b>:: The SMTP host to use.
105
- # <b><tt>:address</tt></b>:: The email address to send to.
104
+ # <b><tt>:address</tt></b>:: Address the email is being sent from.
106
105
  # <b><tt>:user</tt></b>:: The username to use on the SMTP server
107
106
  # <b><tt>:password</tt></b>:: The password to use on the SMTP server.
108
107
  # Optional.
@@ -160,12 +159,7 @@ module Ruport
160
159
  # Returns the currently active logger.
161
160
  def logger; @logger; end
162
161
 
163
- # Forces all messages marked <tt>:log_only</tt> to print anyway.
164
- # def enable_paranoia; @paranoid = true; end
165
-
166
- # Disables the printing of <tt>:log_only</tt> messages.
167
- #def disable_paranoia; @paranoid = false; end
168
-
162
+ # returns true if in debug mode
169
163
  def debug_mode?; !!@debug_mode; end
170
164
 
171
165
  # Verifies that you have provided a DSN for your source.
@@ -190,6 +184,7 @@ module Ruport
190
184
  end
191
185
  end
192
186
 
187
+ # forces messages with :level of :log_only to be printed
193
188
  def debug_mode=(something)
194
189
  @debug_mode = !!something
195
190
  end
@@ -6,7 +6,6 @@
6
6
 
7
7
  module Ruport::Data
8
8
 
9
- #
10
9
  # === Overview
11
10
  #
12
11
  # This is the base class for Ruport's Data structures. It mixes in the
@@ -26,8 +25,14 @@ module Ruport::Data
26
25
  # A simple formatting tool which allows you to quickly generate a formatted
27
26
  # table from a <tt>Collection</tt> object.
28
27
  #
29
- # Example:
28
+ # If given a block, the Renderer::Table object will be yielded
29
+ #
30
+ #
31
+ # Examples:
32
+ #
30
33
  # my_collection.as(:csv) #=> "1,2,3\n4,5,6"
34
+ #
35
+ # my_collection.as(:csv) { |e| e.layout.show_table_headers = false }
31
36
  def as(type)
32
37
  Ruport::Renderer::Table.render(type) do |rend|
33
38
  rend.data = self
@@ -47,6 +52,7 @@ module Ruport::Data
47
52
 
48
53
  # Provides a shortcut for the <tt>as()</tt> method by converting a call to
49
54
  # <tt>as(:format_name)</tt> into a call to <tt>to_format_name</tt>
55
+ #
50
56
  def method_missing(id,*args)
51
57
  return as($1.to_sym) if id.to_s =~ /^to_(.*)/
52
58
  super
@@ -8,7 +8,6 @@ module Ruport::Data
8
8
  #
9
9
  module Groupable
10
10
 
11
- #
12
11
  # Creates a <tt>Record</tt> made up of <tt>Table</tt>s containing all the
13
12
  # records in the original table with the same tag.
14
13
  #
@@ -54,7 +53,6 @@ module Ruport::Data
54
53
  end; r
55
54
  end
56
55
 
57
- #
58
56
  # Tags each row of the <tt>Table</tt> for which the <tt>block</tt> is not
59
57
  # false with <tt>label</tt>.
60
58
  #
@@ -5,7 +5,6 @@
5
5
  # Copyright 2006 by respective content owners, all rights reserved.
6
6
  module Ruport::Data
7
7
 
8
- #
9
8
  # === Overview
10
9
  #
11
10
  # Data::Records are the work horse of Ruport's data model. These can behave
@@ -18,7 +17,6 @@ module Ruport::Data
18
17
  include Enumerable
19
18
  include Taggable
20
19
 
21
- #
22
20
  # Creates a new Record object. If the <tt>:attributes</tt>
23
21
  # keyword is specified, Hash-like and Struct-like
24
22
  # access will be enabled. Otherwise, Record elements may be
@@ -64,7 +62,6 @@ module Ruport::Data
64
62
 
65
63
  def_delegators :@data,:each, :length
66
64
 
67
- #
68
65
  # Allows either Array or Hash-like indexing.
69
66
  #
70
67
  # Examples:
@@ -83,8 +80,6 @@ module Ruport::Data
83
80
  end
84
81
  end
85
82
 
86
-
87
- #
88
83
  # Allows setting a <tt>value</tt> at an <tt>index</tt>.
89
84
  #
90
85
  # Examples:
@@ -103,7 +98,6 @@ module Ruport::Data
103
98
  end
104
99
  end
105
100
 
106
- #
107
101
  # If <tt>attributes</tt> and <tt>data</tt> are equivalent, then
108
102
  # <tt>==</tt> evaluates to true. Otherwise, <tt>==</tt> returns false.
109
103
  #
@@ -115,7 +109,6 @@ module Ruport::Data
115
109
 
116
110
  alias_method :eql?, :==
117
111
 
118
- #
119
112
  # Converts a Record into an Array.
120
113
  #
121
114
  # Example:
@@ -125,7 +118,6 @@ module Ruport::Data
125
118
  #
126
119
  def to_a; @data.dup; end
127
120
 
128
- #
129
121
  # Converts a Record into a Hash. This only works if <tt>attributes</tt>
130
122
  # are specified in the Record.
131
123
  #
@@ -135,7 +127,6 @@ module Ruport::Data
135
127
  # a.to_h #=> {"a" => 1, "b" => 2}
136
128
  def to_h; Hash[*@attributes.zip(data).flatten] end
137
129
 
138
- #
139
130
  # Returns a copy of the <tt>attributes</tt> from this Record.
140
131
  #
141
132
  # Example:
@@ -145,7 +136,6 @@ module Ruport::Data
145
136
  #
146
137
  def attributes; @attributes.map { |a| a.to_s }; end
147
138
 
148
- #
149
139
  # Sets the <tt>attribute</tt> list for this Record.
150
140
  #
151
141
  # Example:
@@ -154,7 +144,6 @@ module Ruport::Data
154
144
  #
155
145
  attr_writer :attributes
156
146
 
157
- #
158
147
  # Allows you to change the order of or reduce the number of columns in a
159
148
  # Record.
160
149
  #
@@ -202,7 +191,6 @@ module Ruport::Data
202
191
  #FIXME: This does not take into account frozen / tainted state
203
192
  alias_method :clone, :dup
204
193
 
205
- #
206
194
  # Provides a unique hash value. If a Record contains the same data and
207
195
  # attributes as another Record, they will hash to the same value, even if
208
196
  # they are not the same object. This is similar to the way Array works,
@@ -212,7 +200,6 @@ module Ruport::Data
212
200
  (attributes.to_a + data.to_a).hash
213
201
  end
214
202
 
215
- #
216
203
  # Provides accessor style methods for attribute access.
217
204
  #
218
205
  # Example:
@@ -7,7 +7,6 @@ require 'set'
7
7
 
8
8
  module Ruport::Data
9
9
 
10
- #
11
10
  # === Overview
12
11
  #
13
12
  # This class is one of the core classes for building and working with data
@@ -23,7 +22,6 @@ module Ruport::Data
23
22
  #
24
23
  class Set < Collection
25
24
 
26
- #
27
25
  # Creates a new Set containing the elements of <tt>options[:data]</tt>.
28
26
  #
29
27
  # Example:
@@ -35,7 +33,6 @@ module Ruport::Data
35
33
  options[:data].each {|e| self << e} if options[:data]
36
34
  end
37
35
 
38
- #
39
36
  # Adds the given object to the Set and returns self.
40
37
  #
41
38
  # Example:
@@ -54,7 +51,6 @@ module Ruport::Data
54
51
  end
55
52
  alias_method :<<, :add
56
53
 
57
- #
58
54
  # Produces a shallow copy of the Set: the same data elements are
59
55
  # referenced by both the old and new Sets.
60
56
  #
@@ -73,7 +69,6 @@ module Ruport::Data
73
69
  end
74
70
  alias_method :clone, :dup
75
71
 
76
- #
77
72
  # Two Sets are equal if they contain the same set of objects.
78
73
  #
79
74
  # Example:
@@ -102,7 +97,6 @@ module Ruport::Data
102
97
  alias_method :union, :|
103
98
  alias_method :+, :|
104
99
 
105
- #
106
100
  # Returns a new Set containing the objects common to the two Sets.
107
101
  #
108
102
  # Example:
@@ -118,7 +112,6 @@ module Ruport::Data
118
112
  end
119
113
  alias_method :intersection, :&
120
114
 
121
- #
122
115
  # Returns a new Set containing those objects present in this Set but not
123
116
  # the other.
124
117
  #
@@ -135,7 +128,6 @@ module Ruport::Data
135
128
  end
136
129
  alias_method :difference, :-
137
130
 
138
- #
139
131
  # Returns a new Set containing those objects that are either in this Set
140
132
  # or the other Set but not in both.
141
133
  #
@@ -7,7 +7,6 @@
7
7
 
8
8
  module Ruport::Data
9
9
 
10
- #
11
10
  # === Overview
12
11
  #
13
12
  # This class is one of the core classes for building and working with data
@@ -24,7 +23,6 @@ module Ruport::Data
24
23
  class Table < Collection
25
24
  include Groupable
26
25
 
27
- #
28
26
  # Creates a new table based on the supplied options.
29
27
  # Valid options:
30
28
  # <b><tt>:data</tt></b>:: An Array of Arrays representing the
@@ -41,7 +39,7 @@ module Ruport::Data
41
39
  @data = []
42
40
  if options[:data]
43
41
  if options[:data].all? { |r| r.kind_of? Record }
44
- record_tags = options[:data].map { |r| r.tags }
42
+ record_tags = options[:data].map { |r| r.tags.dup }
45
43
  options[:data] = options[:data].map { |r| r.to_a }
46
44
  end
47
45
  options[:data].each { |e| self << e }
@@ -53,7 +51,6 @@ module Ruport::Data
53
51
  attr_reader :column_names
54
52
  def_delegator :@data, :[]
55
53
 
56
- #
57
54
  # Sets the column names for this table. <tt>new_column_names</tt> should
58
55
  # be an array listing the names of the columns.
59
56
  #
@@ -68,7 +65,6 @@ module Ruport::Data
68
65
  @column_names.replace(new_column_names.dup)
69
66
  end
70
67
 
71
- #
72
68
  # Compares this Table to another Table and returns <tt>true</tt> if
73
69
  # both the <tt>data</tt> and <tt>column_names</tt> are equal.
74
70
  #
@@ -88,7 +84,6 @@ module Ruport::Data
88
84
 
89
85
  alias_method :==, :eql?
90
86
 
91
- #
92
87
  # Uses Ruport's built-in text plugin to render this Table into a String
93
88
  #
94
89
  # Example:
@@ -101,7 +96,6 @@ module Ruport::Data
101
96
  as(:text)
102
97
  end
103
98
 
104
- #
105
99
  # Used to add extra data to the Table. <tt>other</tt> can be an Array,
106
100
  # Hash or Record.
107
101
  #
@@ -131,7 +125,6 @@ module Ruport::Data
131
125
  self
132
126
  end
133
127
 
134
- #
135
128
  # Used to combine two Tables. Throws an ArgumentError if the Tables don't
136
129
  # have identical columns.
137
130
  #
@@ -151,7 +144,6 @@ module Ruport::Data
151
144
  Table.new(:column_names => @column_names, :data => @data + other.data)
152
145
  end
153
146
 
154
- #
155
147
  # Reorders the columns that exist in the Table. Modifies this Table
156
148
  # in-place.
157
149
  #
@@ -179,7 +171,6 @@ module Ruport::Data
179
171
  }; self
180
172
  end
181
173
 
182
- #
183
174
  # Returns a copy of the Table with its columns in the requested order.
184
175
  #
185
176
  # Example:
@@ -193,7 +184,6 @@ module Ruport::Data
193
184
  dup.reorder!(*indices)
194
185
  end
195
186
 
196
- #
197
187
  # Adds an extra column to the Table. Available Options:
198
188
  #
199
189
  # <b><tt>:name</tt></b>:: The new column's name (required)
@@ -216,7 +206,6 @@ module Ruport::Data
216
206
  end; self
217
207
  end
218
208
 
219
- #
220
209
  # Removes a column from the Table. Any values in the specified column are
221
210
  # lost.
222
211
  #
@@ -244,7 +233,6 @@ module Ruport::Data
244
233
  reorder! column_names - [name]
245
234
  end
246
235
 
247
- #
248
236
  # Create a copy of the Table: records will be copied as well.
249
237
  #
250
238
  # Example:
@@ -259,7 +247,6 @@ module Ruport::Data
259
247
  return a
260
248
  end
261
249
 
262
- #
263
250
  # Loads a CSV file directly into a Table using the FasterCSV library.
264
251
  #
265
252
  # Example:
@@ -277,7 +264,6 @@ module Ruport::Data
277
264
  get_table_from_csv(:foreach, csv_file, options,&block)
278
265
  end
279
266
 
280
- #
281
267
  # Creates a Table from a CSV string using FasterCSV. See Table.load for
282
268
  # additional examples.
283
269
  #
@@ -306,7 +292,6 @@ module Ruport::Data
306
292
  end ; loaded_data
307
293
  end
308
294
 
309
- #
310
295
  # Allows you to split Tables into multiple Tables for grouping.
311
296
  #
312
297
  # Example:
@@ -369,7 +354,6 @@ module Ruport::Data
369
354
  end; rec
370
355
  end
371
356
 
372
- #
373
357
  # Calculates sums. If a column name or index is given, it will try to
374
358
  # convert each element of that column to an integer or float
375
359
  # and add them together.
@@ -401,7 +385,6 @@ module Ruport::Data
401
385
 
402
386
  alias_method :sum, :sigma
403
387
 
404
- #
405
388
  # Returns a sorted table. If col_names is specified,
406
389
  # the block is ignored and the table is sorted by the named columns. All
407
390
  # options are used in constructing the new Table (see Array#to_table