kpi 0.5.6 → 0.6.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.
@@ -6,6 +6,8 @@ module KPI
|
|
6
6
|
raise ArgumentError, "Should have any argument" if args.length == 0
|
7
7
|
raise Exception unless block_given?
|
8
8
|
@_mode = options[:mode] || :&
|
9
|
+
@_title = options[:title]
|
10
|
+
|
9
11
|
@_reports = args
|
10
12
|
@_merge = block
|
11
13
|
end
|
@@ -19,7 +21,7 @@ module KPI
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def title
|
22
|
-
|
24
|
+
@_title || @_reports.first.title
|
23
25
|
end
|
24
26
|
|
25
27
|
def defined_kpis
|
@@ -10,7 +10,10 @@ module KPI
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def method_blacklisted?(name)
|
13
|
-
not_kpi_methods.include?(name) ||
|
13
|
+
KPI::Report.not_kpi_methods.include?(name) ||
|
14
|
+
not_kpi_methods.include?(name) ||
|
15
|
+
name =~ /_unmemoized_/ ||
|
16
|
+
!self.instance_methods(true).map(&:to_sym).include?(name)
|
14
17
|
end
|
15
18
|
|
16
19
|
def blacklist(*methods)
|
data/app/models/kpi/report.rb
CHANGED
@@ -10,8 +10,9 @@ module KPI
|
|
10
10
|
def initialize(*args)
|
11
11
|
@options = args.extract_options!
|
12
12
|
@time = @options[:time] || Time.now
|
13
|
+
@title = @options[:title] || self.class.name
|
13
14
|
end
|
14
|
-
attr_reader :time
|
15
|
+
attr_reader :time, :title
|
15
16
|
|
16
17
|
def collect!
|
17
18
|
self.defined_kpis.each {|kpi_method| send(kpi_method) }
|
@@ -26,10 +27,6 @@ module KPI
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
def title
|
30
|
-
self.class.name
|
31
|
-
end
|
32
|
-
|
33
30
|
def defined_kpis
|
34
31
|
self.class.defined_kpis.map(&:to_sym)
|
35
32
|
end
|
@@ -145,6 +145,22 @@ describe "KPI::MergedReport" do
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
+
describe :title do
|
149
|
+
before do
|
150
|
+
@partial_report = TestKpi.new
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should return title passed in options" do
|
154
|
+
report = KPI::MergedReport.new(@partial_report, :title => "my title") {}
|
155
|
+
assert_equal "my title", report.title
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should return title of first report by default" do
|
159
|
+
report = KPI::MergedReport.new(@partial_report) {}
|
160
|
+
assert_equal @partial_report.title, report.title
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
148
164
|
describe "when different reports given for merge" do
|
149
165
|
before do
|
150
166
|
@report1 = TestKpi.new(2)
|
@@ -67,6 +67,19 @@ describe "KPI::Report" do
|
|
67
67
|
it "should return class name by default" do
|
68
68
|
assert_equal "TestKpi", @kpi.title
|
69
69
|
end
|
70
|
+
|
71
|
+
it "should allow to override title in definition" do
|
72
|
+
class AnotherKpi < KPI::Report
|
73
|
+
def title; "title"; end
|
74
|
+
end
|
75
|
+
@kpi = AnotherKpi.new
|
76
|
+
assert_equal "title", @kpi.title
|
77
|
+
assert !@kpi.defined_kpis.include?(:title), 'report should not have :title KPI'
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should allow to override title in options" do
|
81
|
+
assert_equal "my title", TestKpi.new(:title => "my title").title
|
82
|
+
end
|
70
83
|
end
|
71
84
|
|
72
85
|
describe :time do
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 5
|
9
8
|
- 6
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Artur Roszczyk
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-19 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|