ruport-util 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/INSTALL CHANGED
@@ -3,7 +3,7 @@
3
3
  ruport-util provides a home for marooned former parts of Ruby Reports,
4
4
  and newer fringe ideas.
5
5
 
6
- Support as of 2007.06.07:
6
+ Support as of 2007.08.28:
7
7
 
8
8
  * Basic Graphing (util/graph)
9
9
  * Report runner (util/report)
@@ -20,7 +20,7 @@ See example/ for more information
20
20
 
21
21
  == Getting Ruport
22
22
 
23
- To use ruport-util, you'll need Ruport >= 0.12.0
23
+ To use ruport-util >= 0.8.0, you'll need Ruport >= 1.2.0
24
24
 
25
25
  sudo gem install ruport -y
26
26
 
data/Rakefile CHANGED
@@ -33,7 +33,7 @@ end
33
33
 
34
34
  spec = Gem::Specification.new do |spec|
35
35
  spec.name = "ruport-util"
36
- spec.version = "0.7.2"
36
+ spec.version = "0.8.0"
37
37
  spec.platform = Gem::Platform::RUBY
38
38
  spec.summary = "A set of tools and helper libs for Ruby Reports"
39
39
  spec.files = Dir.glob("{example,lib,test,bin}/**/**/*") +
@@ -48,7 +48,7 @@ spec = Gem::Specification.new do |spec|
48
48
  spec.extra_rdoc_files = %w{INSTALL}
49
49
  spec.rdoc_options << '--title' << 'ruport-util Documentation' <<
50
50
  '--main' << 'INSTALL' << '-q'
51
- spec.add_dependency('ruport', ">=0.11.0")
51
+ spec.add_dependency('ruport', ">=1.2.0")
52
52
  spec.add_dependency('scruffy', ">=0.2.2")
53
53
  spec.add_dependency('mailfactory',">=1.2.3")
54
54
  spec.add_dependency('rubyzip','>=0.9.1')
@@ -80,14 +80,14 @@ module Ruport
80
80
  mkdir project
81
81
  puts "creating directories.."
82
82
  %w[ test config output data data/models lib lib/reports
83
- lib/renderers templates sql log util ].each do |d|
83
+ lib/renderers sql util ].each do |d|
84
84
  m="#{project}/#{d}"
85
85
  puts " #{m}"
86
86
  mkdir(m)
87
87
  end
88
88
 
89
89
  puts "creating files.."
90
- %w[reports helpers renderers].each { |f|
90
+ %w[reports helpers renderers templates].each { |f|
91
91
  m = "#{project}/lib/#{f}.rb"
92
92
  puts " #{m}"
93
93
  touch(m)
@@ -175,7 +175,7 @@ REP = <<EOR
175
175
  require "lib/init"
176
176
  class #{class_name} < Ruport::Report
177
177
 
178
- def renderable_data
178
+ def renderable_data(format)
179
179
 
180
180
  end
181
181
 
@@ -283,6 +283,7 @@ require "ruport"
283
283
  require "ruport/util"
284
284
  require "lib/helpers"
285
285
  require "config/environment"
286
+ require "lib/templates"
286
287
  END_INIT
287
288
 
288
289
  README = <<END_README
@@ -22,8 +22,7 @@ module Ruport
22
22
 
23
23
  extend Forwardable
24
24
 
25
- # Creates a new Mailer object. Optionally, you can select a mailer
26
- # specified by Ruport::Config.
25
+ # Creates a new Mailer object. Optionally, you can select a mailer by label
27
26
  #
28
27
  # Example:
29
28
  #
@@ -31,7 +30,7 @@ module Ruport
31
30
  # a = Mailer.new :foo # uses :foo mail config from Ruport::Config
32
31
  #
33
32
  def initialize( mailer_label=:default )
34
- select_mailer(mailer_label);
33
+ select_mailer(mailer_label)
35
34
  mail_object.from = @mailer.address if mail_object.from.to_s.empty?
36
35
  rescue
37
36
  raise "you need to specify a mailer to use"
@@ -55,20 +54,20 @@ module Ruport
55
54
  # to 25.
56
55
  # <b><tt>:auth_type</tt></b>:: SMTP authorization method. Optional,
57
56
  # defaults to <tt>:plain</tt>.
58
- # <b><tt>:mail_klass</tt></b>:: If you don't want to use the default
57
+ # <b><tt>:mail_class</tt></b>:: If you don't want to use the default
59
58
  # <tt>MailFactory</tt> object, you can
60
59
  # pass another mailer to use here.
61
60
  #
62
61
  # Example (creating a mailer config):
63
- # mailer :alternate, :host => "mail.test.com",
64
- # :address => "test@test.com",
65
- # :user => "test",
66
- # :password => "blinky"
67
- # :auth_type => :cram_md5
62
+ # add_mailer :alternate, :host => "mail.test.com",
63
+ # :address => "test@test.com",
64
+ # :user => "test",
65
+ # :password => "blinky"
66
+ # :auth_type => :cram_md5
68
67
  #
69
68
  # Example (retreiving a mailer config):
70
- # mail_conf = mailer(:alternate) #=> <OpenStruct ..>
71
- # mail_conf.address #=> test@test.com
69
+ # mail_conf = mailers[:alternate] #=> <OpenStruct ..>
70
+ # mail_conf.address #=> test@test.com
72
71
  #
73
72
  def add_mailer(name,options)
74
73
  mailers[name] = OpenStruct.new(options)
@@ -119,12 +118,12 @@ module Ruport
119
118
  @address = @mailer.address
120
119
  @port = @mailer.port || 25
121
120
  @auth = @mailer.auth_type || :plain
122
- @mail_klass = @mailer.mail_klass
121
+ @mail_class = @mailer.mail_class
123
122
  end
124
123
 
125
124
  def mail_object
126
125
  return @mail if @mail
127
- return @mail ||= @mail_klass.new if @mail_klass
126
+ return @mail ||= @mail_class.new if @mail_class
128
127
  require "mailfactory"
129
128
  @mail ||= MailFactory.new
130
129
  end
@@ -32,7 +32,7 @@ module Ruport
32
32
  #
33
33
  # renders_as_grouping(:style => :inline)
34
34
  #
35
- # def generate
35
+ # def renderable_data(format)
36
36
  # table = Table("foo.csv")
37
37
  # Grouping(table, :by => "username")
38
38
  # end
@@ -81,9 +81,11 @@ module Ruport
81
81
  q.result
82
82
  end
83
83
  end
84
-
85
- def renderable_data #:nodoc:
86
- generate
84
+
85
+ def renderable_data(format)
86
+ raise NotImplementedError,
87
+ "You must implement renderable_data(format) if you wish to use as()
88
+ or save_as()"
87
89
  end
88
90
 
89
91
  alias_method :old_as, :as
@@ -95,16 +97,16 @@ module Ruport
95
97
  return output
96
98
  end
97
99
 
98
- def save_as(filename,options={})
100
+ def save_as(filename,options={},&block)
99
101
  formats = { "csv" => ["w",:csv], "txt" => ["w",:text],
100
102
  "html" => ["w", :html], "pdf" => ["wb", :pdf ] }
101
103
 
102
104
  fo = filename =~ /.*\.(.*)/ && formats[$1]
103
105
  flags = options.delete(:flags)
104
106
  if fo
105
- File.open(filename,flags || fo[0]) { |f| f << as(fo[1],options) }
107
+ File.open(filename,flags || fo[0]) { |f| f << as(fo[1],options,&block) }
106
108
  else
107
- File.open(filename,flags || "w") { |f| f << as($1.to_sym,options) }
109
+ File.open(filename,flags || "w") { |f| f << as($1.to_sym,options,&block) }
108
110
  end
109
111
  end
110
112
 
@@ -8,11 +8,7 @@ module Ruport
8
8
  def self.add_report(*new_reports)
9
9
  self.reports |= new_reports
10
10
  end
11
-
12
- # Looks in reports first, then models.
13
- # if there is a conflict, you are F'ed.
14
- #
15
- # just kidding, use models#find or reports#find
11
+
16
12
  def self.[](name)
17
13
  (reports + models).find{|n| n.name == name }
18
14
  end
data/lib/ruport/util.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Ruport
2
2
  module Util
3
- VERSION = "0.7.2"
3
+ VERSION = "0.8.0"
4
4
 
5
5
  file = __FILE__
6
6
  file = File.readlink(file) if File.symlink?(file)
data/test/test_report.rb CHANGED
@@ -4,7 +4,7 @@ require 'net/smtp'
4
4
  class SampleReport < Ruport::Report
5
5
  renders_with Ruport::Renderer::Table
6
6
 
7
- def generate
7
+ def renderable_data(format)
8
8
  Table(%w[not abc]) << %w[o r] << %w[one two] << %w[thr ee]
9
9
  end
10
10
  end
@@ -13,7 +13,7 @@ class MyReport < Ruport::Report
13
13
 
14
14
  attr_accessor :data
15
15
 
16
- def generate
16
+ def renderable_data(format)
17
17
  data
18
18
  end
19
19
 
@@ -55,6 +55,14 @@ describe 'Writing Report to files' do
55
55
  file_mock(mode = 'w', filename = 'foo.csv',
56
56
  content = "not,abc\no,r\none,two\nthr,ee\n")
57
57
  @report.save_as(filename).should_not be_nil
58
+ end
59
+
60
+ it 'should yield the renderer object' do
61
+ file_mock(mode = 'w', filename = 'foo.csv',
62
+ content = "not,abc\no,r\none,two\nthr,ee\n")
63
+ @report.save_as(filename) do |r|
64
+ r.should be_an_instance_of(Ruport::Renderer::Table)
65
+ end
58
66
  end
59
67
  end
60
68
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ruport-util
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.2
7
- date: 2007-07-05 00:00:00 -04:00
6
+ version: 0.8.0
7
+ date: 2007-08-28 00:00:00 -04:00
8
8
  summary: A set of tools and helper libs for Ruby Reports
9
9
  require_paths:
10
10
  - lib
@@ -30,50 +30,50 @@ authors:
30
30
  - Gregory Brown
31
31
  files:
32
32
  - example/data
33
- - example/data/blank.ods
34
- - example/mailer.rb
35
33
  - example/form.rb
36
- - example/ods.rb
34
+ - example/graph_report.rb
37
35
  - example/invoice_report.rb
36
+ - example/mailer.rb
38
37
  - example/managed_report.rb
39
- - example/graph_report.rb
38
+ - example/ods.rb
39
+ - example/data/blank.ods
40
40
  - lib/ruport
41
41
  - lib/ruport/util
42
- - lib/ruport/util/pdf
43
- - lib/ruport/util/pdf/form.rb
44
- - lib/ruport/util/generator.rb
42
+ - lib/ruport/util.rb
45
43
  - lib/ruport/util/bench.rb
44
+ - lib/ruport/util/generator.rb
46
45
  - lib/ruport/util/graph.rb
47
- - lib/ruport/util/ods.rb
48
- - lib/ruport/util/report_manager.rb
46
+ - lib/ruport/util/invoice.rb
49
47
  - lib/ruport/util/mailer.rb
48
+ - lib/ruport/util/ods.rb
49
+ - lib/ruport/util/pdf
50
50
  - lib/ruport/util/report.rb
51
- - lib/ruport/util/invoice.rb
52
- - lib/ruport/util.rb
51
+ - lib/ruport/util/report_manager.rb
52
+ - lib/ruport/util/pdf/form.rb
53
53
  - test/helper
54
+ - test/helper.rb
55
+ - test/samples
56
+ - test/test_format_ods.rb
57
+ - test/test_graph_renderer.rb
58
+ - test/test_invoice.rb
59
+ - test/test_mailer.rb
60
+ - test/test_report.rb
61
+ - test/test_report_manager.rb
54
62
  - test/helper/layout.rb
55
63
  - test/helper/wrap.rb
56
- - test/samples
57
64
  - test/samples/data.csv
58
65
  - test/samples/foo.rtxt
59
- - test/test_mailer.rb
60
- - test/helper.rb
61
- - test/test_report_manager.rb
62
- - test/test_graph_renderer.rb
63
- - test/test_report.rb
64
- - test/test_invoice.rb
65
- - test/test_format_ods.rb
66
66
  - bin/csv2ods
67
67
  - bin/rope
68
68
  - Rakefile
69
69
  - INSTALL
70
70
  test_files:
71
- - test/test_mailer.rb
72
- - test/test_report_manager.rb
71
+ - test/test_format_ods.rb
73
72
  - test/test_graph_renderer.rb
74
- - test/test_report.rb
75
73
  - test/test_invoice.rb
76
- - test/test_format_ods.rb
74
+ - test/test_mailer.rb
75
+ - test/test_report.rb
76
+ - test/test_report_manager.rb
77
77
  rdoc_options:
78
78
  - --title
79
79
  - ruport-util Documentation
@@ -97,7 +97,7 @@ dependencies:
97
97
  requirements:
98
98
  - - ">="
99
99
  - !ruby/object:Gem::Version
100
- version: 0.11.0
100
+ version: 1.2.0
101
101
  version:
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: scruffy