rake-performance 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -0
- data/.rspec +2 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/autotest/discover.rb +1 -0
- data/lib/rake_performance.rb +16 -0
- data/lib/time_helper.rb +15 -0
- data/rake-performance.gemspec +52 -0
- data/spec/rake_performance_spec.rb +35 -0
- data/spec/time_helper_spec.rb +31 -0
- metadata +99 -0
data/.autotest
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'autotest/growl'
|
data/.rspec
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'jeweler'
|
2
|
+
Jeweler::Tasks.new do |gem|
|
3
|
+
gem.name = "rake-performance"
|
4
|
+
gem.summary = %{Hooks into the rake task and display performance times}
|
5
|
+
gem.description = %{Hooks into the rake task and display performance times}
|
6
|
+
gem.email = "andrew.vos@gmail.com"
|
7
|
+
gem.homepage = "http://github.com/AndrewVos/rake-performance"
|
8
|
+
gem.authors = "Andrew Vos"
|
9
|
+
gem.add_development_dependency "rspec"
|
10
|
+
gem.add_development_dependency "rake"
|
11
|
+
end
|
12
|
+
|
13
|
+
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1 @@
|
|
1
|
+
Autotest.add_discovery { "rspec2" }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'time_helper'
|
2
|
+
|
3
|
+
module Rake
|
4
|
+
class Task
|
5
|
+
alias :old_invoke :invoke
|
6
|
+
|
7
|
+
def invoke(*args)
|
8
|
+
start_time = Time.now
|
9
|
+
puts "Task '#{@name}' started at #{start_time}"
|
10
|
+
old_invoke(args)
|
11
|
+
end_time = Time.now
|
12
|
+
puts "Task '#{@name}' ended at #{end_time}"
|
13
|
+
puts "Total time taken: #{TimeHelper.time_difference(start_time, end_time)}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/time_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class TimeHelper
|
2
|
+
class << self
|
3
|
+
def time_difference(a, b)
|
4
|
+
a, b = b, a if a < b
|
5
|
+
difference = Integer(a - b)
|
6
|
+
seconds = difference % 60
|
7
|
+
difference = (difference - seconds) / 60
|
8
|
+
minutes = difference % 60
|
9
|
+
difference = (difference - minutes) / 60
|
10
|
+
hours = difference % 24
|
11
|
+
result = [hours, minutes, seconds].map { |value| value.to_s.rjust(2, "0") }
|
12
|
+
result.join(":")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rake-performance}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Andrew Vos"]
|
12
|
+
s.date = %q{2011-01-30}
|
13
|
+
s.description = %q{Hooks into the rake task and display performance times}
|
14
|
+
s.email = %q{andrew.vos@gmail.com}
|
15
|
+
s.files = [
|
16
|
+
".autotest",
|
17
|
+
".rspec",
|
18
|
+
"Rakefile",
|
19
|
+
"VERSION",
|
20
|
+
"autotest/discover.rb",
|
21
|
+
"lib/rake_performance.rb",
|
22
|
+
"lib/time_helper.rb",
|
23
|
+
"rake-performance.gemspec",
|
24
|
+
"spec/rake_performance_spec.rb",
|
25
|
+
"spec/time_helper_spec.rb"
|
26
|
+
]
|
27
|
+
s.homepage = %q{http://github.com/AndrewVos/rake-performance}
|
28
|
+
s.require_paths = ["lib"]
|
29
|
+
s.rubygems_version = %q{1.3.7}
|
30
|
+
s.summary = %q{Hooks into the rake task and display performance times}
|
31
|
+
s.test_files = [
|
32
|
+
"spec/rake_performance_spec.rb",
|
33
|
+
"spec/time_helper_spec.rb"
|
34
|
+
]
|
35
|
+
|
36
|
+
if s.respond_to? :specification_version then
|
37
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
38
|
+
s.specification_version = 3
|
39
|
+
|
40
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
42
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
43
|
+
else
|
44
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
45
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
46
|
+
end
|
47
|
+
else
|
48
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
49
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rspec'
|
3
|
+
require 'stringio'
|
4
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "rake_performance")
|
5
|
+
|
6
|
+
task :do_something_useful do
|
7
|
+
puts 'This is a rake task!'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "rake-performance" do
|
11
|
+
before :each do
|
12
|
+
task = Rake::Task[:do_something_useful]
|
13
|
+
Time.stub(:now).and_return Time.new(1983, 10, 23, 10, 10, 23), Time.new(1983, 10, 23, 11, 11, 28)
|
14
|
+
$stdout = StringIO.new
|
15
|
+
task.invoke
|
16
|
+
@output = $stdout.string
|
17
|
+
task.reenable
|
18
|
+
end
|
19
|
+
|
20
|
+
it "displays the task start time" do
|
21
|
+
@output.should include "Task \'do_something_useful\' started at 1983-10-23 10:10:23"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "displays the task end time" do
|
25
|
+
@output.should include "Task \'do_something_useful\' ended at 1983-10-23 11:11:28"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "displays a the total time taken" do
|
29
|
+
@output.should include "Total time taken: 01:01:05"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "invokes the task" do
|
33
|
+
@output.should include "This is a rake task!"
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "time_helper")
|
2
|
+
|
3
|
+
describe TimeHelper do
|
4
|
+
describe ".time_difference" do
|
5
|
+
def test_time_difference(time1, time2, expected_result)
|
6
|
+
time1 = Time.new(1983, 10, 23, time1[0], time1[1], time1[2])
|
7
|
+
time2 = Time.new(1983, 10, 23, time2[0], time2[1], time2[2])
|
8
|
+
TimeHelper.time_difference(time1, time2).should == expected_result
|
9
|
+
end
|
10
|
+
|
11
|
+
it "displays the time difference for seconds" do
|
12
|
+
test_time_difference([10, 10, 20], [10, 10, 40], "00:00:20")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "displays the time difference for minutes" do
|
16
|
+
test_time_difference([10, 5, 40], [10, 8, 40], "00:03:00")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "displays the time difference for hours" do
|
20
|
+
test_time_difference([5, 0, 0], [8, 0, 0], "03:00:00")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "displays the time difference for hours, minutes and seconds" do
|
24
|
+
test_time_difference([1, 1, 1], [4, 5, 6], "03:04:05")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "displays the time difference when the first time is greater than the second time" do
|
28
|
+
test_time_difference([4, 5, 6], [1, 1, 1], "03:04:05")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake-performance
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Andrew Vos
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-30 00:00:00 +00:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
46
|
+
description: Hooks into the rake task and display performance times
|
47
|
+
email: andrew.vos@gmail.com
|
48
|
+
executables: []
|
49
|
+
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files: []
|
53
|
+
|
54
|
+
files:
|
55
|
+
- .autotest
|
56
|
+
- .rspec
|
57
|
+
- Rakefile
|
58
|
+
- VERSION
|
59
|
+
- autotest/discover.rb
|
60
|
+
- lib/rake_performance.rb
|
61
|
+
- lib/time_helper.rb
|
62
|
+
- rake-performance.gemspec
|
63
|
+
- spec/rake_performance_spec.rb
|
64
|
+
- spec/time_helper_spec.rb
|
65
|
+
has_rdoc: true
|
66
|
+
homepage: http://github.com/AndrewVos/rake-performance
|
67
|
+
licenses: []
|
68
|
+
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
requirements: []
|
91
|
+
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 1.3.7
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: Hooks into the rake task and display performance times
|
97
|
+
test_files:
|
98
|
+
- spec/rake_performance_spec.rb
|
99
|
+
- spec/time_helper_spec.rb
|