jzimmek-reportme 0.6.0 → 0.7.2

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.7.2
@@ -4,15 +4,28 @@ module Reportme
4
4
  attr_accessor :name
5
5
  attr_accessor :setup_callback
6
6
 
7
- def initialize(report_factory, name, temporary=false)
7
+ def initialize(report_factory, name, opts={})
8
8
 
9
9
  name = name.to_sym
10
10
 
11
+ opts = {
12
+ :temporary => false,
13
+ :engine => "InnoDB",
14
+ :table_prefix => nil
15
+ }.merge(opts)
16
+
11
17
  @report_factory = report_factory
12
18
  @name = name
13
19
  @depends_on = []
14
20
  @histories = []
15
- @temporary = temporary
21
+
22
+ @temporary = opts[:temporary]
23
+ @engine = opts[:engine]
24
+ @table_prefix = opts[:table_prefix]
25
+ end
26
+
27
+ def engine
28
+ @engine
16
29
  end
17
30
 
18
31
  def temporary?
@@ -59,7 +72,9 @@ module Reportme
59
72
  end
60
73
 
61
74
  def table_name(period)
62
- prefix = temporary? ? "tmp_" : ""
75
+ prefix = ""
76
+ prefix << "tmp_" if temporary?
77
+ prefix << @table_prefix + "_" if @table_prefix
63
78
  "#{prefix}#{name}_#{period}"
64
79
  end
65
80
 
@@ -75,7 +75,7 @@ module Reportme
75
75
 
76
76
  sql = report.sql('0000-00-00 00:00:00', '0000-00-00 00:00:00', :day)
77
77
 
78
- exec("create table #{table_name} ENGINE=InnoDB default CHARSET=utf8 as #{sql} limit 0;")
78
+ exec("create table #{table_name} ENGINE=#{report.engine} default CHARSET=utf8 as #{sql} limit 0;")
79
79
  exec("alter table #{table_name} modify von datetime;")
80
80
  exec("alter table #{table_name} add index(von);")
81
81
 
@@ -437,9 +437,9 @@ module Reportme
437
437
 
438
438
  end
439
439
 
440
- def self.report(name, temporary=false, &block)
440
+ def self.report(name, opts={}, &block)
441
441
 
442
- r = Report.new(self, name, temporary)
442
+ r = Report.new(self, name, opts)
443
443
  r.instance_eval(&block)
444
444
 
445
445
  @@reports << r
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jzimmek-reportme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Zimmek
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-13 00:00:00 -07:00
12
+ date: 2009-08-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15