This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile.rb
125 lines (106 loc) · 3.38 KB
/
Rakefile.rb
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
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'
$RAKE_ENV = true
init_file = File.join(File.dirname(__FILE__) / "config" / "init")
Merb.load_dependencies(init_file)
include FileUtils
# # # Get Merb plugins and dependencies
Merb::Plugins.rakefiles.each {|r| require r }
desc "load merb_init.rb"
task :merb_init do
require 'merb-core'
require File.dirname(__FILE__)+'/config/init.rb'
end
task :uninstall => [:clean] do
sh %{sudo gem uninstall #{NAME}}
end
# =====================================================
# = This whole section is really gerryrigged. FIXME!: =
# =====================================================
# You'll want to set DB=p|d|t etc with this:
# rake migrate DB=t
task :migrate do
env = case ENV['DB']
when 'p'
'production'
when 't'
'test'
else
'development'
end
puts "Migrating #{env}."
system "rake dm:db:automigrate MERB_ENV=\"#{env}\" &>/dev/null" # System'ing it, to silence it.
end
task :migrate_test do
system 'rake dm:db:automigrate MERB_ENV="test" &>/dev/null'
end
task :run_specs do
dirs = []
Dir['app/*'].each do |dir|
dirs << Dir['spec/' + dir.gsub(%r|^app/|,'') + '/**/*']
end
files = dirs.flatten.map{|d|"\"#{d}\""}.join(' ')
system 'spec --format specdoc --colour ' + files
end
desc 'Migrate, then run specs'
task :aok => [:migrate_test, :run_specs]
# =======================================================
# = This is pretty bad too, but not AS bad. FIXME ALSO: =
# =======================================================
unless Gem.cache.search("haml").empty?
namespace :haml do
desc "Compiles all sass files into CSS"
task :compile_sass do
gem 'haml'
require 'sass'
puts "*** Updating stylesheets"
Sass::Plugin.update_stylesheets
puts "*** Done"
end
desc "Move gen'd .erb files to .haml"
task :erb2haml do
require 'fileutils'
print 'gitillate? '
gitillate = STDIN.gets.match /^y(es)?$/
affirm = Proc.new { |what|
puts what
print 'move? '
affirmation = STDIN.gets
}
Dir['**/*'].each do |filename|
if filename.match /\.erb$/
affirmation = affirm.call(filename).match /^y(es)?$/
if affirmation
new_filename = filename.gsub(/\.erb$/, '.haml')
FileUtils.cp(filename, new_filename)
if gitillate
if system "git rm './#{filename}'"
system "git add './#{new_filename}'"
end # if system git rm
end # if gitillate
end # if affirmation
end # filename .erb
if filename.match /\.erb_spec\./
affirmation = affirm.call(filename).match /^y(es)?$/
if affirmation
new_filename = filename.gsub(/\.erb_spec\./, '.haml_spec.')
FileUtils.cp(filename, new_filename)
if gitillate
if system "git rm './#{filename}'"
system "git add './#{new_filename}'"
end # if system git rm
end # if gitillate
end # if affirmation
end # filename .erb_spec.
end # Dir each
end # task :erb2haml
end # namespace :haml
end # unless gem cache