stella 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/README.textile +14 -10
  2. data/Rakefile +22 -36
  3. data/lib/daemonize.rb +56 -0
  4. data/lib/stella/adapter/ab.rb +49 -39
  5. data/lib/stella/adapter/base.rb +17 -8
  6. data/lib/stella/adapter/httperf.rb +24 -18
  7. data/lib/stella/adapter/pcap_watcher.rb +1 -1
  8. data/lib/stella/adapter/siege.rb +15 -12
  9. data/lib/stella/cli/localtest.rb +2 -3
  10. data/lib/stella/cli/sysinfo.rb +0 -1
  11. data/lib/stella/cli.rb +10 -55
  12. data/lib/stella/command/base.rb +0 -62
  13. data/lib/stella/command/localtest.rb +35 -36
  14. data/lib/stella/data/domain.rb +18 -11
  15. data/lib/stella/data/http.rb +23 -16
  16. data/lib/stella/logger.rb +29 -19
  17. data/lib/stella/response.rb +5 -2
  18. data/lib/stella/storable.rb +138 -52
  19. data/lib/stella/support.rb +107 -8
  20. data/lib/stella/sysinfo.rb +26 -16
  21. data/lib/stella/test/definition.rb +1 -1
  22. data/lib/stella/test/run/summary.rb +23 -13
  23. data/lib/stella/test/stats.rb +114 -0
  24. data/lib/stella/text/resource.rb +1 -1
  25. data/lib/stella.rb +29 -4
  26. data/lib/utils/mathutil.rb +0 -76
  27. data/lib/utils/stats.rb +88 -0
  28. data/lib/win32/Console/ANSI.rb +305 -305
  29. data/lib/win32/Console.rb +970 -970
  30. data/support/ruby-pcap-takuma-patch.txt +13 -13
  31. data/support/text/en.yaml +11 -8
  32. data/support/text/nl.yaml +7 -1
  33. data/{spec/show-agents_spec.rb → tests/01-util_test.rb} +0 -0
  34. data/tests/02-stella-util_test.rb +42 -0
  35. data/tests/10-stella_test.rb +104 -0
  36. data/tests/11-stella-storable_test.rb +68 -0
  37. data/tests/60-stella-command_test.rb +248 -0
  38. data/tests/80-stella-cli_test.rb +45 -0
  39. data/tests/spec-helper.rb +31 -0
  40. data/vendor/{frylock/README.textile → drydock/LICENSE.txt} +2 -52
  41. data/vendor/drydock/README.textile +57 -0
  42. data/vendor/{frylock → drydock}/bin/example +14 -14
  43. data/vendor/{frylock/frylock.gemspec → drydock/drydock.gemspec} +1 -1
  44. data/vendor/{frylock/lib/frylock → drydock/lib/drydock}/exceptions.rb +1 -1
  45. data/vendor/{frylock/lib/frylock.rb → drydock/lib/drydock.rb} +8 -8
  46. data/vendor/{frylock → drydock}/test/command_test.rb +0 -0
  47. metadata +34 -61
  48. data/lib/stella/test/base.rb +0 -38
  49. data/lib/stella/test/summary.rb +0 -82
  50. data/vendor/hitimes-0.4.0/HISTORY +0 -28
  51. data/vendor/hitimes-0.4.0/LICENSE.txt +0 -19
  52. data/vendor/hitimes-0.4.0/README +0 -80
  53. data/vendor/hitimes-0.4.0/Rakefile +0 -63
  54. data/vendor/hitimes-0.4.0/examples/benchmarks.rb +0 -86
  55. data/vendor/hitimes-0.4.0/examples/stats.rb +0 -29
  56. data/vendor/hitimes-0.4.0/ext/extconf.rb +0 -15
  57. data/vendor/hitimes-0.4.0/ext/hitimes_ext.c +0 -21
  58. data/vendor/hitimes-0.4.0/ext/hitimes_instant_clock_gettime.c +0 -20
  59. data/vendor/hitimes-0.4.0/ext/hitimes_instant_osx.c +0 -16
  60. data/vendor/hitimes-0.4.0/ext/hitimes_instant_windows.c +0 -27
  61. data/vendor/hitimes-0.4.0/ext/hitimes_interval.c +0 -340
  62. data/vendor/hitimes-0.4.0/ext/hitimes_interval.h +0 -73
  63. data/vendor/hitimes-0.4.0/ext/hitimes_stats.c +0 -242
  64. data/vendor/hitimes-0.4.0/ext/hitimes_stats.h +0 -30
  65. data/vendor/hitimes-0.4.0/ext/rbconfig-mingw.rb +0 -178
  66. data/vendor/hitimes-0.4.0/ext/rbconfig.rb +0 -178
  67. data/vendor/hitimes-0.4.0/gemspec.rb +0 -54
  68. data/vendor/hitimes-0.4.0/lib/hitimes/mutexed_stats.rb +0 -23
  69. data/vendor/hitimes-0.4.0/lib/hitimes/paths.rb +0 -54
  70. data/vendor/hitimes-0.4.0/lib/hitimes/stats.rb +0 -29
  71. data/vendor/hitimes-0.4.0/lib/hitimes/timer.rb +0 -223
  72. data/vendor/hitimes-0.4.0/lib/hitimes/version.rb +0 -42
  73. data/vendor/hitimes-0.4.0/lib/hitimes.rb +0 -24
  74. data/vendor/hitimes-0.4.0/spec/interval_spec.rb +0 -115
  75. data/vendor/hitimes-0.4.0/spec/mutex_stats_spec.rb +0 -34
  76. data/vendor/hitimes-0.4.0/spec/paths_spec.rb +0 -14
  77. data/vendor/hitimes-0.4.0/spec/spec_helper.rb +0 -6
  78. data/vendor/hitimes-0.4.0/spec/stats_spec.rb +0 -72
  79. data/vendor/hitimes-0.4.0/spec/timer_spec.rb +0 -105
  80. data/vendor/hitimes-0.4.0/spec/version_spec.rb +0 -27
  81. data/vendor/hitimes-0.4.0/tasks/announce.rake +0 -39
  82. data/vendor/hitimes-0.4.0/tasks/config.rb +0 -107
  83. data/vendor/hitimes-0.4.0/tasks/distribution.rake +0 -53
  84. data/vendor/hitimes-0.4.0/tasks/documentation.rake +0 -33
  85. data/vendor/hitimes-0.4.0/tasks/extension.rake +0 -64
  86. data/vendor/hitimes-0.4.0/tasks/rspec.rake +0 -31
  87. data/vendor/hitimes-0.4.0/tasks/rubyforge.rake +0 -52
  88. data/vendor/hitimes-0.4.0/tasks/utils.rb +0 -80
@@ -1,105 +0,0 @@
1
- require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
2
-
3
- require 'hitimes/timer'
4
-
5
- describe Hitimes::Timer do
6
-
7
- it "knows if it is running or not" do
8
- t = Hitimes::Timer.new
9
- t.should_not be_running
10
- t.start
11
- t.should be_running
12
- t.stop
13
- t.should_not be_running
14
- end
15
-
16
- it "#split returns the last duration and the timer is still running" do
17
- t = Hitimes::Timer.now
18
- d = t.split
19
- t.should be_running
20
- d.should > 0
21
- t.count.should == 1
22
- t.duration.should == d
23
- end
24
-
25
- it "#stop returns false if called more than once in a row" do
26
- t = Hitimes::Timer.new
27
- t.start
28
- t.stop.should > 0
29
- t.stop.should == false
30
- end
31
-
32
- it "does not count a currently running interval as an interval in calculations" do
33
- t = Hitimes::Timer.new
34
- t.start
35
- t.count.should == 0
36
- t.split
37
- t.count.should == 1
38
- end
39
-
40
- it "#split called on a stopped timer does nothing" do
41
- t = Hitimes::Timer.new
42
- t.start
43
- t.stop
44
- t.split.should == false
45
- end
46
-
47
- it "calculates the mean of the durations" do
48
- t = Hitimes::Timer.new
49
- 2.times { t.start ; sleep 0.05 ; t.stop }
50
- t.mean.should > 0.04
51
- end
52
-
53
- it "calculates the rate of the counts " do
54
- t = Hitimes::Timer.new
55
- 5.times { t.start ; sleep 0.05 ; t.stop }
56
- t.rate.should > 19.0
57
- end
58
-
59
-
60
- it "calculates the stddev of the durations" do
61
- t = Hitimes::Timer.new
62
- 2.times { t.start ; sleep 0.05 ; t.stop }
63
- t.stddev.should > 0.0
64
- end
65
-
66
- it "returns 0.0 for stddev if there is no data" do
67
- t = Hitimes::Timer.new
68
- t.stddev.should == 0.0
69
- end
70
-
71
- it "retuns 0.0 for mean if there is no data" do
72
- Hitimes::Timer.new.mean.should == 0.0
73
- end
74
-
75
- it "keeps track of the min value" do
76
- t = Hitimes::Timer.new
77
- 2.times { t.start ; sleep 0.05 ; t.stop }
78
- t.min.should > 0
79
- end
80
-
81
- it "keeps track of the max value" do
82
- t = Hitimes::Timer.new
83
- 2.times { t.start ; sleep 0.05 ; t.stop }
84
- t.max.should > 0
85
- end
86
-
87
- it "can create an already running timer" do
88
- t = Hitimes::Timer.now
89
- t.should be_running
90
- end
91
-
92
- it "can measure a block of code's execution time" do
93
- dur = Hitimes::Timer.measure { sleep 0.05 }
94
- dur.should > 0.025
95
- end
96
-
97
- it "can measuer a block of code from an instance" do
98
- t = Hitimes::Timer.new
99
- 3.times { t.measure { sleep 0.05 } }
100
- t.duration.should > 0.14
101
- t.count.should == 3
102
- end
103
-
104
- end
105
-
@@ -1,27 +0,0 @@
1
- require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper" ) )
2
-
3
- describe "Hitimes::Version" do
4
- it "should have a major numbers that is >= 0" do
5
- Hitimes::Version::MAJOR.should >= 0
6
- end
7
-
8
- it "should have a minor number that is >= 0" do
9
- Hitimes::Version::MINOR.should >= 0
10
- end
11
-
12
- it "should have a tiny number that is >= 0" do
13
- Hitimes::Version::BUILD.should >= 0
14
- end
15
-
16
- it "should have an array representation" do
17
- Hitimes::Version.to_a.should have(3).items
18
- end
19
-
20
- it "should have a string representation" do
21
- Hitimes::Version.to_s.should match(/\d+\.\d+\.\d+/)
22
- end
23
-
24
- it "should be accessable as a constant" do
25
- Hitimes::VERSION.should match(/\d+\.\d+\.\d+/)
26
- end
27
- end
@@ -1,39 +0,0 @@
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 " gem install #{Hitimes::GEM_SPEC.name}"
21
- mail.puts
22
- mail.puts info[:urls]
23
- mail.puts
24
- mail.puts info[:description]
25
- mail.puts
26
- mail.puts "{{ Release notes for Version #{Hitimes::VERSION} }}"
27
- mail.puts
28
- mail.puts info[:release_notes]
29
- mail.puts
30
- end
31
- puts "Created the following as email.txt:"
32
- puts "-" * 72
33
- puts File.read("email.txt")
34
- puts "-" * 72
35
- end
36
-
37
- CLOBBER << "email.txt"
38
- end
39
-
@@ -1,107 +0,0 @@
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/*.{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 --inline-source ]#-f darkfish ]
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
- }
96
-
97
- #-----------------------------------------------------------------------
98
- # Rubyforge
99
- #-----------------------------------------------------------------------
100
- Configuration.for('rubyforge') {
101
- project "copiousfreetime"
102
- user "jjh"
103
- host "rubyforge.org"
104
- rdoc_location "#{user}@#{host}:/var/www/gforge-projects/#{project}/hitimes"
105
- }
106
-
107
-
@@ -1,53 +0,0 @@
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 "reinstall gem"
35
- task :reinstall => [:uninstall, :repackage, :install]
36
-
37
- desc "package up a windows gem"
38
- task :package_win => "ext:build_win" do
39
- cp "ext/hitimes_ext.so", "lib", :verbose => true
40
- Gem::Builder.new( Hitimes::GEM_SPEC_WIN ).build
41
- mv Dir["*.gem"].first, "pkg"
42
- end
43
-
44
- desc "distribute copiously"
45
- task :copious => [:package, :package_win ] do
46
- gems = Hitimes::SPECS.collect { |s| "#{s.full_name}.gem" }
47
- Rake::SshFilePublisher.new('jeremy@copiousfreetime.org',
48
- '/var/www/vhosts/www.copiousfreetime.org/htdocs/gems/gems',
49
- 'pkg', *gems).upload
50
- sh "ssh jeremy@copiousfreetime.org rake -f /var/www/vhosts/www.copiousfreetime.org/htdocs/gems/Rakefile"
51
- end
52
- end
53
- end
@@ -1,33 +0,0 @@
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 'rake/rdoctask'
12
- #gem 'darkfish-rdoc'
13
- #require 'darkfish-rdoc'
14
-
15
- # generating documentation locally
16
- Rake::RDocTask.new do |rdoc|
17
- rdoc.rdoc_dir = rdoc_config.output_dir
18
- rdoc.options = rdoc_config.options
19
- rdoc.rdoc_files = rdoc_config.files.sort
20
- rdoc.title = rdoc_config.title
21
- rdoc.main = rdoc_config.main_page
22
- end
23
-
24
- if rubyforge_config = Configuration.for_if_exist?('rubyforge') then
25
- desc "Deploy the RDoc documentation to #{rubyforge_config.rdoc_location}"
26
- task :deploy => :rerdoc do
27
- sh "rsync -zav --delete #{rdoc_config.output_dir}/ #{rubyforge_config.rdoc_location}"
28
- end
29
- end
30
-
31
- end
32
- end
33
-
@@ -1,64 +0,0 @@
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 do
12
- Hitimes::GEM_SPEC.extensions.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 "rake default"
19
- sh "make"
20
- end
21
- end
22
- end
23
-
24
- desc "Build the extension for windows"
25
- task :build_win => :clobber do
26
- Hitimes::GEM_SPEC.extensions.each do |extension|
27
- path = Pathname.new(extension)
28
- parts = path.split
29
- conf = parts.last
30
- Dir.chdir(path.dirname) do |d|
31
- cp "rbconfig-mingw.rb", "rbconfig.rb"
32
- sh "ruby -I. extconf.rb"
33
- sh "make"
34
- end
35
- end
36
- end
37
-
38
- task :clean do
39
- ext_config.configs.each do |extension|
40
- path = Pathname.new(extension)
41
- parts = path.split
42
- conf = parts.last
43
- Dir.chdir(path.dirname) do |d|
44
- #sh "rake clean"
45
- sh "make clean"
46
- end
47
- end
48
- end
49
-
50
- task :clobber do
51
- ext_config.configs.each do |extension|
52
- path = Pathname.new(extension)
53
- parts = path.split
54
- conf = parts.last
55
- Dir.chdir(path.dirname) do |d|
56
- #sh "rake clobber"
57
- if File.exist?( "Makefile" ) then
58
- sh "make distclean"
59
- end
60
- end
61
- end
62
- end
63
- end
64
- end
@@ -1,31 +0,0 @@
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
@@ -1,52 +0,0 @@
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
- rubyforge.login
35
- rubyforge.add_release(Hitimes::GEM_SPEC.rubyforge_project, Hitimes::GEM_SPEC.name, Hitimes::VERSION, *files)
36
- puts "done."
37
- end
38
- end
39
-
40
- namespace :announce do
41
- desc "Post news of #{proj_conf.name} to #{rf_conf.project} on rubyforge"
42
- task :rubyforge do
43
- info = Utils.announcement
44
- rubyforge = RubyForge.new
45
- rubyforge.configure
46
- rubyforge.login
47
- rubyforge.post_news(rf_conf.project, info[:subject], "#{info[:title]}\n\n#{info[:urls]}\n\n#{info[:release_notes]}")
48
- puts "Posted to rubyforge"
49
- end
50
-
51
- end
52
- end
@@ -1,80 +0,0 @@
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