sandro / srg

Sandro's rails generator

This URL has Read+Write access

srg / srg.rb
100644 100 lines (79 sloc) 2.037 kb
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
def app_name
  @app_name ||= File.basename(root)
end
 
def app_name_underscore
  @app_name_underscore ||= app_name.gsub(' ', '_').underscore
end
 
#====================
# PREPARE
#====================
FileUtils.rm_rf %w(public/index.html public/images/rails.png test)
run 'touch public/stylesheets/application.css db/schema.rb'
 
file 'README', <<-END
#{app_name}
===============================
END
 
file 'config/routes.rb', <<-END
ActionController::Routing::Routes.draw do |map|
end
END
 
file 'config/database.yml', <<-END
development:
adapter: mysql
username: root
password:
database: #{app_name_underscore}_development
 
test:
adapter: sqlite3
database: db/#{app_name_underscore}_test.sqlite3
pool: 5
timeout: 5000
END
 
append_file 'Rakefile', <<-END
Rake::Task[:default].clear
task :default => :spec
END
 
 
#====================
# GEMS
#====================
gem 'giraffesoft-resource_controller', :lib => 'resource_controller', :source => "http://gems.github.com"
gem "haml"
gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'
gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com'
 
gem 'rspec', :env => 'test', :lib => false, :source => 'http://gems.github.com'
gem 'rspec-rails', :env => 'test', :lib => false, :source => 'http://gems.github.com'
 
#====================
# SETUP
#====================
 
rake "gems:install", :sudo => true
rake "db:create:all"
 
generate "rspec"
file 'spec/spec.opts', <<-END
--colour
--format specdoc
--loadby mtime
END
 
generate "homeward"
rake "homeward:install"
 
rake "log:clear"
 
#====================
# GIT
#====================
 
git :init
 
file '.gitignore', <<-END
.DS_Store
config/database.yml
config/settings.yml
coverage/*
db/*.db
db/*.sqlite3
doc/api
doc/app
log/*.log
tmp/**/*
tmp/tags
END
 
run "cp config/database.yml config/database.example.yml"
run 'find . \( -type d -empty \) -and \( -not -regex ./\.git.* \) -exec touch {}/.gitignore \;'
 
git :add => "."
git :commit => "-a -m 'Generated project'"