-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
126 lines (102 loc) · 3.26 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
require 'rubygems'
Gem.clear_paths
Gem.path.unshift(File.join(File.dirname(__FILE__), "gems"))
require 'rake'
require 'rake/rdoctask'
require 'rake/testtask'
require 'spec/rake/spectask'
require 'fileutils'
require 'merb-core'
require 'rubigen'
include FileUtils
# Load the basic runtime dependencies; this will include
# any plugins and therefore plugin rake tasks.
init_env = ENV['MERB_ENV'] || 'rake'
Merb.load_dependencies(:environment => init_env)
# Get Merb plugins and dependencies
Merb::Plugins.rakefiles.each { |r| require r }
desc "start runner environment"
task :merb_env do
Merb.start_environment(:environment => init_env, :adapter => 'runner')
end
##############################################################################
# ADD YOUR CUSTOM TASKS BELOW
##############################################################################
desc "Add new files to subversion"
task :svn_add do
system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
end
class Freezer
class << self
def components
{
"core" => "git://github.com/wycats/merb-core.git",
"more" => "git://github.com/wycats/merb-more.git",
"plugins" => "git://github.com/wycats/merb-plugins.git"
}
end
def framework_dir
# Should allow customization of this directory's location?
File.join(File.dirname(__FILE__), "framework")
end
def gitmodules
File.join(File.dirname(__FILE__), ".gitmodules")
end
def freeze(component, update = false)
new(component, update).freeze
end
end
def initialize(component, update)
@component = "merb-" + component
@update = update
end
def freeze
# Ensure that required git commands are available
%w(git-pull git-submodule).each do |bin|
next if in_path?(bin)
$stderr.puts "ERROR: #{bin} must be avaible in PATH"
exit 1
end
unless File.directory?(framework_dir)
puts "Creating framework directory ..."
FileUtils.mkdir_p(framework_dir)
end
if managed?
puts "#{@component} seems to be already managed by git-submodule."
if @update
puts "Trying to update #{@component} ..."
sh "cd #{framework_dir}/#{@component} && git-pull"
end
else
puts "Creating submodule for #{@component} ..."
sh "git-submodule --quiet add #{components[@component.gsub("merb-", '')]} #{File.basename(framework_dir)}/#{@component}"
if $?.success?
sh("git-submodule init")
else
# Should this instead be a raise?
$stderr.puts("ERROR: unable to create submodule for #{@component}")
end
end
end
protected
def in_submodule?
return false unless File.exists?(gitmodules)
File.read(gitmodules) =~ %r![submodule "#{framework_dir}/#{@component}"]!
end
def managed?
File.directory?(File.join(framework_dir, @component)) || in_submodule?
end
def in_path?(bin)
`which #{bin}`
!$?.nil? && $?.success?
end
end
task :freeze => Freezer.components.keys.map { |component| "freeze:#{component}" }
namespace :freeze do
Freezer.components.each do |component, git_repository|
desc "Freeze #{component} from #{git_repository}"
task component do
Freezer.freeze(component, ENV["UPDATE"])
end
end
end