tach 0.0.6 → 0.0.7
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/Rakefile +119 -34
- data/lib/tach.rb +16 -2
- data/tach.gemspec +70 -47
- metadata +14 -15
- data/.document +0 -5
- data/.gitignore +0 -39
- data/VERSION +0 -1
data/Rakefile
CHANGED
@@ -1,49 +1,134 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
gem.add_dependency "formatador", ">= 0.0.12"
|
14
|
-
gem.add_development_dependency "shindo", ">= 0"
|
15
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
-
end
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
#############################################################################
|
6
|
+
#
|
7
|
+
# Helper functions
|
8
|
+
#
|
9
|
+
#############################################################################
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
19
13
|
end
|
20
14
|
|
21
|
-
|
22
|
-
|
15
|
+
def version
|
16
|
+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
+
end
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
Rcov::RcovTask.new do |tests|
|
27
|
-
tests.libs << 'tests'
|
28
|
-
tests.pattern = 'tests/**/*_tests.rb'
|
29
|
-
tests.verbose = true
|
30
|
-
end
|
31
|
-
rescue LoadError
|
32
|
-
task :rcov do
|
33
|
-
abort "RCov is not available. In order to run rcov, you must: gem install spicycode-rcov"
|
34
|
-
end
|
20
|
+
def date
|
21
|
+
Date.today.to_s
|
35
22
|
end
|
36
23
|
|
37
|
-
|
24
|
+
def rubyforge_project
|
25
|
+
name
|
26
|
+
end
|
38
27
|
|
28
|
+
def gemspec_file
|
29
|
+
"#{name}.gemspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
def gem_file
|
33
|
+
"#{name}-#{version}.gem"
|
34
|
+
end
|
35
|
+
|
36
|
+
def replace_header(head, header_name)
|
37
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
38
|
+
end
|
39
|
+
|
40
|
+
#############################################################################
|
41
|
+
#
|
42
|
+
# Standard tasks
|
43
|
+
#
|
44
|
+
#############################################################################
|
45
|
+
|
46
|
+
require 'shindo/rake'
|
47
|
+
Shindo::Rake.new
|
39
48
|
task :default => :tests
|
40
49
|
|
50
|
+
desc "Generate RCov test coverage and open in your browser"
|
51
|
+
task :coverage do
|
52
|
+
require 'rcov'
|
53
|
+
sh "rm -fr coverage"
|
54
|
+
sh "rcov test/test_*.rb"
|
55
|
+
sh "open coverage/index.html"
|
56
|
+
end
|
57
|
+
|
41
58
|
require 'rake/rdoctask'
|
42
59
|
Rake::RDocTask.new do |rdoc|
|
43
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
-
|
45
60
|
rdoc.rdoc_dir = 'rdoc'
|
46
|
-
rdoc.title = "
|
61
|
+
rdoc.title = "#{name} #{version}"
|
47
62
|
rdoc.rdoc_files.include('README*')
|
48
63
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
64
|
end
|
65
|
+
|
66
|
+
desc "Open an irb session preloaded with this library"
|
67
|
+
task :console do
|
68
|
+
sh "irb -rubygems -r ./lib/#{name}.rb"
|
69
|
+
end
|
70
|
+
|
71
|
+
#############################################################################
|
72
|
+
#
|
73
|
+
# Packaging tasks
|
74
|
+
#
|
75
|
+
#############################################################################
|
76
|
+
|
77
|
+
task :release => :build do
|
78
|
+
unless `git branch` =~ /^\* master$/
|
79
|
+
puts "You must be on the master branch to release!"
|
80
|
+
exit!
|
81
|
+
end
|
82
|
+
sh "sudo gem install pkg/#{name}-#{version}.gem"
|
83
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
84
|
+
sh "git tag v#{version}"
|
85
|
+
sh "git push origin master"
|
86
|
+
sh "git push origin v#{version}"
|
87
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
88
|
+
end
|
89
|
+
|
90
|
+
task :build => :gemspec do
|
91
|
+
sh "mkdir -p pkg"
|
92
|
+
sh "gem build #{gemspec_file}"
|
93
|
+
sh "mv #{gem_file} pkg"
|
94
|
+
end
|
95
|
+
|
96
|
+
task :gemspec => :validate do
|
97
|
+
# read spec file and split out manifest section
|
98
|
+
spec = File.read(gemspec_file)
|
99
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
100
|
+
|
101
|
+
# replace name version and date
|
102
|
+
replace_header(head, :name)
|
103
|
+
replace_header(head, :version)
|
104
|
+
replace_header(head, :date)
|
105
|
+
#comment this out if your rubyforge_project has a different name
|
106
|
+
replace_header(head, :rubyforge_project)
|
107
|
+
|
108
|
+
# determine file list from git ls-files
|
109
|
+
files = `git ls-files`.
|
110
|
+
split("\n").
|
111
|
+
sort.
|
112
|
+
reject { |file| file =~ /^\./ }.
|
113
|
+
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
114
|
+
map { |file| " #{file}" }.
|
115
|
+
join("\n")
|
116
|
+
|
117
|
+
# piece file back together and write
|
118
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
119
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
120
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
121
|
+
puts "Updated #{gemspec_file}"
|
122
|
+
end
|
123
|
+
|
124
|
+
task :validate do
|
125
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
|
126
|
+
unless libfiles.empty?
|
127
|
+
puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
|
128
|
+
exit!
|
129
|
+
end
|
130
|
+
unless Dir['VERSION*'].empty?
|
131
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
132
|
+
exit!
|
133
|
+
end
|
134
|
+
end
|
data/lib/tach.rb
CHANGED
@@ -3,6 +3,10 @@ require 'formatador'
|
|
3
3
|
|
4
4
|
module Tach
|
5
5
|
|
6
|
+
unless const_defined?(:VERSION)
|
7
|
+
VERSION = '0.0.7'
|
8
|
+
end
|
9
|
+
|
6
10
|
def self.meter(times = 1, &block)
|
7
11
|
Tach::Meter.new(times, &block)
|
8
12
|
end
|
@@ -54,9 +58,13 @@ module Tach
|
|
54
58
|
print(name)
|
55
59
|
STDOUT.flush
|
56
60
|
tach_start = Time.now
|
57
|
-
|
58
|
-
|
61
|
+
|
62
|
+
if benchmark.arity == 0
|
63
|
+
count.times { benchmark.call }
|
64
|
+
else
|
65
|
+
benchmark.call(count)
|
59
66
|
end
|
67
|
+
|
60
68
|
tach_finish = Time.now
|
61
69
|
duration = tach_finish.to_f - tach_start.to_f
|
62
70
|
duration
|
@@ -90,6 +98,12 @@ if __FILE__ == $0
|
|
90
98
|
[$1, $2]
|
91
99
|
end
|
92
100
|
|
101
|
+
tach('regex 4') do |n|
|
102
|
+
n.times do
|
103
|
+
header = data.match(/(.*):\s(.*)/)
|
104
|
+
[$1, $2]
|
105
|
+
end
|
106
|
+
end
|
93
107
|
end
|
94
108
|
|
95
109
|
require 'benchmark'
|
data/tach.gemspec
CHANGED
@@ -1,51 +1,74 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
## This is the rakegem gemspec template. Make sure you read and understand
|
2
|
+
## all of the comments. Some sections require modification, and others can
|
3
|
+
## be deleted if you don't need them. Once you understand the contents of
|
4
|
+
## this file, feel free to delete any comments that begin with two hash marks.
|
5
|
+
## You can find comprehensive Gem::Specification documentation, at
|
6
|
+
## http://docs.rubygems.org/read/chapter/20
|
6
7
|
Gem::Specification.new do |s|
|
7
|
-
s.
|
8
|
-
s.version = "0.0.6"
|
9
|
-
|
8
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
10
9
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
s.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
s.
|
10
|
+
s.rubygems_version = '1.3.5'
|
11
|
+
|
12
|
+
## Leave these as is they will be modified for you by the rake gemspec task.
|
13
|
+
## If your rubyforge_project name is different, then edit it and comment out
|
14
|
+
## the sub! line in the Rakefile
|
15
|
+
s.name = 'tach'
|
16
|
+
s.version = '0.0.7'
|
17
|
+
s.date = '2010-12-07'
|
18
|
+
s.rubyforge_project = 'tach'
|
19
|
+
|
20
|
+
## Make sure your summary is short. The description may be as long
|
21
|
+
## as you like.
|
22
|
+
s.summary = "Simple benchmarking"
|
23
|
+
s.description = "Simple benchmarking with noticable progress and pretty results."
|
24
|
+
|
25
|
+
## List the primary authors. If there are a bunch of authors, it's probably
|
26
|
+
## better to set the email to an email list or something. If you don't have
|
27
|
+
## a custom homepage, consider using your GitHub URL or the like.
|
28
|
+
s.authors = ["geemus (Wesley Beary)"]
|
29
|
+
s.email = 'geemus@gmail.com'
|
30
|
+
s.homepage = 'http://github.com/geemus/tach'
|
31
|
+
|
32
|
+
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
|
33
|
+
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
|
34
|
+
s.require_paths = %w[lib]
|
35
|
+
|
36
|
+
## This sections is only necessary if you have C extensions.
|
37
|
+
#s.require_paths << 'ext'
|
38
|
+
#s.extensions = %w[ext/extconf.rb]
|
39
|
+
|
40
|
+
## If your gem includes any executables, list them here.
|
41
|
+
#s.executables = ["name"]
|
42
|
+
#s.default_executable = 'name'
|
43
|
+
|
44
|
+
## Specify any RDoc options here. You'll want to add your README and
|
45
|
+
## LICENSE files to the extra_rdoc_files list.
|
30
46
|
s.rdoc_options = ["--charset=UTF-8"]
|
31
|
-
s.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
37
|
-
s.specification_version = 3
|
38
|
-
|
39
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
40
|
-
s.add_runtime_dependency(%q<formatador>, [">= 0.0.12"])
|
41
|
-
s.add_development_dependency(%q<shindo>, [">= 0"])
|
42
|
-
else
|
43
|
-
s.add_dependency(%q<formatador>, [">= 0.0.12"])
|
44
|
-
s.add_dependency(%q<shindo>, [">= 0"])
|
45
|
-
end
|
46
|
-
else
|
47
|
-
s.add_dependency(%q<formatador>, [">= 0.0.12"])
|
48
|
-
s.add_dependency(%q<shindo>, [">= 0"])
|
49
|
-
end
|
50
|
-
end
|
47
|
+
s.extra_rdoc_files = %w[README.rdoc]
|
48
|
+
|
49
|
+
## List your runtime dependencies here. Runtime dependencies are those
|
50
|
+
## that are needed for an end user to actually USE your code.
|
51
|
+
s.add_dependency('formatador', ">= 0.0.16")
|
51
52
|
|
53
|
+
## List your development dependencies here. Development dependencies are
|
54
|
+
## those that are only needed during development
|
55
|
+
s.add_development_dependency('shindo', ">= 0.1.10")
|
56
|
+
|
57
|
+
## Leave this section as-is. It will be automatically generated from the
|
58
|
+
## contents of your Git repository via the gemspec task. DO NOT REMOVE
|
59
|
+
## THE MANIFEST COMMENTS, they are used as delimiters by the task.
|
60
|
+
# = MANIFEST =
|
61
|
+
s.files = %w[
|
62
|
+
README.rdoc
|
63
|
+
Rakefile
|
64
|
+
lib/tach.rb
|
65
|
+
tach.gemspec
|
66
|
+
tests/tach_tests.rb
|
67
|
+
tests/tests_helper.rb
|
68
|
+
]
|
69
|
+
# = MANIFEST =
|
70
|
+
|
71
|
+
## Test files will be grabbed from the file list. Make sure the path glob
|
72
|
+
## matches what you actually use.
|
73
|
+
s.test_files = s.files.select { |path| path =~ /^tests\/.*_tests\.rb/ }
|
74
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 7
|
9
|
+
version: 0.0.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- geemus (Wesley Beary)
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-12-07 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -27,8 +27,8 @@ dependencies:
|
|
27
27
|
segments:
|
28
28
|
- 0
|
29
29
|
- 0
|
30
|
-
-
|
31
|
-
version: 0.0.
|
30
|
+
- 16
|
31
|
+
version: 0.0.16
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
@@ -40,11 +40,13 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
segments:
|
42
42
|
- 0
|
43
|
-
|
43
|
+
- 1
|
44
|
+
- 10
|
45
|
+
version: 0.1.10
|
44
46
|
type: :development
|
45
47
|
version_requirements: *id002
|
46
|
-
description: Simple benchmarking with
|
47
|
-
email:
|
48
|
+
description: Simple benchmarking with noticable progress and pretty results.
|
49
|
+
email: geemus@gmail.com
|
48
50
|
executables: []
|
49
51
|
|
50
52
|
extensions: []
|
@@ -52,11 +54,8 @@ extensions: []
|
|
52
54
|
extra_rdoc_files:
|
53
55
|
- README.rdoc
|
54
56
|
files:
|
55
|
-
- .document
|
56
|
-
- .gitignore
|
57
57
|
- README.rdoc
|
58
58
|
- Rakefile
|
59
|
-
- VERSION
|
60
59
|
- lib/tach.rb
|
61
60
|
- tach.gemspec
|
62
61
|
- tests/tach_tests.rb
|
@@ -86,10 +85,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
85
|
version: "0"
|
87
86
|
requirements: []
|
88
87
|
|
89
|
-
rubyforge_project:
|
88
|
+
rubyforge_project: tach
|
90
89
|
rubygems_version: 1.3.6
|
91
90
|
signing_key:
|
92
|
-
specification_version:
|
91
|
+
specification_version: 2
|
93
92
|
summary: Simple benchmarking
|
94
|
-
test_files:
|
95
|
-
|
93
|
+
test_files:
|
94
|
+
- tests/tach_tests.rb
|
data/.document
DELETED
data/.gitignore
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# rcov generated
|
2
|
-
coverage
|
3
|
-
|
4
|
-
# rdoc generated
|
5
|
-
rdoc
|
6
|
-
|
7
|
-
# yard generated
|
8
|
-
doc
|
9
|
-
.yardoc
|
10
|
-
|
11
|
-
# jeweler generated
|
12
|
-
pkg
|
13
|
-
|
14
|
-
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
15
|
-
#
|
16
|
-
# * Create a file at ~/.gitignore
|
17
|
-
# * Include files you want ignored
|
18
|
-
# * Run: git config --global core.excludesfile ~/.gitignore
|
19
|
-
#
|
20
|
-
# After doing this, these files will be ignored in all your git projects,
|
21
|
-
# saving you from having to 'pollute' every project you touch with them
|
22
|
-
#
|
23
|
-
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
24
|
-
#
|
25
|
-
# For MacOS:
|
26
|
-
#
|
27
|
-
#.DS_Store
|
28
|
-
#
|
29
|
-
# For TextMate
|
30
|
-
#*.tmproj
|
31
|
-
#tmtags
|
32
|
-
#
|
33
|
-
# For emacs:
|
34
|
-
#*~
|
35
|
-
#\#*
|
36
|
-
#.\#*
|
37
|
-
#
|
38
|
-
# For vim:
|
39
|
-
#*.swp
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.6
|