kpi 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,6 @@ module KPI
5
5
  extend ActiveSupport::Memoizable
6
6
 
7
7
  include KPI::Report::DynamicDefinitions
8
- include KPI::Report::MailDelivery
9
8
 
10
9
  blacklist :initialize, :collect!, :entries, :time, :title
11
10
 
@@ -0,0 +1,5 @@
1
+ require 'generator'
2
+
3
+ module KPI
4
+ Enumerator = ::Generator
5
+ end
data/lib/kpi.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module KPI
2
2
  require 'engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
3
+ require 'kpi/18compatibility' if RUBY_VERSION < '1.9'
3
4
 
4
5
  require 'kpi/configuration'
5
6
  include KPI::Configuration
@@ -1,13 +1,14 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'minitest/autorun'
4
+
3
5
  require 'active_support'
4
6
  require 'action_mailer'
5
- require 'rspec'
6
7
  require 'kpi'
7
8
 
8
9
  # Requires supporting files with custom matchers and macros, etc,
9
10
  # in ./support/ and its subdirectories.
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
+ # Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
12
 
12
13
  require File.join(File.dirname(__FILE__), '..', 'lib/kpi/configuration')
13
14
  require File.join(File.dirname(__FILE__), '..', 'app/models/kpi/entry')
@@ -17,7 +18,3 @@ require File.join(File.dirname(__FILE__), '..', 'app/models/kpi/report/mail_deli
17
18
  require File.join(File.dirname(__FILE__), '..', 'app/models/kpi/report/base')
18
19
  require File.join(File.dirname(__FILE__), '..', 'app/mailers/kpi/mailer')
19
20
 
20
-
21
- RSpec.configure do |config|
22
-
23
- end
@@ -0,0 +1,54 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
2
+
3
+ class TestKpi < KPI::Report::Base
4
+ def test_kpi
5
+ return ["title", 1, "description"]
6
+ end
7
+
8
+ def another_kpi
9
+ return ["another title", 0]
10
+ end
11
+ end
12
+
13
+ describe "KPI::Report::Base" do
14
+ it "should define indicators" do
15
+ assert_equal [:test_kpi, :another_kpi], TestKpi.defined_kpis
16
+ end
17
+
18
+ describe :collect! do
19
+ before { @kpi = TestKpi.new }
20
+ it "should collect all KPIs" do
21
+ assert_equal 2, @kpi.collect!.entries.count
22
+ end
23
+ end
24
+
25
+ describe :entries do
26
+ before { @kpi = TestKpi.new }
27
+
28
+ it "should return enumerator" do
29
+ assert @kpi.entries.kind_of?(Enumerable)
30
+ end
31
+
32
+ it "should return enumerator with entries" do
33
+ assert @kpi.entries.first.kind_of?(KPI::Entry)
34
+ end
35
+
36
+ it "should fill entries with names" do
37
+ assert_equal ["title", "another title"], @kpi.entries.map(&:name)
38
+ end
39
+
40
+ it "should fill entries with values" do
41
+ assert_equal [1, 0], @kpi.entries.map(&:value)
42
+ end
43
+
44
+ it "should fill entries with descriptions" do
45
+ assert_equal ["description", nil], @kpi.entries.map(&:description)
46
+ end
47
+ end
48
+
49
+ describe :title do
50
+ it "should return class name by default" do
51
+ assert_equal "TestKpi", TestKpi.new.title
52
+ end
53
+ end
54
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: kpi
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.3
5
+ version: 0.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Artur Roszczyk
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-14 00:00:00 +02:00
13
+ date: 2011-05-13 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -18,9 +18,9 @@ dependencies:
18
18
  requirement: &id001 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
- - - ~>
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: "3.0"
23
+ version: "2.3"
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: *id001
@@ -29,20 +29,20 @@ dependencies:
29
29
  requirement: &id002 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
- - - ~>
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: "3.0"
34
+ version: "2.3"
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency
39
- name: rspec
39
+ name: minitest
40
40
  requirement: &id003 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 2.3.0
45
+ version: "0"
46
46
  type: :development
47
47
  prerelease: false
48
48
  version_requirements: *id003
@@ -89,24 +89,20 @@ extra_rdoc_files:
89
89
  - LICENSE.txt
90
90
  - README.rdoc
91
91
  files:
92
- - app/mailers/kpi/mailer.rb
93
92
  - app/models/kpi/entry.rb
94
93
  - app/models/kpi/report/base.rb
95
94
  - app/models/kpi/report/dynamic_definitions.rb
96
- - app/models/kpi/report/mail_delivery.rb
97
95
  - app/models/kpi/report/suppress_memoization.rb
98
- - app/views/kpi/mailer/report.html.erb
99
96
  - lib/engine.rb
100
97
  - lib/generators/kpi/USAGE
101
- - lib/generators/kpi/install_generator.rb
102
98
  - lib/generators/kpi/kpi_generator.rb
103
- - lib/generators/kpi/templates/initializer.rb
104
99
  - lib/kpi.rb
100
+ - lib/kpi/18compatibility.rb
105
101
  - lib/kpi/configuration.rb
106
102
  - LICENSE.txt
107
103
  - README.rdoc
108
- - spec/models/kpi/report/base_spec.rb
109
- - spec/spec_helper.rb
104
+ - test/test_helper.rb
105
+ - test/unit/kpi/report/base_test.rb
110
106
  has_rdoc: true
111
107
  homepage: http://github.com/sevos/kpi
112
108
  licenses:
@@ -121,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
117
  requirements:
122
118
  - - ">="
123
119
  - !ruby/object:Gem::Version
124
- hash: -1444204594839301290
120
+ hash: 2602198996799805107
125
121
  segments:
126
122
  - 0
127
123
  version: "0"
@@ -139,5 +135,5 @@ signing_key:
139
135
  specification_version: 3
140
136
  summary: Key Performance Indicators for Rails 3.x
141
137
  test_files:
142
- - spec/models/kpi/report/base_spec.rb
143
- - spec/spec_helper.rb
138
+ - test/test_helper.rb
139
+ - test/unit/kpi/report/base_test.rb
@@ -1,12 +0,0 @@
1
- class KPI::Mailer < ActionMailer::Base
2
- default :from => KPI.mail_from
3
- default :to => KPI.mail_to
4
-
5
- def report(kpi_report)
6
- @entries = kpi_report.entries
7
- @time = kpi_report.time
8
- @title = kpi_report.title
9
-
10
- mail :subject => "[#{KPI.app_name} KPI][#{@time.to_date.to_s(:db)}] #{@title}"
11
- end
12
- end
@@ -1,15 +0,0 @@
1
- module KPI
2
- module Report
3
- module MailDelivery
4
- def self.included(base)
5
- base.class_eval do
6
- blacklist :send!
7
- end
8
- end
9
-
10
- def send!
11
- KPI::Mailer.report(self.collect!).deliver
12
- end
13
- end
14
- end
15
- end
@@ -1,32 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- </head>
6
-
7
- <body>
8
- <h1><%= KPI.app_name %> KPI Report</h1>
9
- <h2><%= @title %></h2>
10
- <p>Created at: <%= @time.to_s(:db) %></p>
11
- <table style="border-collapse: collapse;width: 100%;" width="100%">
12
- <tr style="border-bottom: 1px solid black;">
13
- <td>KPI</td>
14
- <td>Value</td>
15
- </tr>
16
- <% for entry in @entries %>
17
- <tr style="border-bottom: 1px solid black;">
18
- <td>
19
- <strong><%= entry.name %></strong>
20
- <% unless entry.description.blank? %>
21
- <br />
22
- <span style="color: grey; font-size: smaller;">
23
- <%= entry.description %>
24
- </span>
25
- <% end %>
26
- </td>
27
- <td style="text-align: center;"><%= entry.value %></td>
28
- </tr>
29
- <% end %>
30
- </table>
31
- </body>
32
- </html>
@@ -1,14 +0,0 @@
1
- module KPI
2
- module Generators
3
- class InstallGenerator < Rails::Generators::Base
4
- namespace "kpi:install"
5
- source_root File.expand_path('../templates', __FILE__)
6
- desc "Creates a KPI initializer."
7
-
8
- def copy_initializer
9
- template "initializer.rb", "config/initializers/kpi.rb"
10
- end
11
- end
12
- end
13
- end
14
-
@@ -1,11 +0,0 @@
1
- KPI.configure do |c|
2
- # Your application name
3
- # It appears in email subjects and inside email body
4
- c.app_name = "Your app name"
5
-
6
- # "from" field of KPI emails
7
- c.mail_from = "kpi@yourapp.com"
8
-
9
- # "to" field of KPI emails
10
- c.mail_to = "example@example.com"
11
- end
@@ -1,59 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
2
-
3
- describe "KPI::Report::Base" do
4
- before(:all) do
5
- class TestKpi < KPI::Report::Base
6
- def test_kpi
7
- return ["title", 1, "description"]
8
- end
9
-
10
- def another_kpi
11
- return ["another title", 0]
12
- end
13
- end
14
- end
15
-
16
- it "should define indicators" do
17
- TestKpi.defined_kpis.should == [:test_kpi, :another_kpi]
18
- end
19
-
20
- describe :collect! do
21
- before { @kpi = TestKpi.new }
22
- it "should call all KPIs" do
23
- TestKpi.defined_kpis.each do |kpi_method|
24
- @kpi.should_receive(kpi_method)
25
- end
26
- @kpi.collect!
27
- end
28
- end
29
-
30
- describe :entries do
31
- before { @kpi = TestKpi.new }
32
-
33
- it "should return enumerator" do
34
- @kpi.entries.should be_kind_of(Enumerable)
35
- end
36
-
37
- it "should return enumerator with entries" do
38
- @kpi.entries.first.should be_kind_of(KPI::Entry)
39
- end
40
-
41
- it "should fill entries with names" do
42
- @kpi.entries.map(&:name).should == ["title", "another title"]
43
- end
44
-
45
- it "should fill entries with values" do
46
- @kpi.entries.map(&:value).should == [1, 0]
47
- end
48
-
49
- it "should fill entries with descriptions" do
50
- @kpi.entries.map(&:description).should == ["description", nil]
51
- end
52
- end
53
-
54
- describe :title do
55
- it "should return class name by default" do
56
- TestKpi.new.title.should == "TestKpi"
57
- end
58
- end
59
- end