ruport 1.2.3 → 1.4.0

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.
@@ -4,38 +4,36 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "helpers")
4
4
  class TestRenderTextTable < Test::Unit::TestCase
5
5
 
6
6
  def setup
7
- Ruport::Formatter::Template.create(:simple) do |t|
8
- t.table_format = {
7
+ Ruport::Formatter::Template.create(:simple) do |format|
8
+ format.table = {
9
9
  :show_headings => false,
10
10
  :width => 50,
11
11
  :ignore_width => true
12
12
  }
13
- t.column_format = {
13
+ format.column = {
14
14
  :maximum_width => [5,5,7],
15
15
  :alignment => :center
16
16
  }
17
- t.grouping_format = {
17
+ format.grouping = {
18
18
  :show_headings => false
19
19
  }
20
20
  end
21
21
  end
22
22
 
23
23
  def test_basic
24
-
25
24
  tf = "+-------+\n"
26
25
 
27
- a = [[1,2],[3,4]].to_table.to_text
26
+ a = Table([], :data => [[1,2],[3,4]]).to_text
28
27
  assert_equal("#{tf}| 1 | 2 |\n| 3 | 4 |\n#{tf}",a)
29
28
 
30
- a = [[1,2],[3,4]].to_table(%w[a b]).to_text
29
+ a = Table(%w[a b], :data => [[1,2],[3,4]]).to_text
31
30
  assert_equal("#{tf}| a | b |\n#{tf}| 1 | 2 |\n| 3 | 4 |\n#{tf}", a)
32
-
33
31
  end
34
32
 
35
33
  def test_centering
36
34
  tf = "+---------+\n"
37
35
 
38
- a = [[1,2],[300,4]].to_table
36
+ a = Table([], :data => [[1,2],[300,4]])
39
37
  assert_equal( "#{tf}| 1 | 2 |\n| 300 | 4 |\n#{tf}",
40
38
  a.to_text(:alignment => :center) )
41
39
 
@@ -47,7 +45,7 @@ class TestRenderTextTable < Test::Unit::TestCase
47
45
 
48
46
  def test_justified
49
47
  tf = "+----------+\n"
50
- a = [[1,'Z'],[300,'BB']].to_table
48
+ a = Table([], :data => [[1,'Z'],[300,'BB']])
51
49
 
52
50
  # justified alignment can be set explicitly
53
51
  assert_equal "#{tf}| 1 | Z |\n| 300 | BB |\n#{tf}",
@@ -58,18 +56,18 @@ class TestRenderTextTable < Test::Unit::TestCase
58
56
  end
59
57
 
60
58
  def test_wrapping
61
- a = [[1,2],[300,4]].to_table.to_text(:table_width => 10)
59
+ a = Table([], :data => [[1,2],[300,4]]).to_text(:table_width => 10)
62
60
  assert_equal("+------->>\n| 1 | >>\n| 300 | >>\n+------->>\n",a)
63
61
  end
64
62
 
65
63
  def test_ignore_wrapping
66
- a = [[1,2],[300,4]].to_table.to_text(:table_width => 10,
64
+ a = Table([], :data => [[1,2],[300,4]]).to_text(:table_width => 10,
67
65
  :ignore_table_width => true )
68
66
  assert_equal("+---------+\n| 1 | 2 |\n| 300 | 4 |\n+---------+\n",a)
69
67
  end
70
68
 
71
69
  def test_render_empty_table
72
- assert_raise(Ruport::FormatterError) { [].to_table.to_text }
70
+ assert_raise(Ruport::FormatterError) { Table([]).to_text }
73
71
  assert_nothing_raised { Table(%w[a b c]).to_text }
74
72
 
75
73
  a = Table(%w[a b c]).to_text
@@ -154,7 +152,7 @@ class TestRenderTextTable < Test::Unit::TestCase
154
152
  # -- BUG TRAPS ------------------------------
155
153
 
156
154
  def test_should_render_without_column_names
157
- a = [[1,2,3]].to_table.to_text
155
+ a = Table([], :data => [[1,2,3]]).to_text
158
156
  expected = "+-----------+\n"+
159
157
  "| 1 | 2 | 3 |\n"+
160
158
  "+-----------+\n"
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ruport
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.3
7
- date: 2007-11-24 00:00:00 -05:00
6
+ version: 1.4.0
7
+ date: 2007-12-25 00:00:00 -05:00
8
8
  summary: A generalized Ruby report generation and templating engine.
9
9
  require_paths:
10
10
  - lib
@@ -30,113 +30,103 @@ authors:
30
30
  - Gregory Brown
31
31
  files:
32
32
  - examples/btree
33
- - examples/centered_pdf_text_box.rb
34
- - examples/data
35
- - examples/example.csv
36
- - examples/line_plotter.rb
37
- - examples/pdf_report_with_common_base.rb
38
- - examples/png_embed.rb
39
- - examples/roadmap.png
40
- - examples/row_renderer.rb
41
- - examples/RWEmerson.jpg
42
- - examples/simple_pdf_lines.rb
43
- - examples/simple_templating_example.rb
44
- - examples/tattle_ruby_version.rb
45
- - examples/tattle_rubygems_version.rb
46
- - examples/trac_ticket_status.rb
47
33
  - examples/btree/commaleon
48
- - examples/btree/commaleon/commaleon.rb
49
34
  - examples/btree/commaleon/sample_data
50
35
  - examples/btree/commaleon/sample_data/ticket_count.csv
51
36
  - examples/btree/commaleon/sample_data/ticket_count2.csv
37
+ - examples/btree/commaleon/commaleon.rb
38
+ - examples/data
52
39
  - examples/data/tattle.dump
40
+ - examples/row_renderer.rb
41
+ - examples/RWEmerson.jpg
42
+ - examples/centered_pdf_text_box.rb
43
+ - examples/tattle_rubygems_version.rb
44
+ - examples/trac_ticket_status.rb
45
+ - examples/line_plotter.rb
46
+ - examples/png_embed.rb
47
+ - examples/pdf_report_with_common_base.rb
48
+ - examples/example.csv
49
+ - examples/tattle_ruby_version.rb
50
+ - examples/roadmap.png
51
+ - examples/simple_templating_example.rb
52
+ - examples/simple_pdf_lines.rb
53
53
  - lib/ruport
54
- - lib/ruport.rb
55
- - lib/uport.rb
56
- - lib/ruport/acts_as_reportable.rb
57
- - lib/ruport/data
58
- - lib/ruport/data.rb
59
- - lib/ruport/extensions.rb
60
54
  - lib/ruport/formatter
61
- - lib/ruport/formatter.rb
62
- - lib/ruport/query
63
- - lib/ruport/query.rb
64
- - lib/ruport/renderer
65
- - lib/ruport/renderer.rb
66
- - lib/ruport/data/feeder.rb
67
- - lib/ruport/data/grouping.rb
68
- - lib/ruport/data/record.rb
69
- - lib/ruport/data/table.rb
70
- - lib/ruport/formatter/csv.rb
71
55
  - lib/ruport/formatter/html.rb
56
+ - lib/ruport/formatter/text.rb
72
57
  - lib/ruport/formatter/pdf.rb
58
+ - lib/ruport/formatter/csv.rb
73
59
  - lib/ruport/formatter/template.rb
74
- - lib/ruport/formatter/text.rb
75
- - lib/ruport/query/sql_split.rb
76
- - lib/ruport/renderer/grouping.rb
60
+ - lib/ruport/renderer
77
61
  - lib/ruport/renderer/table.rb
78
- - test/acts_as_reportable_test.rb
79
- - test/csv_formatter_test.rb
80
- - test/data_feeder_test.rb
81
- - test/grouping_test.rb
82
- - test/helpers.rb
83
- - test/html_formatter_test.rb
84
- - test/pdf_formatter_test.rb
85
- - test/query_test.rb
86
- - test/record_test.rb
87
- - test/renderer_test.rb
62
+ - lib/ruport/renderer/grouping.rb
63
+ - lib/ruport/data
64
+ - lib/ruport/data/record.rb
65
+ - lib/ruport/data/table.rb
66
+ - lib/ruport/data/feeder.rb
67
+ - lib/ruport/data/grouping.rb
68
+ - lib/ruport/extensions.rb
69
+ - lib/ruport/formatter.rb
70
+ - lib/ruport/renderer.rb
71
+ - lib/ruport/data.rb
72
+ - lib/uport.rb
73
+ - lib/ruport.rb
88
74
  - test/samples
89
- - test/sql_split_test.rb
90
- - test/table_test.rb
91
- - test/template_test.rb
92
- - test/text_formatter_test.rb
93
- - test/samples/addressbook.csv
75
+ - test/samples/test.yaml
76
+ - test/samples/query_test.sql
94
77
  - test/samples/data.csv
95
78
  - test/samples/data.tsv
96
- - test/samples/dates.csv
97
79
  - test/samples/erb_test.sql
98
- - test/samples/query_test.sql
80
+ - test/samples/ticket_count.csv
99
81
  - test/samples/ruport_test.sql
82
+ - test/samples/addressbook.csv
83
+ - test/samples/dates.csv
100
84
  - test/samples/test.sql
101
- - test/samples/test.yaml
102
- - test/samples/ticket_count.csv
103
- - util/bench/data
85
+ - test/csv_formatter_test.rb
86
+ - test/record_test.rb
87
+ - test/data_feeder_test.rb
88
+ - test/helpers.rb
89
+ - test/renderer_test.rb
90
+ - test/html_formatter_test.rb
91
+ - test/table_test.rb
92
+ - test/text_formatter_test.rb
93
+ - test/grouping_test.rb
94
+ - test/template_test.rb
95
+ - test/pdf_formatter_test.rb
104
96
  - util/bench/formatter
97
+ - util/bench/formatter/bench_html.rb
98
+ - util/bench/formatter/bench_text.rb
99
+ - util/bench/formatter/bench_pdf.rb
100
+ - util/bench/formatter/bench_csv.rb
105
101
  - util/bench/samples
106
- - util/bench/data/record
102
+ - util/bench/samples/tattle.csv
103
+ - util/bench/data
107
104
  - util/bench/data/table
108
- - util/bench/data/record/bench_as_vs_to.rb
109
- - util/bench/data/record/bench_constructor.rb
110
- - util/bench/data/record/bench_indexing.rb
111
- - util/bench/data/record/bench_reorder.rb
112
- - util/bench/data/record/bench_to_a.rb
113
105
  - util/bench/data/table/bench_column_manip.rb
114
- - util/bench/data/table/bench_dup.rb
115
106
  - util/bench/data/table/bench_init.rb
116
107
  - util/bench/data/table/bench_manip.rb
117
- - util/bench/formatter/bench_csv.rb
118
- - util/bench/formatter/bench_html.rb
119
- - util/bench/formatter/bench_pdf.rb
120
- - util/bench/formatter/bench_text.rb
121
- - util/bench/samples/tattle.csv
108
+ - util/bench/data/table/bench_dup.rb
109
+ - util/bench/data/record
110
+ - util/bench/data/record/bench_reorder.rb
111
+ - util/bench/data/record/bench_to_a.rb
112
+ - util/bench/data/record/bench_constructor.rb
113
+ - util/bench/data/record/bench_indexing.rb
114
+ - util/bench/data/record/bench_as_vs_to.rb
122
115
  - Rakefile
123
116
  - README
124
117
  - LICENSE
125
118
  - AUTHORS
126
119
  test_files:
127
- - test/acts_as_reportable_test.rb
128
120
  - test/csv_formatter_test.rb
129
- - test/data_feeder_test.rb
130
- - test/grouping_test.rb
131
- - test/html_formatter_test.rb
132
- - test/pdf_formatter_test.rb
133
- - test/query_test.rb
134
121
  - test/record_test.rb
122
+ - test/data_feeder_test.rb
135
123
  - test/renderer_test.rb
136
- - test/sql_split_test.rb
124
+ - test/html_formatter_test.rb
137
125
  - test/table_test.rb
138
- - test/template_test.rb
139
126
  - test/text_formatter_test.rb
127
+ - test/grouping_test.rb
128
+ - test/template_test.rb
129
+ - test/pdf_formatter_test.rb
140
130
  rdoc_options:
141
131
  - --title
142
132
  - Ruport Documentation
@@ -154,15 +144,6 @@ extensions: []
154
144
  requirements: []
155
145
 
156
146
  dependencies:
157
- - !ruby/object:Gem::Dependency
158
- name: transaction-simple
159
- version_requirement:
160
- version_requirements: !ruby/object:Gem::Version::Requirement
161
- requirements:
162
- - - "="
163
- - !ruby/object:Gem::Version
164
- version: 1.4.0
165
- version:
166
147
  - !ruby/object:Gem::Dependency
167
148
  name: fastercsv
168
149
  version_requirement:
@@ -177,7 +158,7 @@ dependencies:
177
158
  version_requirement:
178
159
  version_requirements: !ruby/object:Gem::Version::Requirement
179
160
  requirements:
180
- - - ">="
161
+ - - "="
181
162
  - !ruby/object:Gem::Version
182
- version: 1.1.3
163
+ version: 1.1.7
183
164
  version:
@@ -1,378 +0,0 @@
1
- # Ruport : Extensible Reporting System
2
- #
3
- # acts_as_reportable.rb provides ActiveRecord integration for Ruport.
4
- #
5
- # Originally created by Dudley Flanders, 2006
6
- # Revised and updated by Michael Milner, 2007
7
- # Copyright (C) 2006-2007 Dudley Flanders / Michael Milner, All Rights Reserved.
8
- #
9
- # This is free software distributed under the same terms as Ruby 1.8
10
- # See LICENSE and COPYING for details.
11
- #
12
- require "ruport"
13
- Ruport.quiet { require "active_record" }
14
-
15
- module Ruport
16
-
17
- # === Overview
18
- #
19
- # This module is designed to allow an ActiveRecord model to be converted to
20
- # Ruport's data structures. If ActiveRecord is available when Ruport is
21
- # loaded, this module will be automatically mixed into ActiveRecord::Base.
22
- #
23
- # Add the acts_as_reportable call to the model class that you want to
24
- # integrate with Ruport:
25
- #
26
- # class Book < ActiveRecord::Base
27
- # acts_as_reportable
28
- # belongs_to :author
29
- # end
30
- #
31
- # Then you can use the <tt>report_table</tt> method to get data from the
32
- # model using ActiveRecord.
33
- #
34
- # Book.report_table(:all, :include => :author)
35
- #
36
- module Reportable
37
-
38
- def self.included(base) #:nodoc:
39
- base.extend ClassMethods
40
- end
41
-
42
- # === Overview
43
- #
44
- # This module contains class methods that will automatically be available
45
- # to ActiveRecord models.
46
- #
47
- module ClassMethods
48
-
49
- # In the ActiveRecord model you wish to integrate with Ruport, add the
50
- # following line just below the class definition:
51
- #
52
- # acts_as_reportable
53
- #
54
- # Available options:
55
- #
56
- # <b><tt>:only</tt></b>:: an attribute name or array of attribute
57
- # names to include in the results, other
58
- # attributes will be excuded.
59
- # <b><tt>:except</tt></b>:: an attribute name or array of attribute
60
- # names to exclude from the results.
61
- # <b><tt>:methods</tt></b>:: a method name or array of method names
62
- # whose result(s) will be included in the
63
- # table.
64
- # <b><tt>:include</tt></b>:: an associated model or array of associated
65
- # models to include in the results.
66
- #
67
- # Example:
68
- #
69
- # class Book < ActiveRecord::Base
70
- # acts_as_reportable, :only => 'title', :include => :author
71
- # end
72
- #
73
- def acts_as_reportable(options = {})
74
- cattr_accessor :aar_options, :aar_columns
75
-
76
- self.aar_options = options
77
-
78
- include Ruport::Reportable::InstanceMethods
79
- extend Ruport::Reportable::SingletonMethods
80
- end
81
- end
82
-
83
- # === Overview
84
- #
85
- # This module contains methods that will be made available as singleton
86
- # class methods to any ActiveRecord model that calls
87
- # <tt>acts_as_reportable</tt>.
88
- #
89
- module SingletonMethods
90
-
91
- # Creates a Ruport::Data::Table from an ActiveRecord find. Takes
92
- # parameters just like a regular find.
93
- #
94
- # Additional options include:
95
- #
96
- # <b><tt>:only</tt></b>:: An attribute name or array of attribute
97
- # names to include in the results, other
98
- # attributes will be excuded.
99
- # <b><tt>:except</tt></b>:: An attribute name or array of attribute
100
- # names to exclude from the results.
101
- # <b><tt>:methods</tt></b>:: A method name or array of method names
102
- # whose result(s) will be included in the
103
- # table.
104
- # <b><tt>:include</tt></b>:: An associated model or array of associated
105
- # models to include in the results.
106
- # <b><tt>:filters</tt></b>:: A proc or array of procs that set up
107
- # conditions to filter the data being added
108
- # to the table.
109
- # <b><tt>:transforms</tt></b>:: A proc or array of procs that perform
110
- # transformations on the data being added
111
- # to the table.
112
- # <b><tt>:record_class</tt></b>:: Specify the class of the table's
113
- # records.
114
- # <b><tt>:eager_loading</tt></b>:: Set to false if you don't want to
115
- # eager load included associations.
116
- #
117
- # The :only, :except, :methods, and :include options may also be passed
118
- # to the :include option in order to specify the output for any
119
- # associated models. In this case, the :include option must be a hash,
120
- # where the keys are the names of the associations and the values
121
- # are hashes of options.
122
- #
123
- # Any options passed to report_table will disable the options set by
124
- # the acts_as_reportable class method.
125
- #
126
- # Example:
127
- #
128
- # class Book < ActiveRecord::Base
129
- # belongs_to :author
130
- # acts_as_reportable
131
- # end
132
- #
133
- # Book.report_table(:all, :only => ['title'],
134
- # :include => { :author => { :only => 'name' } }).as(:html)
135
- #
136
- # Returns:
137
- #
138
- # an html version of the table with two columns, title from
139
- # the book, and name from the associated author.
140
- #
141
- # Example:
142
- #
143
- # Book.report_table(:all, :include => :author).as(:html)
144
- #
145
- # Returns:
146
- #
147
- # an html version of the table with all columns from books and authors.
148
- #
149
- # Note: column names for attributes of included models will be qualified
150
- # with the name of the association.
151
- #
152
- def report_table(number = :all, options = {})
153
- only = options.delete(:only)
154
- except = options.delete(:except)
155
- methods = options.delete(:methods)
156
- includes = options.delete(:include)
157
- filters = options.delete(:filters)
158
- transforms = options.delete(:transforms)
159
- record_class = options.delete(:record_class) || Ruport::Data::Record
160
- self.aar_columns = []
161
-
162
- unless options.delete(:eager_loading) == false
163
- options[:include] = get_include_for_find(includes)
164
- end
165
-
166
- data = [find(number, options)].flatten
167
- data = data.map {|r| r.reportable_data(:include => includes,
168
- :only => only,
169
- :except => except,
170
- :methods => methods) }.flatten
171
-
172
-
173
- table = Ruport::Data::Table.new(:data => data,
174
- :column_names => aar_columns,
175
- :record_class => record_class,
176
- :filters => filters,
177
- :transforms => transforms )
178
- end
179
-
180
- # Creates a Ruport::Data::Table from an ActiveRecord find_by_sql.
181
- #
182
- # Additional options include:
183
- #
184
- # <b><tt>:filters</tt></b>:: A proc or array of procs that set up
185
- # conditions to filter the data being added
186
- # to the table.
187
- # <b><tt>:transforms</tt></b>:: A proc or array of procs that perform
188
- # transformations on the data being added
189
- # to the table.
190
- # <b><tt>:record_class</tt></b>:: Specify the class of the table's
191
- # records.
192
- #
193
- # Example:
194
- #
195
- # class Book < ActiveRecord::Base
196
- # belongs_to :author
197
- # acts_as_reportable
198
- # end
199
- #
200
- # Book.report_table_by_sql("SELECT * FROM books")
201
- #
202
- def report_table_by_sql(sql, options = {})
203
- record_class = options.delete(:record_class) || Ruport::Data::Record
204
- filters = options.delete(:filters)
205
- transforms = options.delete(:transforms)
206
- self.aar_columns = []
207
-
208
- data = find_by_sql(sql)
209
- data = data.map {|r| r.reportable_data }.flatten
210
-
211
- table = Ruport::Data::Table.new(:data => data,
212
- :column_names => aar_columns,
213
- :record_class => record_class,
214
- :filters => filters,
215
- :transforms => transforms)
216
- end
217
-
218
- private
219
-
220
- def get_include_for_find(report_option)
221
- includes = report_option.blank? ? aar_options[:include] : report_option
222
- if includes.is_a?(Hash)
223
- result = {}
224
- includes.each do |k,v|
225
- if v.empty? || !v[:include]
226
- result.merge!(k => {})
227
- else
228
- result.merge!(k => get_include_for_find(v[:include]))
229
- end
230
- end
231
- result
232
- elsif includes.is_a?(Array)
233
- result = {}
234
- includes.each {|i| result.merge!(i => {}) }
235
- result
236
- else
237
- includes
238
- end
239
- end
240
- end
241
-
242
- # === Overview
243
- #
244
- # This module contains methods that will be made available as instance
245
- # methods to any ActiveRecord model that calls <tt>acts_as_reportable</tt>.
246
- #
247
- module InstanceMethods
248
-
249
- # Grabs all of the object's attributes and the attributes of the
250
- # associated objects and returns them as an array of record hashes.
251
- #
252
- # Associated object attributes are stored in the record with
253
- # "association.attribute" keys.
254
- #
255
- # Passing :only as an option will only get those attributes.
256
- # Passing :except as an option will exclude those attributes.
257
- # Must pass :include as an option to access associations. Options
258
- # may be passed to the included associations by providing the :include
259
- # option as a hash.
260
- # Passing :methods as an option will include any methods on the object.
261
- #
262
- # Example:
263
- #
264
- # class Book < ActiveRecord::Base
265
- # belongs_to :author
266
- # acts_as_reportable
267
- # end
268
- #
269
- # abook.reportable_data(:only => ['title'], :include => [:author])
270
- #
271
- # Returns:
272
- #
273
- # [{'title' => 'book title',
274
- # 'author.id' => 'author id',
275
- # 'author.name' => 'author name' }]
276
- #
277
- # NOTE: title will only be returned if the value exists in the table.
278
- # If the books table does not have a title column, it will not be
279
- # returned.
280
- #
281
- # Example:
282
- #
283
- # abook.reportable_data(:only => ['title'],
284
- # :include => { :author => { :only => ['name'] } })
285
- #
286
- # Returns:
287
- #
288
- # [{'title' => 'book title',
289
- # 'author.name' => 'author name' }]
290
- #
291
- def reportable_data(options = {})
292
- options = options.merge(self.class.aar_options) unless
293
- has_report_options?(options)
294
-
295
- data_records = [get_attributes_with_options(options)]
296
- Array(options[:methods]).each do |method|
297
- data_records.first[method.to_s] = send(method)
298
- end
299
-
300
- # Reorder columns to match options[:only]
301
- self.class.aar_columns = options[:only] if Array === options[:only]
302
-
303
- self.class.aar_columns |= data_records.first.keys
304
-
305
- data_records =
306
- add_includes(data_records, options[:include]) if options[:include]
307
- data_records
308
- end
309
-
310
- private
311
-
312
- # Add data for all included associations
313
- #
314
- def add_includes(data_records, includes)
315
- include_has_options = includes.is_a?(Hash)
316
- associations = include_has_options ? includes.keys : Array(includes)
317
-
318
- associations.each do |association|
319
- existing_records = data_records.dup
320
- data_records = []
321
-
322
- if include_has_options
323
- assoc_options = includes[association].merge({
324
- :qualify_attribute_names => association })
325
- else
326
- assoc_options = { :qualify_attribute_names => association }
327
- end
328
-
329
- association_objects = [send(association)].flatten.compact
330
-
331
- existing_records.each do |existing_record|
332
- if association_objects.empty?
333
- data_records << existing_record
334
- else
335
- association_objects.each do |obj|
336
- association_records = obj.reportable_data(assoc_options)
337
- association_records.each do |assoc_record|
338
- data_records << existing_record.merge(assoc_record)
339
- end
340
- self.class.aar_columns |= data_records.last.keys
341
- end
342
- end
343
- end
344
- end
345
- data_records
346
- end
347
-
348
- # Check if the options hash has any report options
349
- # (:only, :except, :methods, or :include).
350
- #
351
- def has_report_options?(options)
352
- options[:only] || options[:except] || options[:methods] ||
353
- options[:include]
354
- end
355
-
356
- # Get the object's attributes using the supplied options.
357
- #
358
- # Use the :only or :except options to limit the attributes returned.
359
- #
360
- # Use the :qualify_attribute_names option to append the association
361
- # name to the attribute name as association.attribute
362
- #
363
- def get_attributes_with_options(options = {})
364
- only_or_except =
365
- if options[:only] or options[:except]
366
- { :only => options[:only], :except => options[:except] }
367
- end
368
- attrs = attributes(only_or_except)
369
- attrs = attrs.inject({}) {|h,(k,v)|
370
- h["#{options[:qualify_attribute_names]}.#{k}"] = v; h
371
- } if options[:qualify_attribute_names]
372
- attrs
373
- end
374
- end
375
- end
376
- end
377
-
378
- ActiveRecord::Base.send :include, Ruport::Reportable