ruport 0.2.9 → 0.3.8
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/ACKNOWLEDGEMENTS +33 -0
- data/AUTHORS +13 -1
- data/CHANGELOG +76 -1
- data/README +208 -89
- data/Rakefile +12 -8
- data/TODO +14 -122
- data/lib/ruport.rb +58 -0
- data/lib/ruport/config.rb +114 -0
- data/lib/ruport/data_row.rb +144 -0
- data/lib/ruport/data_set.rb +221 -0
- data/lib/ruport/format.rb +116 -0
- data/lib/ruport/format/builder.rb +29 -5
- data/lib/ruport/format/document.rb +77 -0
- data/lib/ruport/format/open_node.rb +36 -0
- data/lib/ruport/parser.rb +202 -0
- data/lib/ruport/query.rb +208 -0
- data/lib/ruport/query/sql_split.rb +33 -0
- data/lib/ruport/report.rb +116 -0
- data/lib/ruport/report/mailer.rb +17 -15
- data/test/{addressbook.csv → samples/addressbook.csv} +0 -0
- data/test/samples/car_ads.txt +505 -0
- data/test/{data.csv → samples/data.csv} +0 -0
- data/test/samples/document.xml +22 -0
- data/test/samples/five_lines.txt +5 -0
- data/test/samples/five_paragraphs.txt +9 -0
- data/test/samples/ross_report.txt +58530 -0
- data/test/samples/ruport_test.sql +8 -0
- data/test/samples/stonecodeblog.sql +279 -0
- data/test/{test.sql → samples/test.sql} +2 -1
- data/test/{test.yaml → samples/test.yaml} +0 -0
- data/test/tc_builder.rb +7 -4
- data/test/tc_config.rb +41 -0
- data/test/tc_data_row.rb +16 -26
- data/test/tc_data_set.rb +60 -41
- data/test/tc_database.rb +25 -0
- data/test/tc_document.rb +42 -0
- data/test/tc_element.rb +18 -0
- data/test/tc_page.rb +42 -0
- data/test/tc_query.rb +55 -0
- data/test/tc_reading.rb +60 -0
- data/test/tc_report.rb +31 -0
- data/test/tc_section.rb +45 -0
- data/test/tc_sql_split.rb +18 -0
- data/test/tc_state.rb +142 -0
- data/test/ts_all.rb +6 -3
- data/test/ts_format.rb +5 -0
- data/test/ts_parser.rb +10 -0
- metadata +102 -60
- data/bin/ruport +0 -104
- data/lib/ruport/format/chart.rb +0 -1
- data/lib/ruport/report/data_row.rb +0 -79
- data/lib/ruport/report/data_set.rb +0 -153
- data/lib/ruport/report/engine.rb +0 -201
- data/lib/ruport/report/fake_db.rb +0 -54
- data/lib/ruport/report/fake_engine.rb +0 -26
- data/lib/ruport/report/fake_mailer.rb +0 -23
- data/lib/ruport/report/sql.rb +0 -95
- data/lib/ruportlib.rb +0 -11
- data/test/tc_engine.rb +0 -102
- data/test/tc_mailer.rb +0 -21
data/test/ts_all.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require "test/unit"
|
2
|
-
require "test/
|
2
|
+
require "test/ts_format"
|
3
|
+
require "test/ts_parser"
|
4
|
+
require "test/tc_sql_split"
|
5
|
+
require "test/tc_query"
|
6
|
+
require "test/tc_config"
|
7
|
+
require "test/tc_report"
|
3
8
|
require "test/tc_data_set"
|
4
9
|
require "test/tc_data_row"
|
5
|
-
require "test/tc_builder"
|
6
|
-
require "test/tc_mailer"
|
data/test/ts_format.rb
ADDED
data/test/ts_parser.rb
ADDED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.11
|
3
3
|
specification_version: 1
|
4
4
|
name: ruport
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date:
|
6
|
+
version: 0.3.8
|
7
|
+
date: 2006-02-21 00:00:00 -05:00
|
8
8
|
summary: A generalized Ruby report generation and templating engine.
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: "\tgregory.t.brown@gmail.com"
|
12
12
|
homepage: http://ruport.rubyforge.org
|
13
13
|
rubyforge_project: ruport
|
@@ -18,69 +18,111 @@ bindir: bin
|
|
18
18
|
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
27
28
|
authors:
|
28
|
-
|
29
|
+
- Gregory Brown
|
29
30
|
files:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
31
|
+
- lib/ruport.rb
|
32
|
+
- lib/ruport/data_set.rb
|
33
|
+
- lib/ruport/config.rb
|
34
|
+
- lib/ruport/format.rb
|
35
|
+
- lib/ruport/report.rb
|
36
|
+
- lib/ruport/query.rb
|
37
|
+
- lib/ruport/data_row.rb
|
38
|
+
- lib/ruport/parser.rb
|
39
|
+
- lib/ruport/format/document.rb
|
40
|
+
- lib/ruport/format/builder.rb
|
41
|
+
- lib/ruport/format/open_node.rb
|
42
|
+
- lib/ruport/report/mailer.rb
|
43
|
+
- lib/ruport/query/sql_split.rb
|
44
|
+
- CHANGELOG
|
45
|
+
- LICENSE
|
46
|
+
- Rakefile
|
47
|
+
- AUTHORS
|
48
|
+
- TODO
|
49
|
+
- COPYING
|
50
|
+
- README
|
51
|
+
- ACKNOWLEDGEMENTS
|
52
|
+
- test/samples
|
53
|
+
- test/tc_element.rb
|
54
|
+
- test/ts_all.rb
|
55
|
+
- test/tc_data_row.rb
|
56
|
+
- test/tc_state.rb
|
57
|
+
- test/tc_section.rb
|
58
|
+
- test/tc_database.rb
|
59
|
+
- test/tc_config.rb
|
60
|
+
- test/ts_format.rb
|
61
|
+
- test/ts_parser.rb
|
62
|
+
- test/tc_sql_split.rb
|
63
|
+
- test/tc_report.rb
|
64
|
+
- test/tc_page.rb
|
65
|
+
- test/tc_document.rb
|
66
|
+
- test/tc_data_set.rb
|
67
|
+
- test/tc_builder.rb
|
68
|
+
- test/tc_query.rb
|
69
|
+
- test/tc_reading.rb
|
70
|
+
- test/samples/stonecodeblog.sql
|
71
|
+
- test/samples/ruport_test.sql
|
72
|
+
- test/samples/test.yaml
|
73
|
+
- test/samples/data.csv
|
74
|
+
- test/samples/car_ads.txt
|
75
|
+
- test/samples/addressbook.csv
|
76
|
+
- test/samples/document.xml
|
77
|
+
- test/samples/test.sql
|
78
|
+
- test/samples/five_lines.txt
|
79
|
+
- test/samples/five_paragraphs.txt
|
80
|
+
- test/samples/ross_report.txt
|
59
81
|
test_files:
|
60
|
-
|
82
|
+
- test/ts_all.rb
|
61
83
|
rdoc_options:
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
84
|
+
- --title
|
85
|
+
- Ruport Documentation
|
86
|
+
- --main
|
87
|
+
- README
|
88
|
+
- -q
|
66
89
|
extra_rdoc_files:
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
executables:
|
73
|
-
|
90
|
+
- README
|
91
|
+
- LICENSE
|
92
|
+
- TODO
|
93
|
+
- AUTHORS
|
94
|
+
- CHANGELOG
|
95
|
+
executables: []
|
96
|
+
|
74
97
|
extensions: []
|
98
|
+
|
75
99
|
requirements: []
|
100
|
+
|
76
101
|
dependencies:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: fastercsv
|
104
|
+
version_requirement:
|
105
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.1.0
|
110
|
+
version:
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: RedCloth
|
113
|
+
version_requirement:
|
114
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 3.0.0
|
119
|
+
version:
|
120
|
+
- !ruby/object:Gem::Dependency
|
121
|
+
name: pdf-writer
|
122
|
+
version_requirement:
|
123
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: 1.1.3
|
128
|
+
version:
|
data/bin/ruport
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# ruport.rb : A Ruby Reporting system.
|
3
|
-
#
|
4
|
-
# Created by Gregory Thomas Brown on 2005-08-02
|
5
|
-
# Copyright (c) 2005 Gregory Brown, Stone Code Productions
|
6
|
-
# All rights reserved.
|
7
|
-
#
|
8
|
-
# This product is free software, you may distribute it as such
|
9
|
-
# under your choice of the Ruby license or the GNU GPL
|
10
|
-
# See LICENSE for details
|
11
|
-
#
|
12
|
-
# Special thanks and acknowledgement go to James Edward Gray II
|
13
|
-
# for providing the original source code for this application
|
14
|
-
|
15
|
-
require "rubygems"
|
16
|
-
require "ftools"
|
17
|
-
require "yaml"
|
18
|
-
require "ruportlib"
|
19
|
-
|
20
|
-
# The whole codebase below is scary, dirty, and evil.
|
21
|
-
# The library itself is much cleaner. This is a total hack.
|
22
|
-
|
23
|
-
if ARGV[0].nil?
|
24
|
-
puts "Usage: ruport path/to/script.rb or ruport generate project_name"
|
25
|
-
exit
|
26
|
-
end
|
27
|
-
|
28
|
-
if ARGV[0].eql?("generate")
|
29
|
-
if ARGV[1].nil?
|
30
|
-
puts "You must specify a name for your ruport project"
|
31
|
-
exit
|
32
|
-
end
|
33
|
-
Dir.mkdir(ARGV[1])
|
34
|
-
Dir.mkdir("#{ARGV[1]}/log")
|
35
|
-
Dir.mkdir("#{ARGV[1]}/reports")
|
36
|
-
Dir.mkdir("#{ARGV[1]}/scripts")
|
37
|
-
Dir.mkdir("#{ARGV[1]}/config")
|
38
|
-
Dir.mkdir("#{ARGV[1]}/queries")
|
39
|
-
conf = (<<-END_CONF
|
40
|
-
# any DBI driver ('DBI:mysql', 'DBI:odbc', etc) or Ruport's mock ('ruport')
|
41
|
-
:driver:
|
42
|
-
|
43
|
-
#The database to connect to. For remote database: 'foo:hostname' or 'foo:ip'
|
44
|
-
:database:
|
45
|
-
|
46
|
-
# username. for local auth, leave blank
|
47
|
-
:db_user:
|
48
|
-
|
49
|
-
:db_password:
|
50
|
-
|
51
|
-
#mail info, if you want mail support, fill out. Otherwise leave blank
|
52
|
-
:mail_host:
|
53
|
-
:mail_account:
|
54
|
-
:mail_password:
|
55
|
-
:mail_address:
|
56
|
-
:mail_authentication:
|
57
|
-
:query_table:
|
58
|
-
|
59
|
-
END_CONF
|
60
|
-
).gsub(" ","")
|
61
|
-
|
62
|
-
File.open("#{ARGV[1]}/config/ruport.yaml", "w") { |f| f.puts(conf) }
|
63
|
-
File.open("#{ARGV[1]}/scripts/test.rb", "w") { |f|
|
64
|
-
f.puts('@report = query("show tables").to_csv')
|
65
|
-
}
|
66
|
-
exit
|
67
|
-
elsif ARGV[0].eql?("-v")
|
68
|
-
puts "Ruport Version 0.2.9 \nA ruby report generation system by Gregory " +
|
69
|
-
"Brown.\nThis application is Free Software under the GPL/Ruby License. " +
|
70
|
-
"\nAll praise and/or criticism can be directed to "+
|
71
|
-
"gregory.t.brown@gmail.com"
|
72
|
-
exit
|
73
|
-
end
|
74
|
-
unless (File.exist?("config/ruport.yaml"))
|
75
|
-
puts "You are trying to execute ruport from outside a ruport folder"
|
76
|
-
exit
|
77
|
-
end
|
78
|
-
config = YAML.load(File.open("config/ruport.yaml"))
|
79
|
-
mailer = nil
|
80
|
-
|
81
|
-
if config.has_key?(:mail_host)
|
82
|
-
mailer = Report::Mailer.new( config[:mail_host], config[:mail_address],
|
83
|
-
config[:mail_account], config[:mail_password],
|
84
|
-
25, config[:mail_authentication] )
|
85
|
-
end
|
86
|
-
|
87
|
-
report = Report::Engine.new(
|
88
|
-
"#{config[:driver]}:#{config[:database]}",
|
89
|
-
config[:db_user], config[:db_password], mailer )
|
90
|
-
|
91
|
-
if config[:driver].eql?("ruport")
|
92
|
-
report = Report::FakeEngine.new( "#{config[:driver]}:#{config[:database]}",
|
93
|
-
config[:db_user], config[:db_password], mailer )
|
94
|
-
end
|
95
|
-
|
96
|
-
report.query_table = config[:query_table]
|
97
|
-
report.file = ARGV[1] unless ARGV[1].nil?
|
98
|
-
unless ( File.exists? ARGV[0] )
|
99
|
-
report.logger.fatal("Could not open #{ARGV[0]}")
|
100
|
-
puts "Could not open #{ARGV[0]}"
|
101
|
-
exit
|
102
|
-
end
|
103
|
-
report.eval_report(ARGV[0], File.open(ARGV[0]) { |f| f.read })
|
104
|
-
report.generate_report if report.generate
|
data/lib/ruport/format/chart.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Do me!
|
@@ -1,79 +0,0 @@
|
|
1
|
-
#!/usr/local/bin/ruby
|
2
|
-
# data_row.rb
|
3
|
-
# Created by Gregory Thomas Brown on 2005-08-02
|
4
|
-
# Copyright 2005 (Gregory Brown) All rights reserved.
|
5
|
-
#
|
6
|
-
# This product is free software, you may distribute it as such
|
7
|
-
# under your choice of the Ruby license or the GNU GPL
|
8
|
-
# See LICENSE for details
|
9
|
-
|
10
|
-
module Ruport
|
11
|
-
module Report
|
12
|
-
class DataRow
|
13
|
-
|
14
|
-
include Enumerable
|
15
|
-
|
16
|
-
|
17
|
-
# DataRows are essentially arrays with named ordinal fields and
|
18
|
-
# awareness of their oddness and position.
|
19
|
-
def initialize( data, fields, oddness=nil, position=nil )
|
20
|
-
@data = data
|
21
|
-
@fields = fields
|
22
|
-
@oddness = oddness
|
23
|
-
@position = position
|
24
|
-
@tags = []
|
25
|
-
end
|
26
|
-
|
27
|
-
attr_accessor :fields, :tags
|
28
|
-
|
29
|
-
#Returns an array of values.
|
30
|
-
def +(other)
|
31
|
-
self.to_a + other.to_a
|
32
|
-
end
|
33
|
-
|
34
|
-
# Lets you access individual fields
|
35
|
-
#
|
36
|
-
# i.e. row["phone"]
|
37
|
-
def [](key)
|
38
|
-
key.kind_of?(Fixnum) ? @data[key] : @data[@fields.index(key)]
|
39
|
-
end
|
40
|
-
|
41
|
-
# Lets you set field values
|
42
|
-
#
|
43
|
-
# i.e. row["phone"] = '2038291203'
|
44
|
-
def []=(key,value)
|
45
|
-
key.kind_of?(String) ? @data[@fields.index(key)] = value :
|
46
|
-
@data[key] = value
|
47
|
-
end
|
48
|
-
|
49
|
-
# Converts the DataRow to a plain old Array
|
50
|
-
def to_a
|
51
|
-
@data
|
52
|
-
end
|
53
|
-
|
54
|
-
# Converts the DataRow to a string representation
|
55
|
-
# for outputting to screen.
|
56
|
-
def to_s
|
57
|
-
"[" + @data.join(",") + "]"
|
58
|
-
end
|
59
|
-
|
60
|
-
# implements
|
61
|
-
# DataRow#first? DataRow#last? DataRow#middle?
|
62
|
-
# DataRow#odd? DataRow#even? which are all conditional methods.
|
63
|
-
def method_missing(method)
|
64
|
-
if %[last? first? center?].include? method.to_s
|
65
|
-
return @position.eql?(method.to_s[0..-2].to_sym)
|
66
|
-
elsif %[odd? even?].include? method.to_s
|
67
|
-
return @oddness.eql?(method.to_s[0..-2].to_sym)
|
68
|
-
end
|
69
|
-
super
|
70
|
-
end
|
71
|
-
|
72
|
-
def each(&action)
|
73
|
-
@data.each(&action)
|
74
|
-
end
|
75
|
-
|
76
|
-
attr_accessor :position
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,153 +0,0 @@
|
|
1
|
-
#!/usr/local/bin/ruby
|
2
|
-
# data_set.rb
|
3
|
-
# Created by Gregory Thomas Brown on 2005-08-02
|
4
|
-
# Copyright 2005 (Gregory Brown) All rights reserved.
|
5
|
-
#
|
6
|
-
# This product is free software, you may distribute it as such
|
7
|
-
# under your choice of the Ruby license or the GNU GPL
|
8
|
-
# See LICENSE for details
|
9
|
-
module Ruport
|
10
|
-
module Report
|
11
|
-
class DataSet
|
12
|
-
|
13
|
-
include Enumerable
|
14
|
-
|
15
|
-
def initialize
|
16
|
-
@data = []
|
17
|
-
end
|
18
|
-
|
19
|
-
#fields are the column names, default is the default cell value
|
20
|
-
attr_accessor :fields, :default
|
21
|
-
|
22
|
-
#data is the core Array that holds all the rows
|
23
|
-
attr_reader :data
|
24
|
-
|
25
|
-
|
26
|
-
#Allows ordinal access to rows
|
27
|
-
def [](index)
|
28
|
-
@data[index]
|
29
|
-
end
|
30
|
-
|
31
|
-
#allows setting of rows (providing a DataRow is passed in)
|
32
|
-
def []=(index,value)
|
33
|
-
throw "Invalid object type" unless value.kind_of?(DataRow)
|
34
|
-
@data[index] = value
|
35
|
-
end
|
36
|
-
|
37
|
-
# appends a row to the DataSet
|
38
|
-
# can be added as an array or a keyed hash.
|
39
|
-
# i.e if our DataSet have @fields = [:a, :b, :c]
|
40
|
-
# data << [ 1, 2, 3] and data << { :a => 1, :b => 2, :c => 3 }
|
41
|
-
# are equivalent.
|
42
|
-
def << ( stuff )
|
43
|
-
new_row = Array.new
|
44
|
-
@fields.each_with_index do |key, index|
|
45
|
-
if stuff.kind_of?(Array)
|
46
|
-
new_row[index] = stuff.shift || @default
|
47
|
-
else
|
48
|
-
new_row[index] = stuff[key] || @default
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
oddness = (@data.length % 2 == 0 ? :even : :odd)
|
53
|
-
position = (@data.length == 0 ? :first : :last)
|
54
|
-
@data[@data.length - 1].position = nil if @data.length > 1
|
55
|
-
@data << DataRow.new(new_row,@fields,oddness,position)
|
56
|
-
end
|
57
|
-
|
58
|
-
# checks if one dataset equals another
|
59
|
-
def eql?(data2)
|
60
|
-
return false unless ( @data.length == data2.data.length and
|
61
|
-
@fields.eql?(data2.fields) )
|
62
|
-
@data.each_with_index do |row, r_index|
|
63
|
-
row.each_with_index do |field, f_index|
|
64
|
-
return false unless field.eql?(data2[r_index][f_index])
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
return true
|
69
|
-
end
|
70
|
-
|
71
|
-
# Allows loading of CSV files or YAML dumps. Returns a DataSet
|
72
|
-
def self.load ( source, default="")
|
73
|
-
|
74
|
-
return YAML.load(File.open(source)) if source =~ /\.(yaml|yml)/
|
75
|
-
|
76
|
-
input = FasterCSV.read(source) if source =~ /\.csv/
|
77
|
-
loaded_data = self.new
|
78
|
-
loaded_data.fields = input[0]
|
79
|
-
loaded_data.default = default
|
80
|
-
input[1..-1].each do |row|
|
81
|
-
loaded_data << row
|
82
|
-
end
|
83
|
-
return loaded_data
|
84
|
-
end
|
85
|
-
|
86
|
-
# Converts a DataSet to CSV
|
87
|
-
def to_csv
|
88
|
-
builder = Format::Builder.new(self)
|
89
|
-
builder.format = :csv
|
90
|
-
builder.render
|
91
|
-
end
|
92
|
-
# Converts a Dataset to Html
|
93
|
-
def to_html
|
94
|
-
builder = Format::Builder.new(self)
|
95
|
-
builder.format = :html
|
96
|
-
builder.render
|
97
|
-
end
|
98
|
-
|
99
|
-
# Pretty Pretty printing
|
100
|
-
def to_s
|
101
|
-
builder = Format::Builder.new(self)
|
102
|
-
builder.format = :text
|
103
|
-
builder.render
|
104
|
-
end
|
105
|
-
|
106
|
-
# Works like a standard each iterator
|
107
|
-
def each(&action)
|
108
|
-
@data.each(&action)
|
109
|
-
end
|
110
|
-
|
111
|
-
# adds tag to rows
|
112
|
-
def apply_tag(tag,&condition)
|
113
|
-
to_tag = block_given? ? condition.call(self) : self
|
114
|
-
to_tag.each { |match| match.tags << tag }
|
115
|
-
end
|
116
|
-
|
117
|
-
def apply_tags(tags)
|
118
|
-
tags.each do |tag,block|
|
119
|
-
apply_tag(tag,&block)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def select_field(field)
|
124
|
-
my_data = Report::DataSet.new
|
125
|
-
my_data.fields = [ field ]
|
126
|
-
map { |row| row[field] }.each do |r|
|
127
|
-
my_data << [ r ]
|
128
|
-
end
|
129
|
-
return my_data
|
130
|
-
end
|
131
|
-
|
132
|
-
def select_fields(*fields)
|
133
|
-
my_data = Report::DataSet.new
|
134
|
-
my_data.fields = fields
|
135
|
-
rows = fields.inject([]) { |s,e| s << map { |row| row[e] } }.transpose
|
136
|
-
rows.each do |row|
|
137
|
-
my_data << row
|
138
|
-
end
|
139
|
-
return my_data
|
140
|
-
end
|
141
|
-
|
142
|
-
def tag_matches(tag)
|
143
|
-
my_data = Report::DataSet.new
|
144
|
-
my_data.fields = @fields
|
145
|
-
select { |row| row.tags.include?(tag) }.each do |row|
|
146
|
-
my_data << row
|
147
|
-
end
|
148
|
-
return my_data
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|