Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 101 lines (84 sloc) 2.473 kb
4059ebf @mojombo Initial commit
mojombo authored
1 require 'rubygems'
19531db @mojombo switch to jeweler for package management
mojombo authored
2 require 'rake'
507cd91 @mojombo remove jeweller in preference of oldskool rake tasks
mojombo authored
3 require 'date'
19531db @mojombo switch to jeweler for package management
mojombo authored
4
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
5 NAME = 'god'
6
507cd91 @mojombo remove jeweller in preference of oldskool rake tasks
mojombo authored
7 def source_version
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
8 line = File.read("lib/#{NAME}.rb")[/^\s*VERSION = .*/]
507cd91 @mojombo remove jeweller in preference of oldskool rake tasks
mojombo authored
9 line.match(/.*VERSION = '(.*)'/)[1]
19531db @mojombo switch to jeweler for package management
mojombo authored
10 end
11
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
12 def gemspec_file
13 "#{NAME}.gemspec"
14 end
15
16 def gem_file
17 "#{NAME}-#{source_version}.gem"
18 end
19
19531db @mojombo switch to jeweler for package management
mojombo authored
20 require 'rake/testtask'
21 Rake::TestTask.new(:test) do |test|
22 test.libs << 'lib' << 'test'
23 test.pattern = 'test/**/test_*.rb'
24 test.verbose = true
4059ebf @mojombo Initial commit
mojombo authored
25 end
26
19531db @mojombo switch to jeweler for package management
mojombo authored
27 task :default => :test
28
4059ebf @mojombo Initial commit
mojombo authored
29 desc "Open an irb session preloaded with this library"
30 task :console do
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
31 sh "irb -rubygems -r ./lib/#{NAME}.rb"
4059ebf @mojombo Initial commit
mojombo authored
32 end
33
cd03838 @mojombo added site uploading task to rakefile, updated site index
mojombo authored
34 desc "Upload site to Rubyforge"
35 task :site do
36 sh "scp -r site/* mojombo@god.rubyforge.org:/var/www/gforge-projects/god"
37 end
38
9808a33 @mojombo fix byte-centric sugar (kb is canonical not bytes); make god binary pid ...
mojombo authored
39 desc "Upload site to Rubyforge"
40 task :site_edge do
41 sh "scp -r site/* mojombo@god.rubyforge.org:/var/www/gforge-projects/god/edge"
f867b54 @mojombo timer tests, log output cleanup, rakefile, gitignore
mojombo authored
42 end
43
44 desc "Run rcov"
45 task :coverage do
46 `rm -fr coverage`
47 `rcov test/test_*.rb`
48 `open coverage/index.html`
19531db @mojombo switch to jeweler for package management
mojombo authored
49 end
50
51 require 'rake/rdoctask'
52 Rake::RDocTask.new do |rdoc|
53 rdoc.rdoc_dir = 'rdoc'
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
54 rdoc.title = "#{NAME} #{source_version}"
19531db @mojombo switch to jeweler for package management
mojombo authored
55 rdoc.rdoc_files.include('README*')
56 rdoc.rdoc_files.include('lib/**/*.rb')
507cd91 @mojombo remove jeweller in preference of oldskool rake tasks
mojombo authored
57 end
58
59 if defined?(Gem)
50dffb4 @mojombo add rake release
mojombo authored
60 task :release => :build do
8924ec6 @mojombo do not allow release unless on master branch
mojombo authored
61 unless `git branch` =~ /^\* master$/
62 puts "You must be on the master branch to release!"
63 exit!
64 end
50dffb4 @mojombo add rake release
mojombo authored
65 sh "git commit --allow-empty -a -m 'up to #{source_version}'"
66 sh "git tag v#{source_version}"
a54ed22 @mojombo push tags during release
mojombo authored
67 sh "git push origin master --tags"
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
68 sh "gem push pkg/#{NAME}-#{source_version}.gem"
50dffb4 @mojombo add rake release
mojombo authored
69 end
70
5af7320 @mojombo fix gemspec task (wrong quotes)
mojombo authored
71 task :build => :gemspec do
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
72 sh "mkdir -p pkg"
73 sh "gem build #{gemspec_file}"
74 sh "mv #{gem_file} pkg"
08e1c98 @mojombo add build task
mojombo authored
75 end
76
5af7320 @mojombo fix gemspec task (wrong quotes)
mojombo authored
77 task :gemspec do
507cd91 @mojombo remove jeweller in preference of oldskool rake tasks
mojombo authored
78 # read spec file and split out manifest section
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
79 spec = File.read(gemspec_file)
507cd91 @mojombo remove jeweller in preference of oldskool rake tasks
mojombo authored
80 head, manifest, tail = spec.split(" # = MANIFEST =\n")
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
81
507cd91 @mojombo remove jeweller in preference of oldskool rake tasks
mojombo authored
82 # replace version and date
83 head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
84 head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
85
507cd91 @mojombo remove jeweller in preference of oldskool rake tasks
mojombo authored
86 # determine file list from git ls-files
87 files = `git ls-files`.
88 split("\n").
89 sort.
90 reject { |file| file =~ /^\./ }.
ea2c42f @mojombo rake generated gemspec
mojombo authored
91 reject { |file| file =~ /^(ideas|init|site)/ }.
507cd91 @mojombo remove jeweller in preference of oldskool rake tasks
mojombo authored
92 map { |file| " #{file}" }.
93 join("\n")
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
94
95 # piece file back together and write
507cd91 @mojombo remove jeweller in preference of oldskool rake tasks
mojombo authored
96 manifest = " s.files = %w[\n#{files}\n ]\n"
97 spec = [head, manifest, tail].join(" # = MANIFEST =\n")
fca9065 @mojombo make rake tasks a bit more generic
mojombo authored
98 File.open(gemspec_file, 'w') { |io| io.write(spec) }
99 puts "Updated #{gemspec_file}"
507cd91 @mojombo remove jeweller in preference of oldskool rake tasks
mojombo authored
100 end
e508700 @mojombo default stop for auto-daemonized; bug fixes
mojombo authored
101 end
Something went wrong with that request. Please try again.