rails_apps_composer 1.5.5 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +185 -254
- data/lib/rails_wizard/command.rb +54 -13
- data/lib/rails_wizard/config.rb +1 -1
- data/lib/rails_wizard/diagnostics.rb +22 -0
- data/lib/rails_wizard/template.rb +36 -2
- data/lib/rails_wizard.rb +1 -0
- data/recipes/auth.rb +84 -0
- data/recipes/controllers.rb +58 -0
- data/recipes/{seed_database.rb → database.rb} +35 -22
- data/recipes/{action_mailer.rb → email.rb} +29 -50
- data/recipes/example.rb +70 -0
- data/recipes/extras.rb +91 -30
- data/recipes/frontend.rb +59 -0
- data/recipes/gems.rb +128 -0
- data/recipes/models.rb +61 -0
- data/recipes/prelaunch.rb +45 -0
- data/recipes/readme.rb +83 -0
- data/recipes/routes.rb +36 -0
- data/recipes/setup.rb +148 -0
- data/recipes/testing.rb +187 -0
- data/recipes/views.rb +39 -0
- data/spec/rails_wizard/template_spec.rb +4 -2
- data/templates/helpers.erb +53 -2
- data/templates/layout.erb +81 -20
- data/version.rb +1 -1
- metadata +19 -49
- data/recipes/active_admin.rb +0 -36
- data/recipes/activerecord.rb +0 -37
- data/recipes/add_user.rb +0 -140
- data/recipes/airbrake.rb +0 -34
- data/recipes/backbone.rb +0 -23
- data/recipes/capybara.rb +0 -34
- data/recipes/cleanup.rb +0 -40
- data/recipes/cloudfiles.rb +0 -36
- data/recipes/compass.rb +0 -46
- data/recipes/compass_960.rb +0 -48
- data/recipes/cucumber.rb +0 -75
- data/recipes/datamapper.rb +0 -111
- data/recipes/devise.rb +0 -114
- data/recipes/git.rb +0 -40
- data/recipes/guard.rb +0 -89
- data/recipes/haml.rb +0 -23
- data/recipes/heroku.rb +0 -61
- data/recipes/home_page.rb +0 -58
- data/recipes/home_page_users.rb +0 -47
- data/recipes/html5.rb +0 -152
- data/recipes/inherited_resources.rb +0 -23
- data/recipes/less.rb +0 -12
- data/recipes/mongohq.rb +0 -59
- data/recipes/mongoid.rb +0 -38
- data/recipes/mongolab.rb +0 -59
- data/recipes/omniauth.rb +0 -194
- data/recipes/omniauth_email.rb +0 -82
- data/recipes/paperclip.rb +0 -79
- data/recipes/prelaunch_signup.rb +0 -586
- data/recipes/rails_admin.rb +0 -29
- data/recipes/redis.rb +0 -23
- data/recipes/responders.rb +0 -10
- data/recipes/resque.rb +0 -25
- data/recipes/rspec.rb +0 -131
- data/recipes/sass.rb +0 -25
- data/recipes/settingslogic.rb +0 -43
- data/recipes/simple_form.rb +0 -54
- data/recipes/slim.rb +0 -46
- data/recipes/static_page.rb +0 -43
- data/recipes/subdomains.rb +0 -121
- data/recipes/turnip.rb +0 -18
- data/recipes/unicorn.rb +0 -29
- data/recipes/users_page.rb +0 -165
data/README.textile
CHANGED
@@ -1,396 +1,327 @@
|
|
1
|
-
h1. !http://railsapps.github.com/images/rails-36x36.jpg(Rails Apps Composer Gem)! Rails Apps Composer
|
1
|
+
h1. !http://railsapps.github.com/images/rails-36x36.jpg(Rails Apps Composer Gem)! Rails Apps Composer 2.0
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
* Create and maintain a starter app.
|
6
|
-
* Make an application template that generates a complex Rails app in seconds.
|
7
|
-
|
8
|
-
We use the rails_apps_composer gem to create the "Rails Example Apps":http://railsapps.github.com/ for the "RailsApps project":https://github.com/RailsApps.
|
3
|
+
The Rails Apps Composer gem installs a command line tool to assemble a Rails application from a collection of "recipes."
|
9
4
|
|
10
|
-
|
5
|
+
What you can do with the rails_apps_composer gem:
|
11
6
|
|
12
|
-
|
7
|
+
* create a starter app from the command line
|
8
|
+
* make a reusable application template
|
13
9
|
|
14
|
-
The
|
10
|
+
The "Rails Composer":http://railsapps.github.com/rails-composer/ tool is built with the rails_apps_composer gem. The Rails Composer tool creates the "example applications":http://railsapps.github.com/ for the "RailsApps":http://railsapps.github.com/ project.
|
15
11
|
|
16
|
-
|
12
|
+
The "Guide to the Rails Apps Composer Gem":http://railsapps.github.com/tutorial-rails-apps-composer.html provides complete documentation:
|
17
13
|
|
18
|
-
|
14
|
+
* "Overview":http://railsapps.github.com/tutorial-rails-apps-composer.html#Overview
|
15
|
+
* "Recipes":http://railsapps.github.com/tutorial-rails-apps-composer.html#Recipes
|
16
|
+
* "Usage":http://railsapps.github.com/tutorial-rails-apps-composer.html#Usage
|
17
|
+
* "Diagnostics":http://railsapps.github.com/tutorial-rails-apps-composer.html#Diagnostics
|
18
|
+
* "Hacking the Gem":http://railsapps.github.com/tutorial-rails-apps-composer.html#Hacking
|
19
|
+
* "Anatomy of a Recipe":http://railsapps.github.com/tutorial-rails-apps-composer.html#Anatomy
|
20
|
+
* "Architecture":http://railsapps.github.com/tutorial-rails-apps-composer.html#Architecture
|
21
|
+
* "Defaults File":http://railsapps.github.com/tutorial-rails-apps-composer.html#Defaults
|
19
22
|
|
20
|
-
|
23
|
+
Any issues? Please create a "GitHub issue":http://github.com/RailsApps/rails_apps_composer/issues.
|
21
24
|
|
22
25
|
h2. !http://twitter-badges.s3.amazonaws.com/t_logo-a.png(Follow on Twitter)!:http://www.twitter.com/rails_apps Follow on Twitter
|
23
26
|
|
24
27
|
Follow the project on Twitter: "@rails_apps":http://twitter.com/rails_apps. Tweet some praise if you like what you've found.
|
25
28
|
|
26
|
-
h2.
|
29
|
+
h2. What's New in Version 2.0
|
27
30
|
|
28
|
-
|
31
|
+
Rails_apps_composer 2.0 is significantly different from earlier versions:
|
29
32
|
|
30
|
-
|
33
|
+
* the "Guide":http://railsapps.github.com/tutorial-rails-apps-composer.html provides complete documentation
|
34
|
+
* diagnostics compare your selected recipes and preferences to known working combinations
|
35
|
+
* the generated application README.textile file provides a diagnostics report
|
36
|
+
* an improved "quiz" sets preferences
|
37
|
+
* a new preferences hash makes preferences available to all recipes
|
38
|
+
* recipes and preferences can be set in a defaults file
|
39
|
+
* gems can be added at a prompt or from a defaults file (no need to write a recipe for many gems)
|
40
|
+
* a new 'copy_from_repo' method adds powerful downloading of files to any recipe
|
41
|
+
* downloading of files from the example app repos reduces the complexity of recipes
|
42
|
+
* the 'copy_from_repo' method converts ERB files to Haml or Slim
|
43
|
+
* recipes have been reorganized for easier maintenance
|
44
|
+
* recipes are based on functionality (e.g., authentication, testing) instead of gems (Devise, RSpec)
|
45
|
+
* a prompt sets -T or -O args when generating an application
|
46
|
+
* the 'extras' recipe creates a project-specific gemset and .rvmrc file
|
31
47
|
|
32
|
-
|
48
|
+
Most important, many unsupported or outdated recipes have been removed. If your favorite recipe is missing, please update it and test it with version 2.0, then submit a pull request. I'm happy to add new recipes.
|
49
|
+
|
50
|
+
h2. Who This Is For
|
51
|
+
|
52
|
+
This gem is for experienced Rails developers who need a tool to create and maintain a Rails starter app or Rails application template. If you're regularly building Rails applications that use certain popular gems or rely on common functionality such as authentication, you can benefit from the rails_apps_composer gem.
|
33
53
|
|
34
|
-
|
54
|
+
If you are new to Rails, try the "Rails Composer":http://railsapps.github.com/rails-composer/ tool instead. It provides an application template that is generated from the rails_apps_composer gem's core recipes. It is easier to use.
|
35
55
|
|
36
|
-
|
56
|
+
h2. Alternatives
|
37
57
|
|
38
|
-
|
58
|
+
The rails_apps_composer gem is derived from Michael Bleigh's "RailsWizard":https://github.com/intridea/rails_wizard gem. Early versions of the rails_apps_composer gem were a close fork of Michael Bleigh's gem; rails_apps_composer 2.0 differs substantially. Other notable alternatives are Dr. Nic Williams's "App Scrolls":http://appscrolls.org/ and Daniel Davey's "app_drone":http://drone.bz/. See a list of "Rails Application Template Projects":http://railsapps.github.com/rails-application-templates.html, particularly a list of "Application template-generating gems" for similar projects.
|
39
59
|
|
40
60
|
h2. Dependencies
|
41
61
|
|
42
|
-
Before
|
62
|
+
Before using the rails_apps_composer gem, you will need:
|
43
63
|
|
44
64
|
* The Ruby language (version 1.9.3)
|
45
65
|
* Rails 3.1 or newer
|
46
66
|
|
47
|
-
See "Installing Rails":http://railsapps.github.com/installing-rails.html for
|
67
|
+
See the article "Installing Rails":http://railsapps.github.com/installing-rails.html for advice about updating Rails and your development environment.
|
48
68
|
|
49
69
|
h2. Installation
|
50
70
|
|
71
|
+
I recommend installing and using rvm, the "Ruby Version Manager":https://rvm.io/, to create a new gemset for rails_apps_composer. Using an rvm gemset will make it easier to identify and isolate incompatibilities among gems.
|
72
|
+
|
51
73
|
Installation is simple:
|
52
74
|
|
53
75
|
@$ gem install rails_apps_composer@
|
54
76
|
|
55
77
|
h2. Usage
|
56
78
|
|
57
|
-
|
79
|
+
These commands are summarized here for your reference. See the "Guide to the Rails Apps Composer Gem":http://railsapps.github.com/tutorial-rails-apps-composer.html for details.
|
58
80
|
|
59
|
-
|
60
|
-
$ rails_apps_composer list
|
61
|
-
</pre>
|
62
|
-
|
63
|
-
You can learn more about the available recipes by browsing the repository "recipes directory":https://github.com/RailsApps/rails_apps_composer/tree/master/recipes.
|
81
|
+
h3. List Recipes
|
64
82
|
|
65
|
-
|
83
|
+
You can list recipes with short descriptions:
|
66
84
|
|
67
85
|
<pre>
|
68
|
-
$ rails_apps_composer
|
69
|
-
</pre>
|
70
|
-
|
71
|
-
The command with the @-r@ flag followed by a list of recipes generates an app.
|
72
|
-
|
73
|
-
h4. Generate an App from Defaults
|
86
|
+
$ rails_apps_composer list
|
74
87
|
|
75
|
-
|
76
|
-
|
88
|
+
auth # Add authentication and authorization.
|
89
|
+
controllers # Add controllers needed for starter apps.
|
90
|
+
database # Set up and initialize database.
|
91
|
+
email # Configure email accounts.
|
92
|
+
extras # Various extras.
|
93
|
+
frontend # Install a front-end framework for HTML5 and CSS.
|
94
|
+
gems # Add the gems your application needs.
|
95
|
+
models # Add models needed for starter apps.
|
96
|
+
prelaunch # Generates a Prelaunch Signup App
|
97
|
+
readme # Build a README file for your application.
|
98
|
+
routes # Add routes needed for starter apps.
|
99
|
+
setup # Make choices for your application.
|
100
|
+
testing # Add testing framework.
|
101
|
+
views # Add views needed for starter apps.
|
77
102
|
</pre>
|
78
103
|
|
79
|
-
|
80
|
-
|
81
|
-
h4. Generate a Template
|
82
|
-
|
83
|
-
You may want a template to customize or share with others. See various "application templates":https://github.com/RailsApps/rails3-application-templates from the "RailsApps project":https://github.com/RailsApps.
|
104
|
+
The above list is current for rails_apps_composer 2.0; later releases will contain more recipes.
|
84
105
|
|
85
|
-
|
86
|
-
$ rails_apps_composer template ~/Desktop/template.txt -r haml home_page html5
|
87
|
-
</pre>
|
106
|
+
You can learn more about the available recipes by examing the source code in the repository "recipes directory":https://github.com/RailsApps/rails_apps_composer/tree/master/recipes.
|
88
107
|
|
89
|
-
|
108
|
+
h3. Recipe Order and Interdependency
|
90
109
|
|
91
|
-
|
110
|
+
The order in which you input a list or recipes determines the order of execution unless a recipe contains a @requires@ or @run_after@ directive.
|
92
111
|
|
93
|
-
|
94
|
-
$ rails new myapp -m ~/Desktop/template.txt
|
95
|
-
</pre>
|
112
|
+
A recipe may contain a @requires@ directive which specifies other recipes which must be present before a recipe can run. The @requires@ constraint will force the rails_apps_composer program to load any required recipes, even if you don't add them explicitly.
|
96
113
|
|
97
|
-
|
114
|
+
Recipes may also contain a @run_after@ directive. The rails_apps_composer program will organize the order of execution so that any recipes in the @run_after@ list will execute earlier. That is, the recipe will run after everything else in the list.
|
98
115
|
|
99
|
-
|
116
|
+
In general, it's best to add (or list) recipes in the order they should execute as some recipes may not contain a necessary @requires@ or @run_after@ directive.
|
100
117
|
|
101
|
-
|
118
|
+
See the "Anatomy of a Recipe":http://railsapps.github.com/tutorial-rails-apps-composer.html#Anatomy section in the Guide to learn about the format of a recipe.
|
102
119
|
|
103
|
-
|
104
|
-
$ rails_apps_composer new myapp -r haml home_page html5
|
105
|
-
</pre>
|
120
|
+
h3. Skipping Test::Unit or Active Record
|
106
121
|
|
107
|
-
|
122
|
+
If you plan to use RSpec instead of Test::Unit, or use an ORM such as Mongoid instead of Active Record, you can pass the @-T@ or @-O@ flags to the @rails new@ command so it will skip Test::Unit or Active Record.
|
108
123
|
|
109
|
-
|
124
|
+
When you generate an application interactively using the rails_apps_composer gem, the program will ask if you want to skip Test::Unit or Active Record.
|
110
125
|
|
111
|
-
|
126
|
+
When you generate an application template, you will not be asked if you want to skip Test::Unit or Active Record. An application template runs after the @rails new@ command so it cannot set the @-T@ or @-O@ arguments.
|
112
127
|
|
113
|
-
|
114
|
-
$ rails_apps_composer --defaults=~/.rac
|
115
|
-
</pre>
|
128
|
+
Any recipe can set the @-T@ or @-O@ arguments using the @args@ directive. However, this has no affect on application templates and is only useful when an application is generated interactively.
|
116
129
|
|
117
|
-
|
130
|
+
h3. Generate an Application Interactively
|
118
131
|
|
119
|
-
|
132
|
+
You'll be prompted for recipes and gems:
|
120
133
|
|
121
134
|
<pre>
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
ban_spiders: true
|
144
|
-
paginate: false
|
145
|
-
jsruntime: false
|
146
|
-
|
147
|
-
guard:
|
148
|
-
guard: standard
|
149
|
-
|
150
|
-
html5:
|
151
|
-
css_option: bootstrap_sass
|
152
|
-
|
153
|
-
rspec:
|
154
|
-
rspec: true
|
155
|
-
fixtures: factory_girl
|
156
|
-
|
157
|
-
sass:
|
158
|
-
sass: true
|
135
|
+
$ rails_apps_composer new myapp
|
136
|
+
|
137
|
+
Would you like to skip Test::Unit? (yes for RSpec) (y/n)
|
138
|
+
Would you like to skip Active Record? (yes for NoSQL) (y/n)
|
139
|
+
|
140
|
+
Available Recipes:
|
141
|
+
apps: prelaunch
|
142
|
+
auth: auth
|
143
|
+
configuration: email, gems, readme, setup
|
144
|
+
example: example
|
145
|
+
frontend: frontend
|
146
|
+
initialize: database
|
147
|
+
mvc: controllers, models, routes, views
|
148
|
+
other: extras
|
149
|
+
testing: testing
|
150
|
+
|
151
|
+
Which recipe would you like to add? (blank to finish)
|
152
|
+
What gem would you like to add? (blank to finish)
|
153
|
+
|
154
|
+
Generating basic application, using:
|
155
|
+
"rails new myapp -m <temp_file>"
|
159
156
|
</pre>
|
160
157
|
|
161
|
-
You
|
162
|
-
|
163
|
-
The list of recipes at the top will be included whenever you generate an app. The remaining hashes will be used to respond to prompts (questions) that recipes display. If there is no preference specified in the defaults file, rails_apps_composer will ask you to respond with a preference. That way, you can give yourself flexibility if you don't always have the same preference.
|
164
|
-
|
165
|
-
When you run the command with the @--defaults@ option and no recipes specified on the command line, you'll see the prompt, "Which recipe would you like to add? (blank to finish)". If you want to use only your default recipes, just hit return. If you want to add a recipe for the app you are generating, just type the recipe name at the prompt. If you've provided your preferences for the recipe in your defaults file, you won't be prompted for preferences. If you haven't provided default preferences for the additional recipe, you'll be prompted normally.
|
158
|
+
You will only be able to choose recipes that are contained in the rails_apps_composer gem.
|
166
159
|
|
167
|
-
|
160
|
+
You can specify any gem. Any string you enter will be added as a gem in the starter app Gemfile.
|
168
161
|
|
169
|
-
|
162
|
+
h3. Generate an Application from a List of Recipes
|
170
163
|
|
171
|
-
|
164
|
+
Provide a list of recipes:
|
172
165
|
|
173
166
|
<pre>
|
174
|
-
$ rails_apps_composer
|
175
|
-
</pre>
|
176
|
-
|
177
|
-
The command with the @template@ argument followed by a filename and a list of recipes generates an application template.
|
178
|
-
|
179
|
-
The rails_apps_composer gem creates an application template that can be used by the @rails new@ command with the @-m@ option. You can specify a local file as a template. For example:
|
180
|
-
|
181
|
-
<pre>
|
182
|
-
$ rails new myapp -m ~/Desktop/template.txt
|
183
|
-
</pre>
|
184
|
-
|
185
|
-
The @raisl new@ command allows you to specify the @-T -O@ flags as needed to skip Test::Unit files and Active Record files.
|
167
|
+
$ rails_apps_composer new myapp -r setup readme gems testing auth email models controllers views routes frontend database extras
|
186
168
|
|
187
|
-
|
169
|
+
Would you like to skip Test::Unit? (yes for RSpec) (y/n)
|
170
|
+
Would you like to skip Active Record? (yes for NoSQL) (y/n)
|
171
|
+
What gem would you like to add? (blank to finish)
|
188
172
|
|
189
|
-
|
190
|
-
|
173
|
+
Generating basic application, using:
|
174
|
+
"rails new myapp -m <temp_file>"
|
191
175
|
</pre>
|
192
176
|
|
193
|
-
|
194
|
-
|
195
|
-
h2. Recipe Compatibility
|
177
|
+
The program will prompt you for your preferences before generating an application.
|
196
178
|
|
197
|
-
|
179
|
+
h3. Generate an Application from Defaults
|
198
180
|
|
199
|
-
|
200
|
-
|
201
|
-
The maintainers and contributors to the project can't test every combination of recipes. We rely on contributors to alert us to issues and contribute patches as needed. If you find recipes that don't combine properly, please alert us with a "GitHub issue":http://github.com/RailsApps/rails_apps_composer/issues and contribute a fix if you can.
|
202
|
-
|
203
|
-
h2. Examples
|
204
|
-
|
205
|
-
We use the rails_apps_composer gem to create the "Rails Example Apps":http://railsapps.github.com/ for the "RailsApps project":https://github.com/RailsApps. These example apps have been used by thousands of Rails developers. The recipes used for the RailsApps examples are well-integrated and known to work in the specific combinations listed below.
|
206
|
-
|
207
|
-
h4. Template for Rails 3 + Haml + HTML5
|
208
|
-
|
209
|
-
This application template will offer you a choice of Haml or ERB, give you options for a CSS front-end framework such as Twitter Bootstrap, and create a default application layout using HTML5:
|
181
|
+
Use a defaults file for recipes, preferences, and extra gems so you don't have to provide them interactively. Then generate an application with:
|
210
182
|
|
211
183
|
<pre>
|
212
|
-
$ rails_apps_composer
|
184
|
+
$ rails_apps_composer new myapp --defaults=my_defaults.yaml
|
213
185
|
</pre>
|
214
186
|
|
215
|
-
|
187
|
+
Use the @my_defaults.yaml@ file to specify a list of recipes, preferences, and extra gems. You can use any name (and file extension) for the file. See the "Defaults File":http://railsapps.github.com/tutorial-rails-apps-composer.html#Defaults section in the Guide to learn about the format of the defaults file.
|
216
188
|
|
217
|
-
|
218
|
-
$ rails new myapp -m ~/Desktop/template.txt
|
219
|
-
</pre>
|
189
|
+
h3. Generate an Application Template Interactively
|
220
190
|
|
221
|
-
|
191
|
+
You may want an application template to share with others. For an example of an application template, see the "Rails Composer":http://railsapps.github.com/rails-composer/ tool or various "application templates":https://github.com/RailsApps/rails3-application-templates from the RailsApps project.
|
222
192
|
|
223
|
-
|
193
|
+
Specify a filename for the template:
|
224
194
|
|
225
195
|
<pre>
|
226
|
-
$ rails_apps_composer template ~/Desktop/template.
|
196
|
+
$ rails_apps_composer template ~/Desktop/template.rb
|
197
|
+
|
198
|
+
Available Recipes:
|
199
|
+
apps: prelaunch
|
200
|
+
auth: auth
|
201
|
+
configuration: email, gems, readme, setup
|
202
|
+
example: example
|
203
|
+
frontend: frontend
|
204
|
+
initialize: database
|
205
|
+
mvc: controllers, models, routes, views
|
206
|
+
other: extras
|
207
|
+
testing: testing
|
208
|
+
|
209
|
+
Which recipe would you like to add? (blank to finish)
|
210
|
+
What gem would you like to add? (blank to finish)
|
211
|
+
Generating and saving application template...
|
212
|
+
Done.
|
227
213
|
</pre>
|
228
214
|
|
229
|
-
|
215
|
+
The command with the @template@ argument followed by a filename generates an application template. You can add additional recipes or gems when prompted.
|
230
216
|
|
231
|
-
|
232
|
-
$ rails new rails-prelaunch-signup -m ~/Desktop/template.txt -T
|
233
|
-
</pre>
|
217
|
+
h3. Generate an Application Template from a List of Recipes
|
234
218
|
|
235
|
-
|
236
|
-
|
237
|
-
To build an application template for the "rails3-devise-rspec-cucumber":http://github.com/RailsApps/rails3-devise-rspec-cucumber/ example application, run the command:
|
219
|
+
Specify a filename for the template and provide a list of recipes:
|
238
220
|
|
239
221
|
<pre>
|
240
|
-
$ rails_apps_composer template ~/Desktop/template.
|
241
|
-
</pre>
|
222
|
+
$ rails_apps_composer template ~/Desktop/template.rb -r setup readme gems testing auth email models controllers views routes frontend database extras
|
242
223
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
$ rails new rails3-devise-rspec-cucumber -m ~/Desktop/template.txt -T
|
224
|
+
What gem would you like to add? (blank to finish)
|
225
|
+
Generating and saving application template...
|
226
|
+
Done.
|
247
227
|
</pre>
|
248
228
|
|
249
|
-
|
250
|
-
|
251
|
-
To build an application template for the "rails3-mongoid-devise":http://github.com/RailsApps/rails3-mongoid-devise/ example application, run the command:
|
229
|
+
The command with the @template@ argument followed by a filename and a list of recipes generates an application template.
|
252
230
|
|
253
|
-
|
254
|
-
$ rails_apps_composer template ~/Desktop/template.txt -r haml rspec cucumber guard mongoid action_mailer devise add_user home_page home_page_users seed_database users_page html5 simple_form cleanup extras git
|
255
|
-
</pre>
|
231
|
+
h3. Generate an Application Template from Defaults
|
256
232
|
|
257
|
-
|
233
|
+
Generate an application template using a defaults file:
|
258
234
|
|
259
235
|
<pre>
|
260
|
-
$
|
236
|
+
$ rails_apps_composer template ~/Desktop/template.rb --defaults=my_defaults.yaml
|
261
237
|
</pre>
|
262
238
|
|
263
|
-
|
239
|
+
Use the @my_defaults.yaml@ file to specify a list of recipes, preferences, and extra gems. You can use any name (and file extension) for the file. See the "Defaults File":http://railsapps.github.com/tutorial-rails-apps-composer.html#Defaults section in the Guide to learn about the format of the defaults file.
|
264
240
|
|
265
|
-
|
241
|
+
h3. Generate an Application from a Template
|
266
242
|
|
267
|
-
|
268
|
-
$ rails_apps_composer template ~/Desktop/template.txt -r haml rspec cucumber guard mongoid seed_database omniauth home_page home_page_users html5 simple_form users_page omniauth_email cleanup extras git
|
269
|
-
</pre>
|
270
|
-
|
271
|
-
Then generate the application using the @-T -O@ flags.
|
243
|
+
After you've created a template file, you can generate an application from a template at any time using the @rails new@ command with the @-m@ option:
|
272
244
|
|
273
245
|
<pre>
|
274
|
-
$ rails new
|
246
|
+
$ rails new myapp -m ~/Desktop/template.rb
|
275
247
|
</pre>
|
276
248
|
|
277
|
-
|
249
|
+
The application template will prompt you for any configuration preferences requested by the recipes.
|
278
250
|
|
279
|
-
|
251
|
+
The @rails new@ command allows you to specify the @-T -O@ flags to skip Test::Unit files and Active Record files when you use an application template.
|
280
252
|
|
281
253
|
<pre>
|
282
|
-
$
|
254
|
+
$ rails new myapp -m ~/Desktop/template.rb -T -O
|
283
255
|
</pre>
|
284
256
|
|
285
|
-
|
257
|
+
The @rails new@ command with the @-m@ option also allows you to specify an application template that can be downloaded via HTTP. This makes it possible to host a template on GitHub (for example) and allow anyone to generate an application from the hosted template. For example:
|
286
258
|
|
287
259
|
<pre>
|
288
|
-
$ rails new
|
260
|
+
$ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
|
289
261
|
</pre>
|
290
262
|
|
291
|
-
h2.
|
292
|
-
|
293
|
-
Your patches and improvements are welcome. Fork the repository and clone the project locally.
|
263
|
+
h2. Diagnostics
|
294
264
|
|
295
|
-
|
265
|
+
The rails_apps_composer program runs diagnostics to reveal whether you've picked recipes and preferences that are known to work together.
|
296
266
|
|
297
|
-
|
298
|
-
$ gem install activesupport i18n thor mg
|
299
|
-
</pre>
|
300
|
-
|
301
|
-
Add or modify recipes as needed.
|
267
|
+
Hundreds of developers are using this gem to build starter apps. As you can see from the commit log, the gem is actively maintained and the collection of recipes is growing. There is a drawback to all this activity, however. No developer who uses the rails_apps_composer gem uses all the recipes. And it would be very difficult to test a recipe in every possible combination. Consequently, combining some recipes or preferences may not work.
|
302
268
|
|
303
|
-
|
269
|
+
The rails_apps_composer gem contains an internal database of combinations of recipes and preferences that are known to work together. If you've picked recipes and preferences that are known to work together, you'll get a confirmation:
|
304
270
|
|
305
271
|
<pre>
|
306
|
-
|
307
|
-
|
308
|
-
|
272
|
+
WOOT! The recipes you've selected are known to work together.
|
273
|
+
If they don't, open an issue for rails_apps_composer on GitHub.
|
274
|
+
WOOT! The preferences you've selected are known to work together.
|
275
|
+
If they don't, open an issue for rails_apps_composer on GitHub.
|
309
276
|
</pre>
|
310
277
|
|
311
|
-
|
312
|
-
|
313
|
-
h2. Writing New Recipes
|
314
|
-
|
315
|
-
You can find the rails_apps_composer recipe collection in the GitHub repository's "recipes directory":https://github.com/RailsApps/rails_apps_composer/tree/master/recipes. If you find errors or improve a recipe you can contribute to the project by submitting a pull request or creating a "Github issue":http://github.com/RailsApps/rails_apps_composer/issues.
|
316
|
-
|
317
|
-
h4. Warning: Gnarly Code Ahead!
|
318
|
-
|
319
|
-
The best (and only) way to create a new recipe (or customize an existing one) is to examine several recipes to learn how they work. The "extras":https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/extras.rb recipe is a good place to start. Some recipes, such as the "add_user":https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/add_user.rb recipe, are very complex with multiple preferences and dependencies on other recipes.
|
320
|
-
|
321
|
-
Frankly, the recipe code (and the resulting application template) can be ugly. The code is not much more than a long procedural script with conditional statements to resolve dependencies or enable preferences, interspersed with snippets of template code that is injected into files. The inline template code (for example, code that sets up a Rails "view" file) is particularly ugly because it has to be indented to conform to its destination file, often making the recipe difficult to read. Nevertheless, the project has value and many developers have contributed recipes and added features.
|
322
|
-
|
323
|
-
h4. Rails Wizard Basics
|
324
|
-
|
325
|
-
For more information on all available options for authoring recipes that can be read by the rails_wizard or rails_apps_composer gems, please see the "wiki for Michael Bleigh's RailsWizard gem":https://github.com/intridea/rails_wizard/wiki.
|
326
|
-
|
327
|
-
Recipes are made of up *template code* and *YAML back-matter* stored in a ruby file. The @__END__@ parsing convention is used so that each recipe is actually a valid, parseable Ruby file. The structure of a recipe looks something like this:
|
278
|
+
You'll get a warning if you've picked a combination we don't know about:
|
328
279
|
|
329
280
|
<pre>
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
end
|
335
|
-
|
336
|
-
__END__
|
337
|
-
|
338
|
-
category: templating
|
339
|
-
name: SuperGem
|
340
|
-
description: Installs SuperGem which is useful for things
|
341
|
-
author: mbleigh
|
281
|
+
WARNING! The recipes you've selected might not work together.
|
282
|
+
Help us out by reporting whether this combination works or fails.
|
283
|
+
WARNING! The preferences you've selected might not work together.
|
284
|
+
Help us out by reporting whether this combination works or fails.
|
342
285
|
</pre>
|
343
286
|
|
344
|
-
|
287
|
+
Go to the GitHub repository to create an "issue":http://github.com/RailsApps/rails_apps_composer/issues and let us know if you've found a combination of recipes or preferences that work together. If you've found a combination that works together, we'll update the gem's internal database for the next public release.
|
345
288
|
|
346
|
-
|
289
|
+
When you generate an application, the application's *README.textile* file will contain a diagnostics report. Here's an example of the diagnostics report:
|
347
290
|
|
348
291
|
<pre>
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
installs git before haml.
|
292
|
+
Recipes:
|
293
|
+
["gems", "readme", "setup"]
|
353
294
|
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
h4. How It Works
|
359
|
-
|
360
|
-
Rails generators can use any methods provided by the "Thor::Actions":http://rdoc.info/github/wycats/thor/master/Thor/Actions module. The flexibility of mixing "recipes" for application templates comes from use of the @apply@ method from the Thor::Actions module. Given a web address or a local filepath, the "apply method":http://rdoc.info/github/wycats/thor/master/Thor/Actions#apply-instance_method loads and executes a file within the context of the generator script.
|
295
|
+
Preferences:
|
296
|
+
{:database=>"sqlite", :templates=>"erb", :email=>"none"}
|
297
|
+
</pre>
|
361
298
|
|
362
|
-
|
299
|
+
Please include the diagnostics report when you create an issue on GitHub.
|
363
300
|
|
364
|
-
|
301
|
+
h2. Hacking the Gem
|
365
302
|
|
366
|
-
|
303
|
+
See the "Guide to the Rails Apps Composer Gem":http://railsapps.github.com/tutorial-rails-apps-composer.html to learn how to customize the gem either for your own use or to share with others.
|
367
304
|
|
368
|
-
|
305
|
+
h2. Issues
|
369
306
|
|
370
|
-
|
307
|
+
Any issues? Please create an "issue":http://github.com/RailsApps/rails_apps_composer/issues on GitHub. Reporting issues (and patching!) helps everyone.
|
371
308
|
|
372
|
-
|
373
|
-
"Rails Application Templates (16 Sept 2010) by Collin Schaafsma":http://quickleft.com/blog/rails-application-templates
|
374
|
-
"Application templates in Rails 3 (18 Sept 2009) by Ben Scofield":http://benscofield.com/2009/09/application-templates-in-rails-3/
|
375
|
-
"Railscasts: App Templates in Rails 2.3 (9 Feb 2009) by Ryan Bates":http://railscasts.com/episodes/148-app-templates-in-rails-2-3
|
376
|
-
"Rails templates (4 Dec 2008) by Pratik Naik":http://m.onkey.org/rails-templates
|
309
|
+
When you generate an application, the application's *README.textile* file will contain a diagnostics report. Please include the diagnostics report when you create an issue on GitHub.
|
377
310
|
|
378
311
|
h2. Credits
|
379
312
|
|
380
313
|
Daniel Kehoe maintains this gem as part of the "RailsApps Project":http://railsapps.github.com/.
|
381
314
|
|
382
|
-
This gem is
|
315
|
+
This gem is derived from "Michael Bleigh's RailsWizard gem":https://github.com/intridea/rails_wizard. The original idea and the innovative implementation is the work of Michael Bleigh.
|
383
316
|
|
384
317
|
Please see the "CHANGELOG":https://github.com/RailsApps/rails_apps_composer/blob/master/CHANGELOG.textile for a list of contributors.
|
385
318
|
|
386
|
-
|
319
|
+
Is the gem useful to you? Follow the project on Twitter: "@rails_apps":http://twitter.com/rails_apps. I'd love to know you were helped out by the gem.
|
387
320
|
|
388
|
-
|
389
|
-
"@rails_apps":http://twitter.com/rails_apps
|
390
|
-
and tweet some praise. I'd love to know you were helped out by the gem.
|
321
|
+
h2. MIT License (with restriction)
|
391
322
|
|
392
|
-
|
323
|
+
The rails_apps_composer program is licensed under the terms of the "MIT License":http://www.opensource.org/licenses/mit-license, except portions of the program authored by Daniel Kehoe may not be used to build a website that generates an application template that can be downloaded or used to generate a web application online (for such use, ask for permission).
|
393
324
|
|
394
|
-
|
325
|
+
Copyright © 2012 Daniel Kehoe
|
395
326
|
|
396
|
-
|
327
|
+
!https://cruel-carlota.pagodabox.com/1f4f51c551cd90489a558e5fe4d91fff(githalytics.com alpha)!
|