|
1 #!/usr/bin/env rake |
|
2 # vim: set nosta noet ts=4 sw=4: |
|
3 |
|
4 require 'pathname' |
|
5 |
|
6 PROJECT = 'fping' |
|
7 BASEDIR = Pathname.new( __FILE__ ).expand_path.dirname.relative_path_from( Pathname.getwd ) |
|
8 LIBDIR = BASEDIR + 'lib' |
|
9 |
|
10 if Rake.application.options.trace |
|
11 $trace = true |
|
12 $stderr.puts '$trace is enabled' |
|
13 end |
|
14 |
|
15 # parse the current library version |
|
16 $version = ( LIBDIR + 'arborist' + 'monitor' + "#{PROJECT}.rb" ).read.split(/\n/). |
|
17 select{|line| line =~ /VERSION =/}.first.match(/([\d|.]+)/)[1] |
|
18 |
|
19 task :default => [ :spec, :docs, :package ] |
|
20 |
|
21 |
|
22 ######################################################################## |
|
23 ### P A C K A G I N G |
|
24 ######################################################################## |
|
25 |
|
26 require 'rubygems' |
|
27 require 'rubygems/package_task' |
|
28 spec = Gem::Specification.new do |s| |
|
29 s.email = 'mahlon@martini.nu' |
|
30 s.homepage = 'http://bitbucket.org/mahlon/Arborist-fping' |
|
31 s.authors = [ 'Mahlon E. Smith <mahlon@martini.nu>', 'Michael Granger <ged@faeriemud.org>' ] |
|
32 s.platform = Gem::Platform::RUBY |
|
33 s.summary = "Efficient ping strobing for Arborist" |
|
34 s.name = 'arborist-' + PROJECT |
|
35 s.version = $version |
|
36 s.license = 'BSD-3-Clause' |
|
37 s.has_rdoc = true |
|
38 s.require_path = 'lib' |
|
39 s.bindir = 'bin' |
|
40 s.files = File.read( __FILE__ ).split( /^__END__/, 2 ).last.split |
|
41 # s.executables = %w[] |
|
42 s.description = <<-EOF |
|
43 This library adds fping output parsing support to Arborist monitors. |
|
44 EOF |
|
45 s.required_ruby_version = '>= 2' |
|
46 |
|
47 s.add_dependency 'arborist', "~> 1.0" |
|
48 end |
|
49 |
|
50 Gem::PackageTask.new( spec ) do |pkg| |
|
51 pkg.need_zip = true |
|
52 pkg.need_tar = true |
|
53 end |
|
54 |
|
55 |
|
56 ######################################################################## |
|
57 ### D O C U M E N T A T I O N |
|
58 ######################################################################## |
|
59 |
|
60 begin |
|
61 require 'rdoc/task' |
|
62 |
|
63 desc 'Generate rdoc documentation' |
|
64 RDoc::Task.new do |rdoc| |
|
65 rdoc.name = :docs |
|
66 rdoc.rdoc_dir = 'docs' |
|
67 rdoc.main = "README.rdoc" |
|
68 rdoc.options = [ '-f', 'fivefish' ] |
|
69 rdoc.rdoc_files = [ 'lib', *FileList['*.rdoc'] ] |
|
70 end |
|
71 |
|
72 RDoc::Task.new do |rdoc| |
|
73 rdoc.name = :doc_coverage |
|
74 rdoc.options = [ '-C1' ] |
|
75 end |
|
76 |
|
77 rescue LoadError |
|
78 $stderr.puts "Omitting 'docs' tasks, rdoc doesn't seem to be installed." |
|
79 end |
|
80 |
|
81 |
|
82 ######################################################################## |
|
83 ### T E S T I N G |
|
84 ######################################################################## |
|
85 |
|
86 begin |
|
87 require 'rspec/core/rake_task' |
|
88 task :test => :spec |
|
89 |
|
90 desc "Run specs" |
|
91 RSpec::Core::RakeTask.new do |t| |
|
92 t.pattern = "spec/**/*_spec.rb" |
|
93 end |
|
94 |
|
95 desc "Build a coverage report" |
|
96 task :coverage do |
|
97 ENV[ 'COVERAGE' ] = "yep" |
|
98 Rake::Task[ :spec ].invoke |
|
99 end |
|
100 |
|
101 rescue LoadError |
|
102 $stderr.puts "Omitting testing tasks, rspec doesn't seem to be installed." |
|
103 end |
|
104 |
|
105 |
|
106 |
|
107 ######################################################################## |
|
108 ### M A N I F E S T |
|
109 ######################################################################## |
|
110 __END__ |
|
111 lib/arborist/monitor/fping.rb |
|
112 |