Rakefile
changeset 0 8547a1ce445e
child 1 8446f55f7e58
equal deleted inserted replaced
-1:000000000000 0:8547a1ce445e
       
     1 #!/usr/bin/env rake
       
     2 # vim: set nosta noet ts=4 sw=4:
       
     3 
       
     4 require 'pathname'
       
     5 
       
     6 PROJECT = 'snmp'
       
     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-SNMP'
       
    31 	s.authors      = [ 'Mahlon E. Smith <mahlon@martini.nu>', 'Michael Granger <ged@faeriemud.org>' ]
       
    32 	s.platform     = Gem::Platform::RUBY
       
    33 	s.summary      = "Common SNMP support 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 common SNMP support to Arborist monitors.
       
    44 	EOF
       
    45 	s.required_ruby_version = '>= 2'
       
    46 	# s.post_install_message = 'HuurrnnggghH!!!'
       
    47 
       
    48 	s.add_dependency 'snmp', "~> 1.2"
       
    49 end
       
    50 
       
    51 Gem::PackageTask.new( spec ) do |pkg|
       
    52 	pkg.need_zip = true
       
    53 	pkg.need_tar = true
       
    54 end
       
    55 
       
    56 
       
    57 ########################################################################
       
    58 ### D O C U M E N T A T I O N
       
    59 ########################################################################
       
    60 
       
    61 begin
       
    62 	require 'rdoc/task'
       
    63 
       
    64 	desc 'Generate rdoc documentation'
       
    65 	RDoc::Task.new do |rdoc|
       
    66 		rdoc.name       = :docs
       
    67 		rdoc.rdoc_dir   = 'docs'
       
    68 		rdoc.main       = "README.rdoc"
       
    69 		rdoc.options    = [ '-f', 'fivefish' ]
       
    70 		rdoc.rdoc_files = [ 'lib', *FileList['*.rdoc'] ]
       
    71 	end
       
    72 
       
    73 	RDoc::Task.new do |rdoc|
       
    74 		rdoc.name       = :doc_coverage
       
    75 		rdoc.options    = [ '-C1' ]
       
    76 	end
       
    77 
       
    78 rescue LoadError
       
    79 	$stderr.puts "Omitting 'docs' tasks, rdoc doesn't seem to be installed."
       
    80 end
       
    81 
       
    82 
       
    83 ########################################################################
       
    84 ### T E S T I N G
       
    85 ########################################################################
       
    86 
       
    87 begin
       
    88     require 'rspec/core/rake_task'
       
    89     task :test => :spec
       
    90 
       
    91     desc "Run specs"
       
    92     RSpec::Core::RakeTask.new do |t|
       
    93         t.pattern = "spec/**/*_spec.rb"
       
    94     end
       
    95 
       
    96     desc "Build a coverage report"
       
    97     task :coverage do
       
    98         ENV[ 'COVERAGE' ] = "yep"
       
    99         Rake::Task[ :spec ].invoke
       
   100     end
       
   101 
       
   102 rescue LoadError
       
   103     $stderr.puts "Omitting testing tasks, rspec doesn't seem to be installed."
       
   104 end
       
   105 
       
   106 
       
   107 
       
   108 ########################################################################
       
   109 ### M A N I F E S T
       
   110 ########################################################################
       
   111 __END__
       
   112 lib/arborist/monitor/snmp.rb
       
   113