File: Rakefile

package info (click to toggle)
rerun 0.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 412 kB
  • sloc: ruby: 1,360; sh: 22; makefile: 11
file content (82 lines) | stat: -rw-r--r-- 1,926 bytes parent folder | download | duplicates (4)
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
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rspec/core/rake_task'

task :default => [:spec]
task :test => :spec

desc "Run all specs"
RSpec::Core::RakeTask.new('spec') do |t|
  ENV['ENV'] = "test"
  t.pattern = 'spec/**/*_spec.rb'
  t.rspec_opts = ['--color']
end

$rubyforge_project = 'pivotalrb'

$spec =
  begin
    require 'rubygems/specification'
    data = File.read('rerun.gemspec')
    spec = nil
    #Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
    spec = eval data
    spec
  end

def package(ext='')
  "pkg/#{$spec.name}-#{$spec.version}" + ext
end

desc 'Exit if git is dirty'
task :check_git do
  state = `git status 2> /dev/null | tail -n1`
  clean = (state =~ /working (directory|tree) clean/)
  unless clean
    warn "can't do that on an unclean git dir"
    exit 1
  end
end

desc 'Build packages'
task :package => %w[.gem .tar.gz].map { |e| package(e) }

desc 'Build and install as local gem'
task :install => package('.gem') do
  sh "gem install #{package('.gem')}"
end

directory 'pkg/'
CLOBBER.include('pkg')

file package('.gem') => %W[pkg/ #{$spec.name}.gemspec] + $spec.files do |f|
  sh "gem build #{$spec.name}.gemspec"
  mv File.basename(f.name), f.name
end

file package('.tar.gz') => %w[pkg/] + $spec.files do |f|
  cmd = <<-SH
    git archive \
      --prefix=#{$spec.name}-#{$spec.version}/ \
      --format=tar \
      HEAD | gzip > #{f.name}
  SH
  sh cmd.gsub(/ +/, ' ')
end

desc 'Publish gem and tarball to rubyforge'
task 'release' => [:check_git, package('.gem'), package('.tar.gz')] do |t|
  puts "Releasing #{$spec.version}"
  sh "gem push #{package('.gem')}"
  puts "Tagging and pushing"
  sh "git tag v#{$spec.version}"
  sh "git push && git push --tags"
end

desc 'download github issues and pull requests'
task 'github' do
  %w(issues pulls).each do |type|
    sh "curl -o #{type}.json https://api.github.com/repos/alexch/rerun/#{type}"
  end
end