Rakefile
author Mahlon E. Smith <mahlon@martini.nu>
Tue, 27 Mar 2018 14:27:31 -0700
changeset 5 6cf2c60c80f7
parent 0 d99e1dffbc72
child 8 4f397a05dcdf
permissions -rw-r--r--
Provide fping addresses via pipe, instead of an argument list. #exec_arguments defaults to a no-op, but #exec_input does not. This means that exec_callbacks modules that do no use #exec_input need to define a no-op themselves, as the default will still try to write data to stdin. (This may be addressed in the monitor at some point, it is a bit of a gotcha.) Rather than define an empty #exec_input method, make a functional one, and remove #exec_arguments. This will fare better if the input list is excessively long anyway, and it fixes Error::EPIPE.

#!/usr/bin/env rake
# vim: set nosta noet ts=4 sw=4:

require 'pathname'

PROJECT = 'fping'
BASEDIR = Pathname.new( __FILE__ ).expand_path.dirname.relative_path_from( Pathname.getwd )
LIBDIR  = BASEDIR + 'lib'

if Rake.application.options.trace
    $trace = true
    $stderr.puts '$trace is enabled'
end

# parse the current library version
$version = ( LIBDIR + 'arborist' + 'monitor' + "#{PROJECT}.rb" ).read.split(/\n/).
	select{|line| line =~ /VERSION =/}.first.match(/([\d|.]+)/)[1]

task :default => [ :spec, :docs, :package ]


########################################################################
### P A C K A G I N G
########################################################################

require 'rubygems'
require 'rubygems/package_task'
spec = Gem::Specification.new do |s|
	s.email        = 'mahlon@martini.nu'
	s.homepage     = 'http://bitbucket.org/mahlon/Arborist-fping'
	s.authors      = [ 'Mahlon E. Smith <mahlon@martini.nu>', 'Michael Granger <ged@faeriemud.org>' ]
	s.platform     = Gem::Platform::RUBY
	s.summary      = "Efficient ping strobing for Arborist"
	s.name         = 'arborist-' + PROJECT
	s.version      = $version
	s.license      = 'BSD-3-Clause'
	s.has_rdoc     = true
	s.require_path = 'lib'
	s.bindir       = 'bin'
	s.files        = File.read( __FILE__ ).split( /^__END__/, 2 ).last.split
	# s.executables  = %w[]
	s.description  = <<-EOF
	This library adds fping output parsing support to Arborist monitors.
	EOF
	s.required_ruby_version = '>= 2'

	s.add_dependency 'arborist', "~> 1.0"
end

Gem::PackageTask.new( spec ) do |pkg|
	pkg.need_zip = true
	pkg.need_tar = true
end


########################################################################
### D O C U M E N T A T I O N
########################################################################

begin
	require 'rdoc/task'

	desc 'Generate rdoc documentation'
	RDoc::Task.new do |rdoc|
		rdoc.name       = :docs
		rdoc.rdoc_dir   = 'docs'
		rdoc.main       = "README.rdoc"
		rdoc.options    = [ '-f', 'fivefish' ]
		rdoc.rdoc_files = [ 'lib', *FileList['*.rdoc'] ]
	end

	RDoc::Task.new do |rdoc|
		rdoc.name       = :doc_coverage
		rdoc.options    = [ '-C1' ]
	end

rescue LoadError
	$stderr.puts "Omitting 'docs' tasks, rdoc doesn't seem to be installed."
end


########################################################################
### T E S T I N G
########################################################################

begin
    require 'rspec/core/rake_task'
    task :test => :spec

    desc "Run specs"
    RSpec::Core::RakeTask.new do |t|
        t.pattern = "spec/**/*_spec.rb"
    end

    desc "Build a coverage report"
    task :coverage do
        ENV[ 'COVERAGE' ] = "yep"
        Rake::Task[ :spec ].invoke
    end

rescue LoadError
    $stderr.puts "Omitting testing tasks, rspec doesn't seem to be installed."
end



########################################################################
### M A N I F E S T
########################################################################
__END__
lib/arborist/monitor/fping.rb