hitimes 1.0.4-x86-mswin32
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/HISTORY +60 -0
- data/LICENSE +13 -0
- data/README +134 -0
- data/Rakefile +66 -0
- data/examples/benchmarks.rb +113 -0
- data/examples/stats.rb +31 -0
- data/ext/hitimes/extconf.rb +17 -0
- data/ext/hitimes/hitimes_ext.c +21 -0
- data/ext/hitimes/hitimes_instant_clock_gettime.c +28 -0
- data/ext/hitimes/hitimes_instant_osx.c +16 -0
- data/ext/hitimes/hitimes_instant_windows.c +27 -0
- data/ext/hitimes/hitimes_interval.c +362 -0
- data/ext/hitimes/hitimes_interval.h +73 -0
- data/ext/hitimes/hitimes_stats.c +269 -0
- data/ext/hitimes/hitimes_stats.h +30 -0
- data/gemspec.rb +60 -0
- data/lib/hitimes.rb +31 -0
- data/lib/hitimes/1.8/hitimes_ext.so +0 -0
- data/lib/hitimes/1.9/hitimes_ext.so +0 -0
- data/lib/hitimes/metric.rb +112 -0
- data/lib/hitimes/mutexed_stats.rb +28 -0
- data/lib/hitimes/paths.rb +53 -0
- data/lib/hitimes/stats.rb +54 -0
- data/lib/hitimes/timed_metric.rb +177 -0
- data/lib/hitimes/timed_value_metric.rb +235 -0
- data/lib/hitimes/value_metric.rb +72 -0
- data/lib/hitimes/version.rb +57 -0
- data/spec/interval_spec.rb +133 -0
- data/spec/metric_spec.rb +30 -0
- data/spec/mutex_stats_spec.rb +34 -0
- data/spec/paths_spec.rb +13 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/stats_spec.rb +100 -0
- data/spec/timed_metric_spec.rb +155 -0
- data/spec/timed_value_metric_spec.rb +172 -0
- data/spec/value_metric_spec.rb +110 -0
- data/spec/version_spec.rb +33 -0
- data/tasks/announce.rake +42 -0
- data/tasks/config.rb +108 -0
- data/tasks/distribution.rake +77 -0
- data/tasks/documentation.rake +32 -0
- data/tasks/extension.rake +92 -0
- data/tasks/rspec.rake +31 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/utils.rb +80 -0
- metadata +150 -0
data/tasks/announce.rake
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'tasks/config'
|
2
|
+
#-------------------------------------------------------------------------------
|
3
|
+
# announcement methods
|
4
|
+
#-------------------------------------------------------------------------------
|
5
|
+
|
6
|
+
proj_config = Configuration.for('project')
|
7
|
+
namespace :announce do
|
8
|
+
desc "create email for ruby-talk"
|
9
|
+
task :email do
|
10
|
+
info = Utils.announcement
|
11
|
+
|
12
|
+
File.open("email.txt", "w") do |mail|
|
13
|
+
mail.puts "From: #{proj_config.author} <#{proj_config.email}>"
|
14
|
+
mail.puts "To: ruby-talk@ruby-lang.org"
|
15
|
+
mail.puts "Date: #{Time.now.rfc2822}"
|
16
|
+
mail.puts "Subject: [ANN] #{info[:subject]}"
|
17
|
+
mail.puts
|
18
|
+
mail.puts info[:title]
|
19
|
+
mail.puts
|
20
|
+
mail.puts "{{ Release notes for Version #{Hitimes::VERSION} }}"
|
21
|
+
mail.puts
|
22
|
+
mail.puts info[:release_notes]
|
23
|
+
mail.puts
|
24
|
+
mail.puts " #{info[:urls]}"
|
25
|
+
mail.puts
|
26
|
+
mail.puts "=== Installation"
|
27
|
+
mail.puts
|
28
|
+
mail.puts " gem install #{Hitimes::GEM_SPEC.name}"
|
29
|
+
mail.puts
|
30
|
+
mail.puts "=== Description"
|
31
|
+
mail.puts
|
32
|
+
mail.puts info[:description]
|
33
|
+
end
|
34
|
+
puts "Created the following as email.txt:"
|
35
|
+
puts "-" * 72
|
36
|
+
puts File.read("email.txt")
|
37
|
+
puts "-" * 72
|
38
|
+
end
|
39
|
+
|
40
|
+
CLOBBER << "email.txt"
|
41
|
+
end
|
42
|
+
|
data/tasks/config.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'configuration'
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'tasks/utils'
|
5
|
+
|
6
|
+
#-----------------------------------------------------------------------
|
7
|
+
# General project configuration
|
8
|
+
#-----------------------------------------------------------------------
|
9
|
+
Configuration.for('project') {
|
10
|
+
name "hitimes"
|
11
|
+
version Hitimes::Version.to_s
|
12
|
+
author "Jeremy Hinegardner"
|
13
|
+
email "jeremy at copiousfreetime dot org"
|
14
|
+
homepage "http://copiousfreetime.rubyforge.org/hitimes/"
|
15
|
+
description Utils.section_of("README", "description")
|
16
|
+
summary description.split(".").first
|
17
|
+
history "HISTORY"
|
18
|
+
license FileList["LICENSE"]
|
19
|
+
readme "README"
|
20
|
+
}
|
21
|
+
|
22
|
+
#-----------------------------------------------------------------------
|
23
|
+
# Packaging
|
24
|
+
#-----------------------------------------------------------------------
|
25
|
+
Configuration.for('packaging') {
|
26
|
+
# files in the project
|
27
|
+
proj_conf = Configuration.for('project')
|
28
|
+
files {
|
29
|
+
bin FileList["bin/*"]
|
30
|
+
ext FileList["ext/hitimes/*.{c,h,rb}"]
|
31
|
+
examples FileList["examples/*.rb"]
|
32
|
+
lib FileList["lib/**/*.rb"]
|
33
|
+
test FileList["spec/**/*.rb", "test/**/*.rb"]
|
34
|
+
data FileList["data/**/*"]
|
35
|
+
tasks FileList["tasks/**/*.r{ake,b}"]
|
36
|
+
rdoc FileList[proj_conf.readme, proj_conf.history,
|
37
|
+
proj_conf.license] + lib + FileList["ext/*.c"]
|
38
|
+
all bin + examples + ext + lib + test + data + rdoc + tasks + FileList["Rakefile"]
|
39
|
+
}
|
40
|
+
|
41
|
+
# ways to package the results
|
42
|
+
formats {
|
43
|
+
tgz true
|
44
|
+
zip true
|
45
|
+
rubygem Configuration::Table.has_key?('gem')
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
#-----------------------------------------------------------------------
|
50
|
+
# Gem packaging
|
51
|
+
#-----------------------------------------------------------------------
|
52
|
+
Configuration.for("gem") {
|
53
|
+
spec "gemspec.rb"
|
54
|
+
Configuration.for('packaging').files.all << spec
|
55
|
+
}
|
56
|
+
|
57
|
+
#-----------------------------------------------------------------------
|
58
|
+
# Testing
|
59
|
+
# - change mode to 'testunit' to use unit testing
|
60
|
+
#-----------------------------------------------------------------------
|
61
|
+
Configuration.for('test') {
|
62
|
+
mode "spec"
|
63
|
+
files Configuration.for("packaging").files.test
|
64
|
+
options %w[ --format specdoc --color ]
|
65
|
+
ruby_opts %w[ ]
|
66
|
+
}
|
67
|
+
|
68
|
+
#-----------------------------------------------------------------------
|
69
|
+
# Rcov
|
70
|
+
#-----------------------------------------------------------------------
|
71
|
+
Configuration.for('rcov') {
|
72
|
+
output_dir "coverage"
|
73
|
+
libs %w[ lib ]
|
74
|
+
rcov_opts %w[ --html ]
|
75
|
+
ruby_opts %w[ ]
|
76
|
+
test_files Configuration.for('packaging').files.test
|
77
|
+
}
|
78
|
+
|
79
|
+
#-----------------------------------------------------------------------
|
80
|
+
# Rdoc
|
81
|
+
#-----------------------------------------------------------------------
|
82
|
+
Configuration.for('rdoc') {
|
83
|
+
files Configuration.for('packaging').files.rdoc
|
84
|
+
main_page files.first
|
85
|
+
title Configuration.for('project').name
|
86
|
+
options %w[ --line-numbers ]
|
87
|
+
output_dir "doc"
|
88
|
+
}
|
89
|
+
|
90
|
+
#-----------------------------------------------------------------------
|
91
|
+
# Extension
|
92
|
+
#-----------------------------------------------------------------------
|
93
|
+
Configuration.for('extension') {
|
94
|
+
configs Configuration.for('packaging').files.ext.find_all { |x| %w[ mkrf_conf.rb extconf.rb ].include?(File.basename(x)) }
|
95
|
+
cross_rbconfig YAML.load_file( File.expand_path("~/.rake-compiler/config.yml"))
|
96
|
+
}
|
97
|
+
|
98
|
+
#-----------------------------------------------------------------------
|
99
|
+
# Rubyforge
|
100
|
+
#-----------------------------------------------------------------------
|
101
|
+
Configuration.for('rubyforge') {
|
102
|
+
project "copiousfreetime"
|
103
|
+
user "jjh"
|
104
|
+
host "rubyforge.org"
|
105
|
+
rdoc_location "#{user}@#{host}:/var/www/gforge-projects/#{project}/hitimes"
|
106
|
+
}
|
107
|
+
|
108
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'tasks/config'
|
2
|
+
|
3
|
+
#-------------------------------------------------------------------------------
|
4
|
+
# Distribution and Packaging
|
5
|
+
#-------------------------------------------------------------------------------
|
6
|
+
if pkg_config = Configuration.for_if_exist?("packaging") then
|
7
|
+
|
8
|
+
require 'gemspec'
|
9
|
+
require 'rake/gempackagetask'
|
10
|
+
require 'rake/contrib/sshpublisher'
|
11
|
+
|
12
|
+
namespace :dist do
|
13
|
+
|
14
|
+
Rake::GemPackageTask.new(Hitimes::GEM_SPEC) do |pkg|
|
15
|
+
pkg.need_tar = pkg_config.formats.tgz
|
16
|
+
pkg.need_zip = pkg_config.formats.zip
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Install as a gem"
|
20
|
+
task :install => [:clobber, :package] do
|
21
|
+
sh "sudo gem install pkg/#{Hitimes::GEM_SPEC.full_name}.gem"
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Uninstall gem"
|
25
|
+
task :uninstall do
|
26
|
+
sh "sudo gem uninstall -x #{Hitimes::GEM_SPEC.name}"
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "dump gemspec"
|
30
|
+
task :gemspec do
|
31
|
+
puts Hitimes::GEM_SPEC.to_ruby
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "dump gemspec for win"
|
35
|
+
task :gemspec_win do
|
36
|
+
puts Hitimes::GEM_SPEC_WIN.to_ruby
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "reinstall gem"
|
40
|
+
task :reinstall => [:uninstall, :repackage, :install]
|
41
|
+
|
42
|
+
desc "package up a windows gem"
|
43
|
+
task :package_win => :clean do
|
44
|
+
Configuration.for("extension").cross_rbconfig.keys.each do |rbconfig|
|
45
|
+
v = rbconfig.split("-").last
|
46
|
+
s = v.sub(/\.\d$/,'')
|
47
|
+
sh "rake ext:build_win-#{v}"
|
48
|
+
mkdir_p "lib/hitimes/#{s}", :verbose => true
|
49
|
+
cp "ext/hitimes/hitimes_ext.so", "lib/hitimes/#{s}/", :verbose => true
|
50
|
+
end
|
51
|
+
|
52
|
+
Hitimes::SPECS.each do |spec|
|
53
|
+
next if spec.platform == "ruby"
|
54
|
+
spec.files += FileList["lib/hitimes/{1.8,1.9}/**.{dll,so}"]
|
55
|
+
Gem::Builder.new( spec ).build
|
56
|
+
mkdir "pkg" unless File.directory?( 'pkg' )
|
57
|
+
mv Dir["*.gem"].first, "pkg"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
task :clobber do
|
62
|
+
rm_rf "lib/hitimes/1.8"
|
63
|
+
rm_rf "lib/hitimes/1.9"
|
64
|
+
end
|
65
|
+
|
66
|
+
task :prep => [:clean, :package, :package_win]
|
67
|
+
|
68
|
+
desc "distribute copiously"
|
69
|
+
task :copious => [:clean, :package, :package_win ] do
|
70
|
+
gems = Hitimes::SPECS.collect { |s| "#{s.full_name}.gem" }
|
71
|
+
Rake::SshFilePublisher.new('jeremy@copiousfreetime.org',
|
72
|
+
'/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems',
|
73
|
+
'pkg', *gems).upload
|
74
|
+
sh "ssh jeremy@copiousfreetime.org rake -f /var/www/vhosts/www.copiousfreetime.org/htdocs/gems/Rakefile"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'tasks/config'
|
2
|
+
|
3
|
+
#-----------------------------------------------------------------------
|
4
|
+
# Documentation
|
5
|
+
#-----------------------------------------------------------------------
|
6
|
+
|
7
|
+
if rdoc_config = Configuration.for_if_exist?('rdoc') then
|
8
|
+
|
9
|
+
namespace :doc do
|
10
|
+
|
11
|
+
require 'rdoc'
|
12
|
+
require 'rake/rdoctask'
|
13
|
+
|
14
|
+
# generating documentation locally
|
15
|
+
Rake::RDocTask.new do |rdoc|
|
16
|
+
rdoc.rdoc_dir = rdoc_config.output_dir
|
17
|
+
rdoc.options = rdoc_config.options
|
18
|
+
rdoc.rdoc_files = rdoc_config.files.sort
|
19
|
+
rdoc.title = rdoc_config.title
|
20
|
+
rdoc.main = rdoc_config.main_page
|
21
|
+
end
|
22
|
+
|
23
|
+
if rubyforge_config = Configuration.for_if_exist?('rubyforge') then
|
24
|
+
desc "Deploy the RDoc documentation to #{rubyforge_config.rdoc_location}"
|
25
|
+
task :deploy => :rerdoc do
|
26
|
+
sh "rsync -zav --delete #{rdoc_config.output_dir}/ #{rubyforge_config.rdoc_location}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'tasks/config'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
#-----------------------------------------------------------------------
|
5
|
+
# Extensions
|
6
|
+
#-----------------------------------------------------------------------
|
7
|
+
|
8
|
+
if ext_config = Configuration.for_if_exist?('extension') then
|
9
|
+
namespace :ext do
|
10
|
+
desc "Build the extension(s)"
|
11
|
+
task :build => :clean do
|
12
|
+
ext_config.configs.each do |extension|
|
13
|
+
path = Pathname.new(extension)
|
14
|
+
parts = path.split
|
15
|
+
conf = parts.last
|
16
|
+
Dir.chdir(path.dirname) do |d|
|
17
|
+
ruby conf.to_s
|
18
|
+
sh "make"
|
19
|
+
|
20
|
+
# install into requireable location so specs will run
|
21
|
+
subdir = "hitimes/#{RUBY_VERSION.sub(/\.\d$/,'')}"
|
22
|
+
dest_dir = Hitimes::Paths.lib_path( subdir )
|
23
|
+
mkdir_p dest_dir, :verbose => true
|
24
|
+
cp "hitimes_ext.#{Config::CONFIG['DLEXT']}", dest_dir, :verbose => true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_win( version = "1.8.6" )
|
30
|
+
ext_config = Configuration.for("extension")
|
31
|
+
rbconfig = ext_config.cross_rbconfig["rbconfig-#{version}"]
|
32
|
+
raise ArgumentError, "No cross compiler for version #{version}, we have #{ext_config.cross_rbconfig.keys.join(",")}" unless rbconfig
|
33
|
+
ruby_exe = if version =~ /1\.8/ then
|
34
|
+
"ruby"
|
35
|
+
else
|
36
|
+
"ruby1.9"
|
37
|
+
end
|
38
|
+
Hitimes::GEM_SPEC.extensions.each do |extension|
|
39
|
+
path = Pathname.new(extension)
|
40
|
+
parts = path.split
|
41
|
+
conf = parts.last
|
42
|
+
Dir.chdir(path.dirname) do |d|
|
43
|
+
if File.exist?( "Makefile" ) then
|
44
|
+
sh "make clean distclean"
|
45
|
+
end
|
46
|
+
cp "#{rbconfig}", "rbconfig.rb"
|
47
|
+
sh "#{ruby_exe} -I. extconf.rb"
|
48
|
+
sh "make"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
win_builds = []
|
54
|
+
ext_config.cross_rbconfig.keys.each do |v|
|
55
|
+
s = v.split("-").last
|
56
|
+
desc "Build the extension for windows version #{s}"
|
57
|
+
win_bname = "build_win-#{s}"
|
58
|
+
win_builds << win_bname
|
59
|
+
task win_bname => :clean do
|
60
|
+
build_win( s )
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
task :clean do
|
65
|
+
ext_config.configs.each do |extension|
|
66
|
+
path = Pathname.new(extension)
|
67
|
+
parts = path.split
|
68
|
+
conf = parts.last
|
69
|
+
Dir.chdir(path.dirname) do |d|
|
70
|
+
if File.exist?( "Makefile" ) then
|
71
|
+
sh "make clean"
|
72
|
+
end
|
73
|
+
rm_f "rbconfig.rb"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
task :clobber do
|
79
|
+
ext_config.configs.each do |extension|
|
80
|
+
path = Pathname.new(extension)
|
81
|
+
parts = path.split
|
82
|
+
conf = parts.last
|
83
|
+
Dir.chdir(path.dirname) do |d|
|
84
|
+
if File.exist?( "Makefile" ) then
|
85
|
+
sh "make distclean"
|
86
|
+
end
|
87
|
+
rm_f "rbconfig.rb"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
require 'tasks/config'
|
3
|
+
|
4
|
+
#--------------------------------------------------------------------------------
|
5
|
+
# configuration for running rspec. This shows up as the test:default task
|
6
|
+
#--------------------------------------------------------------------------------
|
7
|
+
if spec_config = Configuration.for_if_exist?("test") then
|
8
|
+
if spec_config.mode == "spec" then
|
9
|
+
namespace :test do
|
10
|
+
|
11
|
+
task :default => :spec
|
12
|
+
|
13
|
+
require 'spec/rake/spectask'
|
14
|
+
Spec::Rake::SpecTask.new do |r|
|
15
|
+
r.ruby_opts = spec_config.ruby_opts
|
16
|
+
r.libs = [ Hitimes::Paths.lib_path,
|
17
|
+
Hitimes::Paths.root_dir ]
|
18
|
+
r.spec_files = spec_config.files
|
19
|
+
r.spec_opts = spec_config.options
|
20
|
+
|
21
|
+
if rcov_config = Configuration.for_if_exist?('rcov') then
|
22
|
+
r.rcov = true
|
23
|
+
r.rcov_dir = rcov_config.output_dir
|
24
|
+
r.rcov_opts = rcov_config.rcov_opts
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
task :spec => "ext:build"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'tasks/config'
|
2
|
+
|
3
|
+
#-----------------------------------------------------------------------
|
4
|
+
# Rubyforge additions to the task library
|
5
|
+
#-----------------------------------------------------------------------
|
6
|
+
if rf_conf = Configuration.for_if_exist?("rubyforge") then
|
7
|
+
|
8
|
+
abort("rubyforge gem not installed 'gem install rubyforge'") unless Utils.try_require('rubyforge')
|
9
|
+
|
10
|
+
proj_conf = Configuration.for('project')
|
11
|
+
|
12
|
+
namespace :dist do
|
13
|
+
desc "Release files to rubyforge"
|
14
|
+
task :rubyforge => [:clean, :package, :package_win] do
|
15
|
+
|
16
|
+
rubyforge = RubyForge.new
|
17
|
+
|
18
|
+
config = {}
|
19
|
+
config["release_notes"] = proj_conf.description
|
20
|
+
config["release_changes"] = Utils.release_notes_from(proj_conf.history)[Hitimes::VERSION]
|
21
|
+
config["Prefomatted"] = true
|
22
|
+
|
23
|
+
|
24
|
+
rubyforge.configure config
|
25
|
+
|
26
|
+
# make sure this release doesn't already exist
|
27
|
+
releases = rubyforge.autoconfig['release_ids']
|
28
|
+
if releases.has_key?(Hitimes::GEM_SPEC.name) and releases[Hitimes::GEM_SPEC.name][Hitimes::VERSION] then
|
29
|
+
abort("Release #{Hitimes::VERSION} already exists! Unable to release.")
|
30
|
+
end
|
31
|
+
|
32
|
+
puts "Uploading to rubyforge..."
|
33
|
+
files = FileList[File.join("pkg","#{Hitimes::GEM_SPEC.name}-#{Hitimes::VERSION}*.*")].to_a
|
34
|
+
files.each do |f|
|
35
|
+
puts " * #{f}"
|
36
|
+
end
|
37
|
+
rubyforge.login
|
38
|
+
rubyforge.add_release(Hitimes::GEM_SPEC.rubyforge_project, Hitimes::GEM_SPEC.name, Hitimes::VERSION, *files)
|
39
|
+
puts "done."
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
namespace :announce do
|
44
|
+
desc "Post news of #{proj_conf.name} to #{rf_conf.project} on rubyforge"
|
45
|
+
task :rubyforge do
|
46
|
+
info = Utils.announcement
|
47
|
+
rubyforge = RubyForge.new
|
48
|
+
rubyforge.configure
|
49
|
+
rubyforge.login
|
50
|
+
rubyforge.post_news(rf_conf.project, info[:subject], "#{info[:title]}\n\n#{info[:urls]}\n\n#{info[:release_notes]}")
|
51
|
+
puts "Posted to rubyforge"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
data/tasks/utils.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'hitimes/version'
|
2
|
+
|
3
|
+
#-------------------------------------------------------------------------------
|
4
|
+
# Additions to the Configuration class that are useful
|
5
|
+
#-------------------------------------------------------------------------------
|
6
|
+
class Configuration
|
7
|
+
class << self
|
8
|
+
def exist?( name )
|
9
|
+
Configuration::Table.has_key?( name )
|
10
|
+
end
|
11
|
+
|
12
|
+
def for_if_exist?( name )
|
13
|
+
if self.exist?( name ) then
|
14
|
+
self.for( name )
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
#-------------------------------------------------------------------------------
|
21
|
+
# some useful utilitiy methods for the tasks
|
22
|
+
#-------------------------------------------------------------------------------
|
23
|
+
module Utils
|
24
|
+
class << self
|
25
|
+
|
26
|
+
# Try to load the given _library_ using the built-in require, but do not
|
27
|
+
# raise a LoadError if unsuccessful. Returns +true+ if the _library_ was
|
28
|
+
# successfully loaded; returns +false+ otherwise.
|
29
|
+
#
|
30
|
+
def try_require( lib )
|
31
|
+
require lib
|
32
|
+
true
|
33
|
+
rescue LoadError
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
# partition an rdoc file into sections, and return the text of the section
|
38
|
+
# given.
|
39
|
+
def section_of(file, section_name)
|
40
|
+
File.read(file).split(/^(?==)/).each do |section|
|
41
|
+
lines = section.split("\n")
|
42
|
+
return lines[1..-1].join("\n").strip if lines.first =~ /#{section_name}/i
|
43
|
+
end
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
47
|
+
# Get an array of all the changes in the application for a particular
|
48
|
+
# release. This is done by looking in the history file and grabbing the
|
49
|
+
# information for the most recent release. The history file is assumed to
|
50
|
+
# be in RDoc format and version release are 2nd tier sections separated by
|
51
|
+
# '== Version X.Y.Z'
|
52
|
+
#
|
53
|
+
# returns:: A hash of notes keyed by version number
|
54
|
+
#
|
55
|
+
def release_notes_from(history_file)
|
56
|
+
releases = {}
|
57
|
+
File.read(history_file).split(/^(?=== Version)/).each do |section|
|
58
|
+
lines = section.split("\n")
|
59
|
+
md = %r{Version ((\w+\.)+\w+)}.match(lines.first)
|
60
|
+
next unless md
|
61
|
+
releases[md[1]] = lines[1..-1].join("\n").strip
|
62
|
+
end
|
63
|
+
return releases
|
64
|
+
end
|
65
|
+
|
66
|
+
# return a hash of useful information for the latest release
|
67
|
+
# urls, subject, title, description and latest release notes
|
68
|
+
#
|
69
|
+
def announcement
|
70
|
+
cfg = Configuration.for("project")
|
71
|
+
{
|
72
|
+
:subject => "#{cfg.name} #{Hitimes::VERSION} Released",
|
73
|
+
:title => "#{cfg.name} version #{Hitimes::VERSION} has been released.",
|
74
|
+
:urls => "#{cfg.homepage}",
|
75
|
+
:description => "#{cfg.description.rstrip}",
|
76
|
+
:release_notes => Utils.release_notes_from(cfg.history)[Hitimes::VERSION].rstrip
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end # << self
|