forked from markbates/configatron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
105 lines (95 loc) · 3.11 KB
/
Rakefile
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
require 'rake'
require 'rake/gempackagetask'
require 'rake/clean'
require 'rake/testtask'
require 'rake/rdoctask'
require 'find'
require 'rubyforge'
require 'rubygems'
require 'rubygems/gem_runner'
require 'spec'
require 'spec/rake/spectask'
require 'pathname'
@gem_spec = Gem::Specification.new do |s|
s.name = "configatron"
s.version = "2.2.2"
s.summary = "A powerful Ruby configuration system."
s.description = "Configatron was developed by: markbates"
s.author = "markbates"
s.email = "[email protected]"
s.homepage = "http://www.mackframework.com"
s.test_files = FileList['test/**/*', 'spec/**/*']
s.files = FileList['lib/**/*.rb', 'README', 'doc/**/*.*', 'bin/**/*.*']
s.require_paths << 'lib'
#s.bindir = "bin"
#s.executables << "configatron"
#s.default_executable = ""
#s.add_dependency("", "")
#s.add_dependency("", "")
#s.extensions << ""
s.extra_rdoc_files = ["README"]
s.has_rdoc = true
#s.platform = "Gem::Platform::Ruby"
#s.required_ruby_version = ">= 1.8.5"
#s.requirements << "An ice cold beer."
#s.requirements << "Some free time!"
s.rubyforge_project = "magrathea"
end
# rake package
Rake::GemPackageTask.new(@gem_spec) do |pkg|
pkg.need_zip = false
pkg.need_tar = false
rm_f FileList['pkg/**/*.*']
end
desc 'Run specifications'
Spec::Rake::SpecTask.new(:default) do |t|
t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
t.spec_files = FileList['spec/**/*_spec.rb']
end
desc "Install the gem"
task :install => :package do |t|
puts `sudo gem install --local pkg/#{@gem_spec.name}-#{@gem_spec.version}.gem --no-update-sources`
end
desc "Release the gem"
task :release => :install do |t|
begin
ac_path = File.join(ENV["HOME"], ".rubyforge", "auto-config.yml")
if File.exists?(ac_path)
fixed = File.open(ac_path).read.gsub(" ~: {}\n\n", '')
fixed.gsub!(/ !ruby\/object:Gem::Version \? \n.+\n.+\n\n/, '')
puts "Fixing #{ac_path}..."
File.open(ac_path, "w") {|f| f.puts fixed}
end
begin
rf = RubyForge.new
rf.configure
rf.login
rf.add_release(@gem_spec.rubyforge_project, @gem_spec.name, @gem_spec.version, File.join("pkg", "#{@gem_spec.name}-#{@gem_spec.version}.gem"))
rescue Exception => e
if e.message.match("Invalid package_id") || e.message.match("no <package_id> configured for")
puts "You need to create the package!"
rf.create_package(@gem_spec.rubyforge_project, @gem_spec.name)
rf.add_release(@gem_spec.rubyforge_project, @gem_spec.name, @gem_spec.version, File.join("pkg", "#{@gem_spec.name}-#{@gem_spec.version}.gem"))
else
raise e
end
end
rescue Exception => e
if e.message == "You have already released this version."
puts e
else
raise e
end
end
end
Rake::RDocTask.new do |rd|
rd.main = "README"
files = Dir.glob("**/*.rb")
files = files.collect {|f| f unless f.match("test/") || f.match("doc/") || f.match("spec/") }.compact
files << "README"
rd.rdoc_files = files
rd.rdoc_dir = "doc"
rd.options << "--line-numbers"
rd.options << "--inline-source"
rd.title = "Configatron"
end