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