-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path003_haml.rails
137 lines (111 loc) · 3.6 KB
/
003_haml.rails
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
137
# HAML template
#
# Builds on top of:
# - 003_haml.rails
#
# Provides:
# - HAML support
#
# Helper methods
# After the first run of ./script/server, the init file is missing
# the "require 'rubygems'" line...we don't want to have to commit
# that in or leave the repository in a dirty state after the first
# "quick run"...
def replace_default_haml_init
filename = "vendor/plugins/haml/init.rb"
run "rm -f #{filename}"
file filename,
%q{begin
require File.join(File.dirname(__FILE__), 'lib', 'haml') # From here
rescue LoadError
require 'haml' # From gem
end
# Load Haml and Sass
Haml.init_rails(binding)
}
end
def replace_default_test_environment_config
filename = "config/environments/test.rb"
run "rm -f #{filename}"
file filename,
%q{# Settings specified here will take precedence over those in config/environment.rb
config.gem 'webrat', :lib => false
config.gem 'rspec-rails', :lib => false, :version => '>= 1.2.2'
config.gem 'rspec', :lib => false, :version => '>= 1.2.2'
config.gem 'cucumber'
config.gem 'ZenTest'
config.gem 'builder'
config.gem 'diff-lcs', :lib => 'diff/lcs'
config.gem 'nokogiri'
config.gem 'treetop'
config.gem 'term-ansicolor', :lib => 'term/ansicolor'
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_view.cache_template_loading = true
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
}
end
# rails:rm_tmp_dirs
["./tmp/pids", "./tmp/sessions", "./tmp/sockets", "./tmp/cache"].each do |f|
run("rmdir ./#{f}")
end
# Delete unnecessary files
run "rm README"
run "rm doc/README_FOR_APP"
run "rm public/favicon.ico"
run "rm public/robots.txt"
# Remove test dir...this uses RSpec
run "rm -rf test"
# git:hold_empty_dirs
run("find . \\( -type d -empty \\) -and \\( -not -regex ./\\.git.* \\) -exec touch {}/.gitignore \\;")
# git:rails:new_app
git :init
file '.gitignore', <<-CODE
log/*.log
log/*.pid
db/*.db
db/*.sqlite3
db/schema.rb
tmp/**/*
.DS_Store
doc/api
doc/app
config/database.yml
CODE
run "cp config/database.yml config/database.yml.sample"
# Migrate to create a db/schema.rb file
rake "db:migrate"
gem "haml"
# Add in test environment-specific gems & config
replace_default_test_environment_config
if yes?("Install gems on local system? (y/n)")
rake("gems:install", :sudo => true)
rake("gems:install", :sudo => true, :env => "test")
end
# Initialize submodules
git :submodule => "init"
# Generate RSpec & cucumber support/directory system
generate("rspec")
generate("cucumber")
# Initialize haml in project
run "haml --rails ."
replace_default_haml_init
git :add => "."
git :commit => "-a -m 'Initial commit'"