averager 0.1.0 → 0.2.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.
- data/.bundle/config +2 -0
- data/.rspec +2 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +38 -0
- data/LICENSE +20 -0
- data/README.rdoc +12 -43
- data/Rakefile +53 -26
- data/VERSION +1 -0
- data/averager.gemspec +81 -0
- data/lib/averager.rb +13 -4
- data/spec/averager_spec.rb +24 -11
- data/spec/spec_helper.rb +24 -8
- data/spec/time_travel.rb +1 -0
- metadata +149 -34
- data/History.txt +0 -4
- data/Manifest.txt +0 -14
- data/PostInstall.txt +0 -7
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/spec/spec.opts +0 -1
- data/tasks/rspec.rake +0 -21
data/.bundle/config
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
|
|
3
|
+
group :development do
|
|
4
|
+
if RUBY_VERSION.match(/^1\.8/)
|
|
5
|
+
gem 'ruby-debug'
|
|
6
|
+
elsif RUBY_VERSION.match(/^1\.9/)
|
|
7
|
+
gem 'ruby-debug19'
|
|
8
|
+
end
|
|
9
|
+
gem "rspec", ">= 2.0.0.beta.19"
|
|
10
|
+
gem "bundler", "~> 1.0.0"
|
|
11
|
+
gem "jeweler", "~> 1.5.0.pre3"
|
|
12
|
+
gem "rcov", ">= 0"
|
|
13
|
+
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
columnize (0.3.1)
|
|
5
|
+
diff-lcs (1.1.2)
|
|
6
|
+
git (1.2.5)
|
|
7
|
+
jeweler (1.5.0.pre5)
|
|
8
|
+
bundler (~> 1.0.0)
|
|
9
|
+
git (>= 1.2.5)
|
|
10
|
+
rake
|
|
11
|
+
linecache (0.43)
|
|
12
|
+
rake (0.8.7)
|
|
13
|
+
rcov (0.9.9)
|
|
14
|
+
rspec (2.0.1)
|
|
15
|
+
rspec-core (~> 2.0.1)
|
|
16
|
+
rspec-expectations (~> 2.0.1)
|
|
17
|
+
rspec-mocks (~> 2.0.1)
|
|
18
|
+
rspec-core (2.0.1)
|
|
19
|
+
rspec-expectations (2.0.1)
|
|
20
|
+
diff-lcs (>= 1.1.2)
|
|
21
|
+
rspec-mocks (2.0.1)
|
|
22
|
+
rspec-core (~> 2.0.1)
|
|
23
|
+
rspec-expectations (~> 2.0.1)
|
|
24
|
+
ruby-debug (0.10.3)
|
|
25
|
+
columnize (>= 0.1)
|
|
26
|
+
ruby-debug-base (~> 0.10.3.0)
|
|
27
|
+
ruby-debug-base (0.10.3)
|
|
28
|
+
linecache (>= 0.3)
|
|
29
|
+
|
|
30
|
+
PLATFORMS
|
|
31
|
+
ruby
|
|
32
|
+
|
|
33
|
+
DEPENDENCIES
|
|
34
|
+
bundler (~> 1.0.0)
|
|
35
|
+
jeweler (~> 1.5.0.pre3)
|
|
36
|
+
rcov
|
|
37
|
+
rspec (>= 2.0.0.beta.19)
|
|
38
|
+
ruby-debug
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2010 Tobias Schwab
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
|
@@ -1,48 +1,17 @@
|
|
|
1
1
|
= averager
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Description goes here.
|
|
4
4
|
|
|
5
|
-
==
|
|
5
|
+
== Note on Patches/Pull Requests
|
|
6
|
+
|
|
7
|
+
* Fork the project.
|
|
8
|
+
* Make your feature addition or bug fix.
|
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
|
10
|
+
future version unintentionally.
|
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
|
6
14
|
|
|
7
|
-
|
|
15
|
+
== Copyright
|
|
8
16
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* FIX (list of features or problems)
|
|
12
|
-
|
|
13
|
-
== SYNOPSIS:
|
|
14
|
-
|
|
15
|
-
FIX (code sample of usage)
|
|
16
|
-
|
|
17
|
-
== REQUIREMENTS:
|
|
18
|
-
|
|
19
|
-
* FIX (list of requirements)
|
|
20
|
-
|
|
21
|
-
== INSTALL:
|
|
22
|
-
|
|
23
|
-
* sudo gem install averager
|
|
24
|
-
|
|
25
|
-
== LICENSE:
|
|
26
|
-
|
|
27
|
-
(The MIT License)
|
|
28
|
-
|
|
29
|
-
Copyright (c) 2010 FIXME full name
|
|
30
|
-
|
|
31
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
32
|
-
a copy of this software and associated documentation files (the
|
|
33
|
-
'Software'), to deal in the Software without restriction, including
|
|
34
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
35
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
36
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
37
|
-
the following conditions:
|
|
38
|
-
|
|
39
|
-
The above copyright notice and this permission notice shall be
|
|
40
|
-
included in all copies or substantial portions of the Software.
|
|
41
|
-
|
|
42
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
43
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
44
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
45
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
46
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
47
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
48
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
17
|
+
Copyright (c) 2010 Tobias Schwab. See LICENSE for details.
|
data/Rakefile
CHANGED
|
@@ -1,26 +1,53 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
#
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler'
|
|
3
|
+
begin
|
|
4
|
+
Bundler.setup(:default, :development)
|
|
5
|
+
rescue Bundler::BundlerError => e
|
|
6
|
+
$stderr.puts e.message
|
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
8
|
+
exit e.status_code
|
|
9
|
+
end
|
|
10
|
+
require 'rake'
|
|
11
|
+
|
|
12
|
+
require 'jeweler'
|
|
13
|
+
Jeweler::Tasks.new do |gem|
|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
15
|
+
gem.name = "averager"
|
|
16
|
+
gem.summary = %Q{RubyGem to track long running processes.}
|
|
17
|
+
gem.description = %Q{RubyGem to track long running processes.}
|
|
18
|
+
gem.email = "tobias.schwab@dynport.de"
|
|
19
|
+
gem.homepage = "http://github.com/tobstarr/averager"
|
|
20
|
+
gem.authors = ["Tobias Schwab"]
|
|
21
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
|
22
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
|
23
|
+
# spec.add_runtime_dependency 'jabber4r', '> 0.1'
|
|
24
|
+
# spec.add_development_dependency 'rspec', '> 1.2.3'
|
|
25
|
+
gem.add_development_dependency "rspec", ">= 2.0.0.beta.19"
|
|
26
|
+
gem.add_development_dependency "bundler", "~> 1.0.0"
|
|
27
|
+
gem.add_development_dependency "jeweler", "~> 1.5.0.pre3"
|
|
28
|
+
gem.add_development_dependency "rcov", ">= 0"
|
|
29
|
+
end
|
|
30
|
+
Jeweler::RubygemsDotOrgTasks.new
|
|
31
|
+
|
|
32
|
+
require 'rspec/core'
|
|
33
|
+
require 'rspec/core/rake_task'
|
|
34
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
35
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
39
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
40
|
+
spec.rcov = true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
task :default => :spec
|
|
44
|
+
|
|
45
|
+
require 'rake/rdoctask'
|
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
48
|
+
|
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
50
|
+
rdoc.title = "averager #{version}"
|
|
51
|
+
rdoc.rdoc_files.include('README*')
|
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
53
|
+
end
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.2.0
|
data/averager.gemspec
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = %q{averager}
|
|
8
|
+
s.version = "0.2.0"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Tobias Schwab"]
|
|
12
|
+
s.date = %q{2010-11-03}
|
|
13
|
+
s.description = %q{RubyGem to track long running processes.}
|
|
14
|
+
s.email = %q{tobias.schwab@dynport.de}
|
|
15
|
+
s.extra_rdoc_files = [
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"README.rdoc"
|
|
18
|
+
]
|
|
19
|
+
s.files = [
|
|
20
|
+
".bundle/config",
|
|
21
|
+
".rspec",
|
|
22
|
+
"Gemfile",
|
|
23
|
+
"Gemfile.lock",
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"README.rdoc",
|
|
26
|
+
"Rakefile",
|
|
27
|
+
"VERSION",
|
|
28
|
+
"averager.gemspec",
|
|
29
|
+
"lib/averager.rb",
|
|
30
|
+
"spec/averager_spec.rb",
|
|
31
|
+
"spec/spec_helper.rb",
|
|
32
|
+
"spec/time_travel.rb"
|
|
33
|
+
]
|
|
34
|
+
s.homepage = %q{http://github.com/tobstarr/averager}
|
|
35
|
+
s.require_paths = ["lib"]
|
|
36
|
+
s.rubygems_version = %q{1.3.7}
|
|
37
|
+
s.summary = %q{RubyGem to track long running processes.}
|
|
38
|
+
s.test_files = [
|
|
39
|
+
"spec/averager_spec.rb",
|
|
40
|
+
"spec/spec_helper.rb",
|
|
41
|
+
"spec/time_travel.rb"
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
if s.respond_to? :specification_version then
|
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
46
|
+
s.specification_version = 3
|
|
47
|
+
|
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
49
|
+
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
|
50
|
+
s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
|
51
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
52
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
|
|
53
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
|
54
|
+
s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
|
55
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
56
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
|
|
57
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
|
58
|
+
else
|
|
59
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
|
60
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
|
61
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
62
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
|
|
63
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
64
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
|
65
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
66
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
|
|
67
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
68
|
+
end
|
|
69
|
+
else
|
|
70
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
|
71
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
|
72
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
73
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
|
|
74
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
75
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
|
76
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
77
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.0.pre3"])
|
|
78
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
data/lib/averager.rb
CHANGED
|
@@ -2,8 +2,6 @@ $:.unshift(File.dirname(__FILE__)) unless
|
|
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
|
3
3
|
|
|
4
4
|
class Averager
|
|
5
|
-
VERSION = '0.1.0'
|
|
6
|
-
|
|
7
5
|
module ArrayExtensions
|
|
8
6
|
def each_with_avg(options = {})
|
|
9
7
|
options[:expected] ||= self.length
|
|
@@ -57,6 +55,7 @@ class Averager
|
|
|
57
55
|
end
|
|
58
56
|
|
|
59
57
|
def print_current(status = nil)
|
|
58
|
+
return if @i == 0
|
|
60
59
|
per_second = @i / (Time.now - @started)
|
|
61
60
|
out = nil
|
|
62
61
|
if block_given?
|
|
@@ -64,10 +63,20 @@ class Averager
|
|
|
64
63
|
else
|
|
65
64
|
out = "%#{@digits}d" % @i
|
|
66
65
|
if @expected
|
|
67
|
-
out << "/#{@expected}"
|
|
66
|
+
out << "/#{@expected}"
|
|
68
67
|
out << " %3.1f%" % (100 * (@i / @expected.to_f)) if @i <= @expected
|
|
69
68
|
end
|
|
70
|
-
out << " (%.1f
|
|
69
|
+
out << " (%.1f/second" % [per_second]
|
|
70
|
+
if !per_second.infinite? && @expected && @i < @expected
|
|
71
|
+
missing = @expected - @i
|
|
72
|
+
seconds = missing / per_second
|
|
73
|
+
hours = (seconds / 3600.0).floor
|
|
74
|
+
seconds -= (hours * 3600)
|
|
75
|
+
minutes = (seconds / 60.0).floor
|
|
76
|
+
seconds -= (minutes * 60)
|
|
77
|
+
out << " %02d:%02d:%02d" % [hours, minutes, seconds]
|
|
78
|
+
end
|
|
79
|
+
out << ")"
|
|
71
80
|
out << ": #{status}" if status
|
|
72
81
|
end
|
|
73
82
|
if @progress_bar
|
data/spec/averager_spec.rb
CHANGED
|
@@ -13,20 +13,20 @@ describe "Place your specs here" do
|
|
|
13
13
|
avg = Averager.new(:log_path => @log_path, :every => 10, :digits => 3)
|
|
14
14
|
TimeTravel.jump(1)
|
|
15
15
|
avg.avg(100, "test")
|
|
16
|
-
File.read(@log_path).should == %(100 (100.0): test\n)
|
|
16
|
+
File.read(@log_path).should == %(100 (100.0/second): test\n)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "should only print every x seconds" do
|
|
20
20
|
avg = Averager.new(:log_path => @log_path, :every => 10, :digits => 3)
|
|
21
21
|
TimeTravel.jump(1)
|
|
22
22
|
avg.avg(100, "test")
|
|
23
|
-
File.read(@log_path).should == %(100 (100.0): test\n)
|
|
23
|
+
File.read(@log_path).should == %(100 (100.0/second): test\n)
|
|
24
24
|
TimeTravel.jump(1)
|
|
25
25
|
avg.avg(200, "test")
|
|
26
|
-
File.read(@log_path).should == %(100 (100.0): test\n)
|
|
26
|
+
File.read(@log_path).should == %(100 (100.0/second): test\n)
|
|
27
27
|
TimeTravel.jump(9)
|
|
28
28
|
avg.avg(1100, "test")
|
|
29
|
-
File.read(@log_path).should == %(100 (100.0): test\n1100 (100.0): test\n)
|
|
29
|
+
File.read(@log_path).should == %(100 (100.0/second): test\n1100 (100.0/second): test\n)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it "should include a percentage and estimated end time" do
|
|
@@ -35,17 +35,17 @@ describe "Place your specs here" do
|
|
|
35
35
|
avg.avg(500, "500")
|
|
36
36
|
TimeTravel.jump(1)
|
|
37
37
|
avg.avg(750, "750")
|
|
38
|
-
File.read(@log_path).should == %( 500/1000 50.0% (500.0): 500\n 750/1000 75.0% (375.0): 750\n)
|
|
38
|
+
File.read(@log_path).should == %( 500/1000 50.0% (500.0/second 00:00:01): 500\n 750/1000 75.0% (375.0/second 00:00:00): 750\n)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "should print a progress when asked for" do
|
|
42
42
|
avg = Averager.new(:log_path => @log_path, :expected => 1000, :every => 1.0, :progress_bar => true)
|
|
43
43
|
TimeTravel.jump(1)
|
|
44
44
|
avg.avg(500, "500")
|
|
45
|
-
File.read(@log_path).should == %( 500/1000 50.0% (500.0): 500)
|
|
45
|
+
File.read(@log_path).should == %( 500/1000 50.0% (500.0/second 00:00:01): 500)
|
|
46
46
|
TimeTravel.jump(1)
|
|
47
47
|
avg.avg(750, "750")
|
|
48
|
-
File.read(@log_path).should == %( 750/1000 75.0% (375.0): 750)
|
|
48
|
+
File.read(@log_path).should == %( 750/1000 75.0% (375.0/second 00:00:00): 750)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "should not be mandatory to call with integer" do
|
|
@@ -54,7 +54,7 @@ describe "Place your specs here" do
|
|
|
54
54
|
avg.avg
|
|
55
55
|
TimeTravel.jump(1)
|
|
56
56
|
avg.avg
|
|
57
|
-
File.read(@log_path).should == %(1/2 50.0% (1.0)\n2/2 100.0% (1.0)\n)
|
|
57
|
+
File.read(@log_path).should == %(1/2 50.0% (1.0/second 00:00:01)\n2/2 100.0% (1.0/second)\n)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
it "should be able to be called with a block" do
|
|
@@ -64,7 +64,20 @@ describe "Place your specs here" do
|
|
|
64
64
|
TimeTravel.jump(1)
|
|
65
65
|
avg.avg
|
|
66
66
|
end
|
|
67
|
-
File.read(@log_path).should == %(1/2 50.0% (1.0)\n2/2 100.0% (1.0)\nfinished in 2.0\n)
|
|
67
|
+
File.read(@log_path).should == %(1/2 50.0% (1.0/second 00:00:01)\n2/2 100.0% (1.0/second)\nfinished in 2.0\n)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should not break on printing first and per_second is null" do
|
|
71
|
+
Averager.new(:log_path => @log_path, :expected => 2, :every => 1) do |a|
|
|
72
|
+
a.avg
|
|
73
|
+
end
|
|
74
|
+
File.read(@log_path).should == "1/2 50.0% (inf/second)\nfinished in 0.0\n"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should not break when per_second is 0.0" do
|
|
78
|
+
Averager.new(:log_path => @log_path, :expected => 2, :every => 1) do |a|
|
|
79
|
+
a.avg(0.0)
|
|
80
|
+
end
|
|
68
81
|
end
|
|
69
82
|
|
|
70
83
|
it "should print the last status when finished before" do
|
|
@@ -76,13 +89,13 @@ describe "Place your specs here" do
|
|
|
76
89
|
TimeTravel.jump(1)
|
|
77
90
|
avg.avg
|
|
78
91
|
end
|
|
79
|
-
File.read(@log_path).should == %(1/3 33.3% (1.0)\n3/3 100.0% (1.0)\nfinished in 3.0\n)
|
|
92
|
+
File.read(@log_path).should == %(1/3 33.3% (1.0/second 00:00:02)\n3/3 100.0% (1.0/second)\nfinished in 3.0\n)
|
|
80
93
|
end
|
|
81
94
|
|
|
82
95
|
it "should be able to average over an array" do
|
|
83
96
|
[1, 2, 3, 4].each_with_avg(:log_path => @log_path) do |i|
|
|
84
97
|
TimeTravel.jump(1)
|
|
85
98
|
end
|
|
86
|
-
File.read(@log_path).should == %(1/4 25.0% (1.0)\n2/4 50.0% (1.0)\n3/4 75.0% (1.0)\n4/4 100.0% (1.0)\nfinished in 4.0\n)
|
|
99
|
+
File.read(@log_path).should == %(1/4 25.0% (1.0/second 00:00:03)\n2/4 50.0% (1.0/second 00:00:02)\n3/4 75.0% (1.0/second 00:00:01)\n4/4 100.0% (1.0/second)\nfinished in 4.0\n)
|
|
87
100
|
end
|
|
88
101
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
|
+
require 'bundler'
|
|
1
2
|
begin
|
|
2
|
-
|
|
3
|
-
rescue
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Bundler.setup(:default, :development)
|
|
4
|
+
rescue Bundler::BundlerError => e
|
|
5
|
+
$stderr.puts e.message
|
|
6
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
7
|
+
exit e.status_code
|
|
7
8
|
end
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
10
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
10
11
|
require 'averager'
|
|
11
|
-
require '
|
|
12
|
+
require 'rspec'
|
|
13
|
+
require 'rspec/autorun'
|
|
14
|
+
require 'time_travel'
|
|
15
|
+
|
|
16
|
+
if defined?(Debugger) && Debugger.respond_to?(:settings)
|
|
17
|
+
Debugger.settings[:autolist] = 1
|
|
18
|
+
Debugger.settings[:autoeval] = true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Requires supporting files with custom matchers and macros, etc,
|
|
22
|
+
# in ./support/ and its subdirectories.
|
|
23
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
24
|
+
|
|
25
|
+
RSpec.configure do |config|
|
|
26
|
+
|
|
27
|
+
end
|
data/spec/time_travel.rb
CHANGED
metadata
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: averager
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 23
|
|
4
5
|
prerelease: false
|
|
5
6
|
segments:
|
|
6
7
|
- 0
|
|
7
|
-
-
|
|
8
|
+
- 2
|
|
8
9
|
- 0
|
|
9
|
-
version: 0.
|
|
10
|
+
version: 0.2.0
|
|
10
11
|
platform: ruby
|
|
11
12
|
authors:
|
|
12
13
|
- Tobias Schwab
|
|
@@ -14,73 +15,183 @@ autorequire:
|
|
|
14
15
|
bindir: bin
|
|
15
16
|
cert_chain: []
|
|
16
17
|
|
|
17
|
-
date: 2010-
|
|
18
|
+
date: 2010-11-03 00:00:00 +01:00
|
|
18
19
|
default_executable:
|
|
19
20
|
dependencies:
|
|
20
21
|
- !ruby/object:Gem::Dependency
|
|
21
|
-
name: rubyforge
|
|
22
22
|
prerelease: false
|
|
23
|
-
|
|
23
|
+
type: :development
|
|
24
|
+
name: ruby-debug
|
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
|
26
|
+
none: false
|
|
27
|
+
requirements:
|
|
28
|
+
- - ">="
|
|
29
|
+
- !ruby/object:Gem::Version
|
|
30
|
+
hash: 3
|
|
31
|
+
segments:
|
|
32
|
+
- 0
|
|
33
|
+
version: "0"
|
|
34
|
+
requirement: *id001
|
|
35
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
prerelease: false
|
|
37
|
+
type: :development
|
|
38
|
+
name: rspec
|
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
|
24
40
|
none: false
|
|
25
41
|
requirements:
|
|
26
42
|
- - ">="
|
|
27
43
|
- !ruby/object:Gem::Version
|
|
44
|
+
hash: 62196421
|
|
28
45
|
segments:
|
|
29
46
|
- 2
|
|
30
47
|
- 0
|
|
31
|
-
-
|
|
32
|
-
|
|
48
|
+
- 0
|
|
49
|
+
- beta
|
|
50
|
+
- 19
|
|
51
|
+
version: 2.0.0.beta.19
|
|
52
|
+
requirement: *id002
|
|
53
|
+
- !ruby/object:Gem::Dependency
|
|
54
|
+
prerelease: false
|
|
55
|
+
type: :development
|
|
56
|
+
name: bundler
|
|
57
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
|
58
|
+
none: false
|
|
59
|
+
requirements:
|
|
60
|
+
- - ~>
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
hash: 23
|
|
63
|
+
segments:
|
|
64
|
+
- 1
|
|
65
|
+
- 0
|
|
66
|
+
- 0
|
|
67
|
+
version: 1.0.0
|
|
68
|
+
requirement: *id003
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
prerelease: false
|
|
33
71
|
type: :development
|
|
34
|
-
|
|
72
|
+
name: jeweler
|
|
73
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
|
74
|
+
none: false
|
|
75
|
+
requirements:
|
|
76
|
+
- - ~>
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
hash: -1876988218
|
|
79
|
+
segments:
|
|
80
|
+
- 1
|
|
81
|
+
- 5
|
|
82
|
+
- 0
|
|
83
|
+
- pre3
|
|
84
|
+
version: 1.5.0.pre3
|
|
85
|
+
requirement: *id004
|
|
35
86
|
- !ruby/object:Gem::Dependency
|
|
36
|
-
name: hoe
|
|
37
87
|
prerelease: false
|
|
38
|
-
|
|
88
|
+
type: :development
|
|
89
|
+
name: rcov
|
|
90
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
|
39
91
|
none: false
|
|
40
92
|
requirements:
|
|
41
93
|
- - ">="
|
|
42
94
|
- !ruby/object:Gem::Version
|
|
95
|
+
hash: 3
|
|
96
|
+
segments:
|
|
97
|
+
- 0
|
|
98
|
+
version: "0"
|
|
99
|
+
requirement: *id005
|
|
100
|
+
- !ruby/object:Gem::Dependency
|
|
101
|
+
prerelease: false
|
|
102
|
+
type: :development
|
|
103
|
+
name: rspec
|
|
104
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
hash: 62196421
|
|
43
110
|
segments:
|
|
44
111
|
- 2
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
|
|
112
|
+
- 0
|
|
113
|
+
- 0
|
|
114
|
+
- beta
|
|
115
|
+
- 19
|
|
116
|
+
version: 2.0.0.beta.19
|
|
117
|
+
requirement: *id006
|
|
118
|
+
- !ruby/object:Gem::Dependency
|
|
119
|
+
prerelease: false
|
|
120
|
+
type: :development
|
|
121
|
+
name: bundler
|
|
122
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
|
123
|
+
none: false
|
|
124
|
+
requirements:
|
|
125
|
+
- - ~>
|
|
126
|
+
- !ruby/object:Gem::Version
|
|
127
|
+
hash: 23
|
|
128
|
+
segments:
|
|
129
|
+
- 1
|
|
130
|
+
- 0
|
|
131
|
+
- 0
|
|
132
|
+
version: 1.0.0
|
|
133
|
+
requirement: *id007
|
|
134
|
+
- !ruby/object:Gem::Dependency
|
|
135
|
+
prerelease: false
|
|
136
|
+
type: :development
|
|
137
|
+
name: jeweler
|
|
138
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
|
139
|
+
none: false
|
|
140
|
+
requirements:
|
|
141
|
+
- - ~>
|
|
142
|
+
- !ruby/object:Gem::Version
|
|
143
|
+
hash: -1876988218
|
|
144
|
+
segments:
|
|
145
|
+
- 1
|
|
146
|
+
- 5
|
|
147
|
+
- 0
|
|
148
|
+
- pre3
|
|
149
|
+
version: 1.5.0.pre3
|
|
150
|
+
requirement: *id008
|
|
151
|
+
- !ruby/object:Gem::Dependency
|
|
152
|
+
prerelease: false
|
|
48
153
|
type: :development
|
|
49
|
-
|
|
154
|
+
name: rcov
|
|
155
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
|
156
|
+
none: false
|
|
157
|
+
requirements:
|
|
158
|
+
- - ">="
|
|
159
|
+
- !ruby/object:Gem::Version
|
|
160
|
+
hash: 3
|
|
161
|
+
segments:
|
|
162
|
+
- 0
|
|
163
|
+
version: "0"
|
|
164
|
+
requirement: *id009
|
|
50
165
|
description: RubyGem to track long running processes.
|
|
51
|
-
email:
|
|
52
|
-
- tobias.schwab@dynport.de
|
|
166
|
+
email: tobias.schwab@dynport.de
|
|
53
167
|
executables: []
|
|
54
168
|
|
|
55
169
|
extensions: []
|
|
56
170
|
|
|
57
171
|
extra_rdoc_files:
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
- PostInstall.txt
|
|
172
|
+
- LICENSE
|
|
173
|
+
- README.rdoc
|
|
61
174
|
files:
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
175
|
+
- .bundle/config
|
|
176
|
+
- .rspec
|
|
177
|
+
- Gemfile
|
|
178
|
+
- Gemfile.lock
|
|
179
|
+
- LICENSE
|
|
65
180
|
- README.rdoc
|
|
66
181
|
- Rakefile
|
|
182
|
+
- VERSION
|
|
183
|
+
- averager.gemspec
|
|
67
184
|
- lib/averager.rb
|
|
68
|
-
- script/console
|
|
69
|
-
- script/destroy
|
|
70
|
-
- script/generate
|
|
71
185
|
- spec/averager_spec.rb
|
|
72
|
-
- spec/spec.opts
|
|
73
186
|
- spec/spec_helper.rb
|
|
74
187
|
- spec/time_travel.rb
|
|
75
|
-
- tasks/rspec.rake
|
|
76
188
|
has_rdoc: true
|
|
77
189
|
homepage: http://github.com/tobstarr/averager
|
|
78
190
|
licenses: []
|
|
79
191
|
|
|
80
|
-
post_install_message:
|
|
81
|
-
rdoc_options:
|
|
82
|
-
|
|
83
|
-
- README.rdoc
|
|
192
|
+
post_install_message:
|
|
193
|
+
rdoc_options: []
|
|
194
|
+
|
|
84
195
|
require_paths:
|
|
85
196
|
- lib
|
|
86
197
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
@@ -88,6 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
88
199
|
requirements:
|
|
89
200
|
- - ">="
|
|
90
201
|
- !ruby/object:Gem::Version
|
|
202
|
+
hash: 3
|
|
91
203
|
segments:
|
|
92
204
|
- 0
|
|
93
205
|
version: "0"
|
|
@@ -96,15 +208,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
96
208
|
requirements:
|
|
97
209
|
- - ">="
|
|
98
210
|
- !ruby/object:Gem::Version
|
|
211
|
+
hash: 3
|
|
99
212
|
segments:
|
|
100
213
|
- 0
|
|
101
214
|
version: "0"
|
|
102
215
|
requirements: []
|
|
103
216
|
|
|
104
|
-
rubyforge_project:
|
|
217
|
+
rubyforge_project:
|
|
105
218
|
rubygems_version: 1.3.7
|
|
106
219
|
signing_key:
|
|
107
220
|
specification_version: 3
|
|
108
221
|
summary: RubyGem to track long running processes.
|
|
109
|
-
test_files:
|
|
110
|
-
|
|
222
|
+
test_files:
|
|
223
|
+
- spec/averager_spec.rb
|
|
224
|
+
- spec/spec_helper.rb
|
|
225
|
+
- spec/time_travel.rb
|
data/History.txt
DELETED
data/Manifest.txt
DELETED
data/PostInstall.txt
DELETED
data/script/console
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# File: script/console
|
|
3
|
-
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
|
4
|
-
|
|
5
|
-
libs = " -r irb/completion"
|
|
6
|
-
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
|
7
|
-
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
|
8
|
-
libs << " -r #{File.dirname(__FILE__) + '/../lib/averager.rb'}"
|
|
9
|
-
puts "Loading averager gem"
|
|
10
|
-
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
3
|
-
|
|
4
|
-
begin
|
|
5
|
-
require 'rubigen'
|
|
6
|
-
rescue LoadError
|
|
7
|
-
require 'rubygems'
|
|
8
|
-
require 'rubigen'
|
|
9
|
-
end
|
|
10
|
-
require 'rubigen/scripts/destroy'
|
|
11
|
-
|
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
3
|
-
|
|
4
|
-
begin
|
|
5
|
-
require 'rubigen'
|
|
6
|
-
rescue LoadError
|
|
7
|
-
require 'rubygems'
|
|
8
|
-
require 'rubigen'
|
|
9
|
-
end
|
|
10
|
-
require 'rubigen/scripts/generate'
|
|
11
|
-
|
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
-
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/spec.opts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--colour
|
data/tasks/rspec.rake
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require 'spec'
|
|
3
|
-
rescue LoadError
|
|
4
|
-
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
|
5
|
-
require 'spec'
|
|
6
|
-
end
|
|
7
|
-
begin
|
|
8
|
-
require 'spec/rake/spectask'
|
|
9
|
-
rescue LoadError
|
|
10
|
-
puts <<-EOS
|
|
11
|
-
To use rspec for testing you must install rspec gem:
|
|
12
|
-
gem install rspec
|
|
13
|
-
EOS
|
|
14
|
-
exit(0)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
desc "Run the specs under spec/models"
|
|
18
|
-
Spec::Rake::SpecTask.new do |t|
|
|
19
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
|
20
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
21
|
-
end
|