forked from flapjack/flapjack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
136 lines (116 loc) · 3.78 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
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
#!/usr/bin/env ruby
require 'rubygems'
require 'fileutils'
require 'spec/rake/spectask'
# integration tests for cli utils
begin
require 'cucumber/rake/task'
Cucumber::Rake::Task.new do |task|
task.cucumber_opts = "--require features/"
end
rescue LoadError
end
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ["--options", "spec/spec.opts"]
end
desc "generate list of files for gemspec"
task "gengemfiles" do
executables = `git ls-files bin/*`.split.map {|bin| bin.gsub(/^bin\//, '')}
files = `git ls-files`.split.delete_if {|file| file =~ /^(spec\/|\.gitignore)/}
puts
puts "Copy and paste into flapjack.gemspec:"
puts
puts " s.executables = #{executables.inspect}"
puts " s.files = #{files.inspect}"
puts
puts
end
desc "build gem"
task :build do
system("gem build flapjack.gemspec")
FileUtils.mkdir_p('pkg')
puts
puts "Flapjack gems:"
Dir.glob("flapjack-*.gem").each do |gem|
dest = File.join('pkg', gem)
FileUtils.mv gem, dest
puts " " + dest
end
end
desc "display FIXMEs in the codebase"
task :fixmes do
output = `grep -nR FIXME lib/* spec/* bin/`
output.split("\n").each do |line|
parts = line.split(':')
puts "#{parts[0].strip} +#{parts[1].strip}"
puts " - #{parts[3].strip}"
end
end
desc "build a tarball suitable for building packages from"
task :tarball do
require 'open-uri'
require 'tmpdir'
tmpdir = Dir.mktmpdir
current_commit = `git log`.first.split[1][0..5]
release_tarball = "/tmp/flapjack-#{current_commit}.tar.gz"
flapjack_path = File.join(tmpdir, "flapjack-#{current_commit}")
repo_path = File.expand_path(File.dirname(__FILE__))
ignores = %w(.gitignore .git)
# create new staging directory
command = "git clone #{repo_path} #{flapjack_path}"
`#{command}`
# remove files we don't want to publish
ignores.each do |filename|
path = File.join(flapjack_path, filename)
FileUtils.rm_rf(path)
end
deps = { :daemons => {
:source => "http://rubyforge.org/frs/download.php/34223/daemons-1.0.10.tgz",
:filename => "daemons-1.0.10.tar.gz"
},
:beanstalkd_client => {
:source => "http://github.com/kr/beanstalk-client-ruby/tarball/v1.0.2",
:filename => "beanstalkd-client-1.0.2.tar.gz"
},
:yajl_ruby => {
:source => "http://github.com/brianmario/yajl-ruby/tarball/0.6.4",
:filename => "yajl-ruby-0.6.4.tar.gz"
},
:tmail => {
:source => "http://rubyforge.org/frs/download.php/35297/tmail-1.2.3.1.tgz",
:filename => "tmail-1.2.3.1.tar.gz"
},
:xmpp4r => {
:source => "http://download.gna.org/xmpp4r/xmpp4r-0.4.tgz",
:filename => "xmpp4r-0.4.tar.gz"
},
:log4r => {
:source => "http://qa.debian.org/watch/sf.php/log4r/log4r-1.0.5.tgz",
:filename => "log4r-1.0.5.tar.gz"
}
}
deps.each_pair do |name, details|
puts "Pulling in #{name} dependency..."
# save file
saved_file = "/tmp/#{details[:filename]}"
File.open(saved_file, 'w') do |f|
f << open(details[:source]).read
end
`tar zxf #{saved_file} -C #{tmpdir}`
end
# build tarball
under = File.dirname(tmpdir)
staging = File.join("/tmp", "flapjack-#{current_commit}")
FileUtils.mv(tmpdir, staging)
actual = File.basename(staging)
command = "cd #{under} ; tar czf #{release_tarball} #{actual}"
system(command)
puts "Release tarball with deps at #{release_tarball}"
end
desc "dump out statements to create sqlite3 schema"
task :dm_debug do
require 'lib/flapjack/persistence/data_mapper'
DataMapper.logger.set_log(STDOUT, :debug)
DataMapper.setup(:default, "sqlite3:///tmp/sqlite3.db")
DataMapper.auto_migrate!
end