kpi 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/kpi/entry.rb +6 -1
- data/app/models/kpi/merged_report.rb +2 -1
- data/test/unit/kpi/entry_test.rb +26 -0
- data/test/unit/kpi/merged_report_test.rb +18 -6
- metadata +52 -21
data/app/models/kpi/entry.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
module KPI
|
2
2
|
class Entry
|
3
|
-
attr_reader :name, :value, :description, :unit
|
3
|
+
attr_reader :name, :value, :description, :unit, :important
|
4
4
|
def initialize(*args)
|
5
5
|
options = args.extract_options!
|
6
6
|
raise ArgumentError, "Wrong number of arguments (#{args.count} of 2)" unless args.count == 2
|
7
7
|
@name, @value = args
|
8
8
|
@description = options[:description]
|
9
|
+
@important = options[:important] || false
|
9
10
|
@unit = options[:unit]
|
10
11
|
end
|
11
12
|
|
13
|
+
def important?
|
14
|
+
!!self.important
|
15
|
+
end
|
16
|
+
|
12
17
|
def to_a
|
13
18
|
[@title, @value, @description, @unit].compact
|
14
19
|
end
|
@@ -40,7 +40,8 @@ module KPI
|
|
40
40
|
KPI::Entry.new(result.name.gsub("$$", orginal.name),
|
41
41
|
result.value,
|
42
42
|
:description => description,
|
43
|
-
:unit => (result.unit || orginal.unit)
|
43
|
+
:unit => (result.unit || orginal.unit),
|
44
|
+
:important => (result.important? || orginal.important?))
|
44
45
|
end
|
45
46
|
|
46
47
|
private
|
data/test/unit/kpi/entry_test.rb
CHANGED
@@ -36,5 +36,31 @@ describe "KPI::Entry" do
|
|
36
36
|
assert_equal("EUR", @entry.unit)
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
describe "when entry is important" do
|
41
|
+
before { @entry = KPI::Entry.new "Income", 1294.23, :important => true }
|
42
|
+
|
43
|
+
it "returns true" do
|
44
|
+
assert @entry.important
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe :important? do
|
49
|
+
describe "when entry is important" do
|
50
|
+
before { @entry = KPI::Entry.new "Income", 1294.23, :important => true }
|
51
|
+
|
52
|
+
it "returns true" do
|
53
|
+
assert @entry.important?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "when entry is not important" do
|
58
|
+
before { @entry = KPI::Entry.new "Income", 1294.23 }
|
59
|
+
|
60
|
+
it "returns false" do
|
61
|
+
assert !@entry.important?
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
39
65
|
end
|
40
66
|
end
|
@@ -14,7 +14,7 @@ describe "KPI::MergedReport" do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_kpi_2
|
17
|
-
result "title 2 ", @return*2, :unit => 'EUR'
|
17
|
+
result "title 2 ", @return*2, :unit => 'EUR', :important => true
|
18
18
|
end
|
19
19
|
end
|
20
20
|
class AnotherReport < KPI::Report
|
@@ -79,11 +79,15 @@ describe "KPI::MergedReport" do
|
|
79
79
|
it "should change $$ in description to indicator descripiton" do
|
80
80
|
assert_equal "description (average)", @average.test_kpi.description
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
|
+
it "should return nil description when no description" do
|
84
|
+
assert_nil @average.test_kpi_2.description
|
85
|
+
end
|
86
|
+
|
83
87
|
it "should have unit" do
|
84
88
|
assert_equal "EUR", @average.test_kpi_2.unit
|
85
89
|
end
|
86
|
-
|
90
|
+
|
87
91
|
it "should allow to override unit" do
|
88
92
|
@merged = KPI::MergedReport.new(@report1, @report2) do |*entries|
|
89
93
|
KPI::Entry.new "merged $$", 1, :unit => "$"
|
@@ -91,9 +95,17 @@ describe "KPI::MergedReport" do
|
|
91
95
|
assert_equal '$', @merged.test_kpi.unit
|
92
96
|
assert_equal '$', @merged.test_kpi_2.unit
|
93
97
|
end
|
94
|
-
|
95
|
-
it "should
|
96
|
-
|
98
|
+
|
99
|
+
it "should pass important flag" do
|
100
|
+
assert @average.test_kpi_2.important?
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should allow to override important flag" do
|
104
|
+
@merged = KPI::MergedReport.new(@report1, @report2) do |*entries|
|
105
|
+
KPI::Entry.new "merged $$", 1, :important => true
|
106
|
+
end
|
107
|
+
assert @merged.test_kpi.important?
|
108
|
+
assert @merged.test_kpi_2.important?
|
97
109
|
end
|
98
110
|
|
99
111
|
describe "entries" do
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kpi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 7
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 6
|
10
|
+
version: 0.5.6
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Artur Roszczyk
|
@@ -10,75 +15,98 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-18 00:00:00 +02:00
|
14
19
|
default_executable:
|
15
20
|
dependencies:
|
16
21
|
- !ruby/object:Gem::Dependency
|
17
22
|
name: actionmailer
|
18
|
-
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
19
24
|
none: false
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 5
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 3
|
23
32
|
version: "2.3"
|
24
|
-
type: :runtime
|
25
33
|
prerelease: false
|
26
|
-
|
34
|
+
type: :runtime
|
35
|
+
requirement: *id001
|
27
36
|
- !ruby/object:Gem::Dependency
|
28
37
|
name: activesupport
|
29
|
-
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
30
39
|
none: false
|
31
40
|
requirements:
|
32
41
|
- - ">="
|
33
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 5
|
44
|
+
segments:
|
45
|
+
- 2
|
46
|
+
- 3
|
34
47
|
version: "2.3"
|
35
|
-
type: :runtime
|
36
48
|
prerelease: false
|
37
|
-
|
49
|
+
type: :runtime
|
50
|
+
requirement: *id002
|
38
51
|
- !ruby/object:Gem::Dependency
|
39
52
|
name: minitest
|
40
|
-
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
41
54
|
none: false
|
42
55
|
requirements:
|
43
56
|
- - ">="
|
44
57
|
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
45
61
|
version: "0"
|
46
|
-
type: :development
|
47
62
|
prerelease: false
|
48
|
-
|
63
|
+
type: :development
|
64
|
+
requirement: *id003
|
49
65
|
- !ruby/object:Gem::Dependency
|
50
66
|
name: bundler
|
51
|
-
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
52
68
|
none: false
|
53
69
|
requirements:
|
54
70
|
- - ~>
|
55
71
|
- !ruby/object:Gem::Version
|
72
|
+
hash: 15
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 0
|
56
76
|
version: "1.0"
|
57
|
-
type: :development
|
58
77
|
prerelease: false
|
59
|
-
|
78
|
+
type: :development
|
79
|
+
requirement: *id004
|
60
80
|
- !ruby/object:Gem::Dependency
|
61
81
|
name: jeweler
|
62
|
-
|
82
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
63
83
|
none: false
|
64
84
|
requirements:
|
65
85
|
- - ~>
|
66
86
|
- !ruby/object:Gem::Version
|
87
|
+
hash: 7
|
88
|
+
segments:
|
89
|
+
- 1
|
90
|
+
- 5
|
91
|
+
- 2
|
67
92
|
version: 1.5.2
|
68
|
-
type: :development
|
69
93
|
prerelease: false
|
70
|
-
|
94
|
+
type: :development
|
95
|
+
requirement: *id005
|
71
96
|
- !ruby/object:Gem::Dependency
|
72
97
|
name: rcov
|
73
|
-
|
98
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
74
99
|
none: false
|
75
100
|
requirements:
|
76
101
|
- - ">="
|
77
102
|
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
78
106
|
version: "0"
|
79
|
-
type: :development
|
80
107
|
prerelease: false
|
81
|
-
|
108
|
+
type: :development
|
109
|
+
requirement: *id006
|
82
110
|
description: This gem helps you to track key indicators in your Rails app.
|
83
111
|
email: artur.roszczyk@gmail.com
|
84
112
|
executables: []
|
@@ -120,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
148
|
requirements:
|
121
149
|
- - ">="
|
122
150
|
- !ruby/object:Gem::Version
|
123
|
-
hash:
|
151
|
+
hash: 3
|
124
152
|
segments:
|
125
153
|
- 0
|
126
154
|
version: "0"
|
@@ -129,6 +157,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
157
|
requirements:
|
130
158
|
- - ">="
|
131
159
|
- !ruby/object:Gem::Version
|
160
|
+
hash: 3
|
161
|
+
segments:
|
162
|
+
- 0
|
132
163
|
version: "0"
|
133
164
|
requirements: []
|
134
165
|
|