forked from red-tux/zbxapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrakefile.rb
137 lines (122 loc) · 4.2 KB
/
rakefile.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#License:: GPL 2.0 http://www.gnu.org/licenses/gpl-2.0.html
#Copyright:: Copyright (C) 2009,2010 Andrew Nelson nelsonab(at)red-tux(dot)net
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##########################################
# Subversion information
# $Id$
# $Revision$
##########################################
require 'rubygems'
require 'rake'
require 'rdoc/task'
require 'rubygems/package_task'
require 'rake/testtask'
require 'pp'
#setup our search path or libraries
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '.'))
def get_release_num
if ENV["release_ver"].nil?
revs=`git tag -l 'rev*' | sort -t. -k1,1n -k2,2n -k3,3n | grep -E '^rev([0-9]+\.){2}[0-9]+$'`
revs=revs.gsub("\r","").gsub("rev","").split("\n")
if revs.empty?
fail '**** No release tags found, and ENV["release_ver"] is empty ****'
end
ENV["release_ver"]=revs[-1]
end
ENV["release_ver"]
end
task :default => [:test, :package]
desc "Build a version of the Gem, but do not update version file or perform git changes"
task :test_build do
ENV["test_build"]=true.to_s #looks like ENV can only store strings
end
Rake::TestTask.new do |t|
require "ts_local_vars"
t.test_files = FileList['api_tests/tc*.rb']
t.verbose = true
end
desc "Skip the unit tests"
task :skip_tests do
Rake::Task[:test].clear
end
desc "Bump the revision number"
task :bump_rev do
rev_parts=get_release_num.split(".").map{ |i| Integer(i)}
rev_parts[2]+=1 #0.1.2
ENV["release_ver"]=rev_parts.join(".")
end
desc "Bump the minor version number"
task :bump_minor do
rev_parts=get_release_num.split(".").map{ |i| Integer(i)}
rev_parts[1]+=1 #0.1.2
rev_parts[2]=0
ENV["release_ver"]=rev_parts.join(".")
end
desc "Bump the major version number"
task :bump_major do
rev_parts=get_release_num.split(".").map{ |i| Integer(i)}
rev_parts[0]+=1 #0.1.2
rev_parts[1]=0
rev_parts[2]=0
ENV["release_ver"]=rev_parts.join(".")
end
desc "Create Version Tag"
task :tag_version do
ver=get_release_num
puts "Creating tag for version: #{ver}"
`git tag -a rev#{ver} -m \"Release version: #{ver}\"`
end
desc "Update the revision to the release number"
task :update_revision do
if ENV["test_build"]
puts "Test mode emabled, zbxapi/revision.rb file will not be generated"
else
open("zbxapi/revision.rb", "w") do |o|
o.puts "#CHANGES TO THIS FILE WILL AUTOMATICALLY BE OVERWRITTEN"
o.puts "#This file is autogenerated by the zbxapi rakefile."
o.puts "#This file contains the latest SVN revision number at the time"
o.puts "#the rakefile was run"
o.puts
o.puts "ZBXAPI_VERSION=\"#{ENV["release_ver"]}\""
# o.puts "ZBXAPI_REVISION=\"#{$rev}\""
end
end
end
spec = Gem::Specification.new do |s|
s.name = "zbxapi"
s.rubyforge_project = "zbxapi"
s.version = get_release_num
s.authors = ["A. Nelson"]
s.email = %q{[email protected]}
s.summary = %q{Ruby wrapper to the Zabbix API}
s.homepage = %q{https://github.com/red-tux/zbxapi}
s.description = %q{Provides a straight forward interface to manipulate Zabbix servers using the Zabbix API.}
s.licenses = "LGPL 2.1"
s.requirements = "Requires json"
s.add_dependency('json')
s.require_paths =["."]
s.files =
["LICENSE", "zbxapi.rb", "zbxapi/zdebug.rb", "zbxapi/api_exceptions.rb",
"zbxapi/exceptions.rb", "zbxapi/utils.rb", "zbxapi/result.rb",
"api_classes/api_dsl.rb",
# "zbxapi/revision.rb",
Dir["api_classes/dsl*.rb"]].flatten
end
Gem::PackageTask.new(spec) do |pkg|
pkg.package_dir = "gems"
# pkg.version="#{ENV["release_ver"]}"
# pkg.version = "0.1.#{$rev}"
end