lean-ruport 0.3.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of lean-ruport might be problematic. Click here for more details.

Files changed (50) hide show
  1. data/ACKNOWLEDGEMENTS +33 -0
  2. data/AUTHORS +19 -0
  3. data/CHANGELOG +206 -0
  4. data/COPYING +340 -0
  5. data/LICENSE +7 -0
  6. data/README +209 -0
  7. data/Rakefile +54 -0
  8. data/TODO +27 -0
  9. data/lib/ruport.rb +58 -0
  10. data/lib/ruport/config.rb +114 -0
  11. data/lib/ruport/data_row.rb +144 -0
  12. data/lib/ruport/data_set.rb +221 -0
  13. data/lib/ruport/format.rb +116 -0
  14. data/lib/ruport/format/builder.rb +89 -0
  15. data/lib/ruport/format/document.rb +77 -0
  16. data/lib/ruport/format/open_node.rb +36 -0
  17. data/lib/ruport/parser.rb +202 -0
  18. data/lib/ruport/query.rb +208 -0
  19. data/lib/ruport/query/sql_split.rb +33 -0
  20. data/lib/ruport/report.rb +116 -0
  21. data/lib/ruport/report/mailer.rb +48 -0
  22. data/test/samples/addressbook.csv +6 -0
  23. data/test/samples/car_ads.txt +505 -0
  24. data/test/samples/data.csv +3 -0
  25. data/test/samples/document.xml +22 -0
  26. data/test/samples/five_lines.txt +5 -0
  27. data/test/samples/five_paragraphs.txt +9 -0
  28. data/test/samples/ross_report.txt +58530 -0
  29. data/test/samples/ruport_test.sql +8 -0
  30. data/test/samples/stonecodeblog.sql +279 -0
  31. data/test/samples/test.sql +2 -0
  32. data/test/samples/test.yaml +3 -0
  33. data/test/tc_builder.rb +116 -0
  34. data/test/tc_config.rb +41 -0
  35. data/test/tc_data_row.rb +36 -0
  36. data/test/tc_data_set.rb +141 -0
  37. data/test/tc_database.rb +25 -0
  38. data/test/tc_document.rb +42 -0
  39. data/test/tc_element.rb +18 -0
  40. data/test/tc_page.rb +42 -0
  41. data/test/tc_query.rb +55 -0
  42. data/test/tc_reading.rb +60 -0
  43. data/test/tc_report.rb +31 -0
  44. data/test/tc_section.rb +45 -0
  45. data/test/tc_sql_split.rb +18 -0
  46. data/test/tc_state.rb +142 -0
  47. data/test/ts_all.rb +9 -0
  48. data/test/ts_format.rb +5 -0
  49. data/test/ts_parser.rb +10 -0
  50. metadata +102 -0
@@ -0,0 +1,45 @@
1
+ require "test/unit"
2
+ require "ruport"
3
+
4
+ class TestSection < Test::Unit::TestCase
5
+ include Ruport
6
+ def setup
7
+ elements = { :e1 => Format::Element.new(:e1),
8
+ :e2 => Format::Element.new(:e2) }
9
+ @empty_section = Format::Section.new :test_section1
10
+ @populated_section = Format::Section.new :test_section2,
11
+ :elements => elements
12
+
13
+ end
14
+
15
+ def test_basics
16
+ assert_equal( :test_section1, @empty_section.name )
17
+ assert_equal( :test_section2, @populated_section.name )
18
+ assert_equal( [], [:e1,:e2]-@populated_section.map { |e| e.name } )
19
+ end
20
+
21
+ def test_each
22
+ element_names = [:e1,:e2]
23
+ @populated_section.each { |e| element_names -= [e.name] }
24
+ assert_equal([],element_names)
25
+
26
+ element_names = [:e1, :e2, :e3]
27
+ @populated_section << Format::Element.new(:e3)
28
+ @populated_section.each { |e| element_names -= [e.name] }
29
+ assert_equal([],element_names)
30
+ end
31
+
32
+ def test_add_element
33
+ @empty_section.add_element :e1
34
+ @empty_section.add_element :e2, :content => "Hello from Element!"
35
+ assert(@empty_section[:e1])
36
+ assert(@empty_section[:e2])
37
+ assert_equal("Hello from Element!",@empty_section[:e2].content)
38
+ end
39
+
40
+ def test_brackets
41
+ assert_equal(:e1,@populated_section[:e1].name)
42
+ assert_equal(:e2,@populated_section[:e2].name)
43
+ end
44
+
45
+ end
@@ -0,0 +1,18 @@
1
+ require "test/unit"
2
+ require "ruport"
3
+ class TestSqlSplit < Test::Unit::TestCase
4
+ include Ruport
5
+
6
+ def test_sql_split1
7
+ sql = File.read 'test/samples/ruport_test.sql'
8
+ split = Query::SqlSplit.new sql
9
+ assert_equal( 'SELECT * FROM ruport_test', split.last )
10
+ end
11
+
12
+ def test_sql_split2
13
+ sql = "SELECT * FROM ruport_test"
14
+ split = Query::SqlSplit.new sql
15
+ assert_equal( 1, split.size )
16
+ assert_equal( sql, split.first )
17
+ end
18
+ end
@@ -0,0 +1,142 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ # tc_state.rb
4
+ #
5
+ # Created by James Edward Gray II on 2005-08-14.
6
+ # Copyright 2005 Gray Productions. All rights reserved.
7
+
8
+ require "test/unit"
9
+
10
+ require "ruport/parser"
11
+
12
+ class TestState < Test::Unit::TestCase
13
+ def test_single_skips
14
+ path = File.join(File.dirname(__FILE__), "samples/five_lines.txt")
15
+ lines = File.readlines(path).values_at(0..2, 4)
16
+ test = self
17
+
18
+ Ruport::Parser.new(path) do
19
+ skip(?u)
20
+
21
+ read { |line| test.assert_equal(lines.shift, line) }
22
+ end
23
+ end
24
+
25
+ def test_skipping_range
26
+ path = File.join(File.dirname(__FILE__), "samples/five_lines.txt")
27
+ lines = File.readlines(path).values_at(0, 3..4)
28
+ test = self
29
+
30
+ Ruport::Parser.new(path) do
31
+ start_skipping_at("two")
32
+ stop_skipping_at("three")
33
+
34
+ read { |line| test.assert_equal(lines.shift, line) }
35
+ end
36
+ end
37
+
38
+ def test_searching_skipped
39
+ path = File.join(File.dirname(__FILE__), "samples/five_lines.txt")
40
+
41
+ data = Ruport::Parser.new(path) do
42
+ @state = :skip
43
+ stop_skipping_at("four")
44
+ find_in_skipped(/ou/) { |line| @found_in_skip = line }
45
+
46
+ read { |line| (@lines ||= Array.new) << line }
47
+ end
48
+
49
+ assert_equal("This is line four.\n", data.found_in_skip)
50
+ assert_equal(["This is line five.\n"], data.lines)
51
+ end
52
+
53
+ def test_stop
54
+ path = File.join(File.dirname(__FILE__), "samples/five_lines.txt")
55
+
56
+ data = Ruport::Parser.new(path) do
57
+ stop_at("three")
58
+
59
+ read { |line| @last_line = line }
60
+ end
61
+
62
+ assert_equal("This is line two.\n", data.last_line)
63
+
64
+ data = Ruport::Parser.new(path) do
65
+ read do |line|
66
+ @last_line = line
67
+
68
+ @state = :stop if @read.index("three")
69
+ end
70
+ end
71
+
72
+ assert_equal("This is line three.\n", data.last_line)
73
+ end
74
+
75
+ def test_pre_and_post
76
+ path = File.join(File.dirname(__FILE__), "samples/five_lines.txt")
77
+
78
+ data = Ruport::Parser.new(path) do
79
+ @pre = @post = 0
80
+
81
+ pre do
82
+ @pre += 1
83
+ @post = 0
84
+ end
85
+ read { |line| (@lines ||= Array.new) << line }
86
+ read(/\w+\./) { |number| (@numbers ||= Array.new) << number }
87
+ post { @post += 1 }
88
+ end
89
+
90
+ assert_equal(5, data.pre)
91
+ assert_equal(1, data.post)
92
+ end
93
+
94
+ def test_complex
95
+ path = File.join(File.dirname(__FILE__), "samples/ross_report.txt")
96
+ test = self
97
+
98
+ Ruport::Parser.new(path) do
99
+ @state = :skip
100
+ start_skipping_at("\f")
101
+ stop_skipping_at(/\A-[- ]+-\Z/)
102
+ skip(/\A\s*\Z/)
103
+ skip(/--\Z/)
104
+
105
+ find_in_skipped(/((?:Period|Week)\s+\d.+?)\s*\Z/) do |period|
106
+ test.assert_equal("Period 02/2002", period)
107
+ end
108
+
109
+ stop_at("*** Selection Criteria ***")
110
+
111
+ read do |line|
112
+ test.assert_match(/\A\s+(?:Sales|Cust|SA)|\A[-\w]+\s+/, line)
113
+ end
114
+ end
115
+
116
+ path = File.join(File.dirname(__FILE__), "samples/car_ads.txt")
117
+
118
+ data = Ruport::Parser.new(path, "") do
119
+ @state = :skip
120
+ stop_skipping_at("Save Ad")
121
+ skip(/\A\s*\Z/)
122
+
123
+ pre { @price = @miles = nil }
124
+ read(/\$([\d,]+\d)/) { |price| @price = price.delete(",").to_i }
125
+ read(/([\d,]*\d)\s*m/) { |miles| @miles = miles.delete(",").to_i }
126
+
127
+ read do |ad|
128
+ if @price and @price < 20_000 and @miles and @miles < 40_000
129
+ (@ads ||= Array.new) << ad.strip
130
+ end
131
+ end
132
+ end
133
+
134
+ assert_equal([<<END_AD.strip], data.ads)
135
+ 2003 Chrysler Town & Country LX
136
+ $16,990, green, 21,488 mi, air, pw, power locks, ps, power mirrors,
137
+ dual air bags, keyless entry, intermittent wipers, rear defroster, alloy,
138
+ pb, abs, cruise, am/fm stereo, CD, cassette, tinted glass
139
+ VIN:2C4GP44363R153238, Stock No:C153238, CALL DAN PERKINS AT 1-800-432-6326
140
+ END_AD
141
+ end
142
+ end
@@ -0,0 +1,9 @@
1
+ require "test/unit"
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"
8
+ require "test/tc_data_set"
9
+ require "test/tc_data_row"
@@ -0,0 +1,5 @@
1
+ require "test/tc_builder"
2
+ require "test/tc_document"
3
+ require "test/tc_element"
4
+ require "test/tc_section"
5
+ require "test/tc_page"
@@ -0,0 +1,10 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ # ts_all.rb
4
+ #
5
+ # Created by James Edward Gray II on 2005-08-14.
6
+ # Copyright 2005 Gray Productions. All rights reserved.
7
+
8
+ require "test/unit"
9
+ require "tc_reading"
10
+ require "tc_state"
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: lean-ruport
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.3.8
7
+ date: 2006-02-21 00:00:00 -05:00
8
+ summary: A generalized Ruby report generation and templating engine.
9
+ require_paths:
10
+ - lib
11
+ email: "\tgregory.t.brown@gmail.com"
12
+ homepage: http://ruport.rubyforge.org
13
+ rubyforge_project: ruport
14
+ description: Ruport is a powerful report generation engine that allows users to generate custom ERb templates and easily query various forms of SQL databases via DBI. It provides helper methods and utilities to generate professional reports quickly and cleanly.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Gregory Brown
30
+ files:
31
+ - lib/ruport.rb
32
+ - lib/ruport/data_row.rb
33
+ - lib/ruport/data_set.rb
34
+ - lib/ruport/config.rb
35
+ - lib/ruport/query.rb
36
+ - lib/ruport/format.rb
37
+ - lib/ruport/report.rb
38
+ - lib/ruport/parser.rb
39
+ - lib/ruport/query/sql_split.rb
40
+ - lib/ruport/format/document.rb
41
+ - lib/ruport/format/builder.rb
42
+ - lib/ruport/format/open_node.rb
43
+ - lib/ruport/report/mailer.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_section.rb
57
+ - test/tc_database.rb
58
+ - test/tc_query.rb
59
+ - test/tc_config.rb
60
+ - test/ts_format.rb
61
+ - test/tc_reading.rb
62
+ - test/tc_sql_split.rb
63
+ - test/tc_report.rb
64
+ - test/tc_page.rb
65
+ - test/ts_parser.rb
66
+ - test/tc_document.rb
67
+ - test/tc_state.rb
68
+ - test/tc_data_set.rb
69
+ - test/tc_builder.rb
70
+ - test/samples/five_paragraphs.txt
71
+ - test/samples/ross_report.txt
72
+ - test/samples/test.yaml
73
+ - test/samples/five_lines.txt
74
+ - test/samples/data.csv
75
+ - test/samples/stonecodeblog.sql
76
+ - test/samples/ruport_test.sql
77
+ - test/samples/addressbook.csv
78
+ - test/samples/car_ads.txt
79
+ - test/samples/document.xml
80
+ - test/samples/test.sql
81
+ test_files:
82
+ - test/ts_all.rb
83
+ rdoc_options:
84
+ - --title
85
+ - Ruport Documentation
86
+ - --main
87
+ - README
88
+ - -q
89
+ extra_rdoc_files:
90
+ - README
91
+ - LICENSE
92
+ - TODO
93
+ - AUTHORS
94
+ - CHANGELOG
95
+ executables: []
96
+
97
+ extensions: []
98
+
99
+ requirements: []
100
+
101
+ dependencies: []
102
+