preseason 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/CONTRIBUTING.md +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +100 -0
- data/LICENSE.txt +23 -0
- data/README.md +129 -0
- data/Rakefile +1 -0
- data/bin/preseason +8 -0
- data/lib/Gemfile +4 -0
- data/lib/Rakefile +1 -0
- data/lib/play.rb +2 -0
- data/lib/preseason/colorize.rb +57 -0
- data/lib/preseason/config/authentication.rb +31 -0
- data/lib/preseason/config/database.rb +48 -0
- data/lib/preseason/config/factory.rb +19 -0
- data/lib/preseason/config/heroku.rb +17 -0
- data/lib/preseason/config/ie8.rb +17 -0
- data/lib/preseason/config.rb +6 -0
- data/lib/preseason/generator_context.rb +20 -0
- data/lib/preseason/recipe/active_admin.rb +7 -0
- data/lib/preseason/recipe/application.rb +6 -0
- data/lib/preseason/recipe/authlogic.rb +50 -0
- data/lib/preseason/recipe/bundle.rb +7 -0
- data/lib/preseason/recipe/custom_error_pages.rb +30 -0
- data/lib/preseason/recipe/database.rb +28 -0
- data/lib/preseason/recipe/devise.rb +9 -0
- data/lib/preseason/recipe/flash.rb +6 -0
- data/lib/preseason/recipe/foreman.rb +5 -0
- data/lib/preseason/recipe/gemfile.rb +147 -0
- data/lib/preseason/recipe/git.rb +62 -0
- data/lib/preseason/recipe/gitignore.rb +22 -0
- data/lib/preseason/recipe/guard.rb +7 -0
- data/lib/preseason/recipe/heroku.rb +12 -0
- data/lib/preseason/recipe/ie8.rb +18 -0
- data/lib/preseason/recipe/initializer.rb +20 -0
- data/lib/preseason/recipe/playbook.rb +69 -0
- data/lib/preseason/recipe/production.rb +36 -0
- data/lib/preseason/recipe/routes.rb +21 -0
- data/lib/preseason/recipe/rspec.rb +5 -0
- data/lib/preseason/recipe/rvm.rb +10 -0
- data/lib/preseason/recipe/schedule.rb +5 -0
- data/lib/preseason/recipe/spork_rspec.rb +7 -0
- data/lib/preseason/recipe/whiskey_disk.rb +5 -0
- data/lib/preseason/recipe.rb +38 -0
- data/lib/preseason/templates/authlogic/POST_INSTALL +10 -0
- data/lib/preseason/templates/authlogic/app/controllers/application_controller.rb +40 -0
- data/lib/preseason/templates/authlogic/app/controllers/user_session_controller.rb +58 -0
- data/lib/preseason/templates/authlogic/app/mailers/site_mailer.rb +5 -0
- data/lib/preseason/templates/authlogic/app/models/user.rb +11 -0
- data/lib/preseason/templates/authlogic/app/models/user_session.rb +2 -0
- data/lib/preseason/templates/authlogic/app/views/site_mailer/password_reset_instructions.html.erb +22 -0
- data/lib/preseason/templates/authlogic/app/views/user_session/acquire_password.html.erb +14 -0
- data/lib/preseason/templates/authlogic/app/views/user_session/forgot_password.html.erb +11 -0
- data/lib/preseason/templates/authlogic/app/views/user_session/new.html.erb +17 -0
- data/lib/preseason/templates/authlogic/config/routes.rb +11 -0
- data/lib/preseason/templates/authlogic/spec/factories/users.rb +11 -0
- data/lib/preseason/templates/custom_error_pages/app/views/errors/application_error.html.erb +5 -0
- data/lib/preseason/templates/custom_error_pages/app/views/errors/not_found.html.erb +5 -0
- data/lib/preseason/templates/custom_error_pages/app/views/errors/unprocessable_entity.html.erb +5 -0
- data/lib/preseason/templates/custom_error_pages/config/routes.rb +5 -0
- data/lib/preseason/templates/database/config/database.yml.dist.erb +19 -0
- data/lib/preseason/templates/database/config/database.yml.erb +19 -0
- data/lib/preseason/templates/flash/app/views/shared/_flash.html.erb +6 -0
- data/lib/preseason/templates/ie8/app/assets/javascripts/ie8.coffee +8 -0
- data/lib/preseason/templates/playbook/app/views/layouts/application.html.erb +31 -0
- data/lib/preseason/templates/readme/README.md.erb +17 -0
- data/lib/preseason/templates/schedule/config/schedule.rb +7 -0
- data/lib/preseason/templates/spec/spec_helper.erb +61 -0
- data/lib/preseason/templates/sqlite/config/database.yml +17 -0
- data/lib/preseason/templates/whiskey_disk/config/deploy.yml +7 -0
- data/lib/preseason/version.rb +3 -0
- data/lib/preseason.rb +82 -0
- data/preseason.gemspec +27 -0
- metadata +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d3f322e9dc43834fa74890214948632d6d82b671
|
4
|
+
data.tar.gz: 1a3f38dfe75b3f614929f1046622f9a58811b0cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7622582d00ee54d3b46b16292142cbb662e7c5f75033703e5ccd0919dda375fa1c4db8bc6edb22145ef171f0e13d18f62316acbae81272e2c892c952a56b2652
|
7
|
+
data.tar.gz: f3ba95012bf1a9f4afd4c479e4a943a0a1e2628c95c7c56ed47a847b4259845bfa2044d6cb121222e78fe49741c7dd23bf410e1da59c214032fc407c22480b12
|
data/.gitignore
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
## Contributing
|
2
|
+
1. fork the repo
|
3
|
+
2. exhibit your brilliance
|
4
|
+
3. push to your fork
|
5
|
+
4. submit a pull request
|
6
|
+
|
7
|
+
### Submitting Bug Reports
|
8
|
+
|
9
|
+
If you're nice enough to submit a bug and make Preseason better, please
|
10
|
+
provide the following information to make resolving the bug easier.
|
11
|
+
|
12
|
+
1. Your operating system (and version)
|
13
|
+
2. Your shell type and version (Bash, Zsh, Bourne, etc)
|
14
|
+
3. Clear steps to reproduce the bug. What answers did you select during
|
15
|
+
the prompts?
|
16
|
+
4. Any error messages seen in the console
|
17
|
+
5. A description of what you expected to happen
|
18
|
+
6. A description of what actually happened
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
preseason (0.0.1)
|
5
|
+
rails (~> 4.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (4.1.5)
|
11
|
+
actionpack (= 4.1.5)
|
12
|
+
actionview (= 4.1.5)
|
13
|
+
mail (~> 2.5.4)
|
14
|
+
actionpack (4.1.5)
|
15
|
+
actionview (= 4.1.5)
|
16
|
+
activesupport (= 4.1.5)
|
17
|
+
rack (~> 1.5.2)
|
18
|
+
rack-test (~> 0.6.2)
|
19
|
+
actionview (4.1.5)
|
20
|
+
activesupport (= 4.1.5)
|
21
|
+
builder (~> 3.1)
|
22
|
+
erubis (~> 2.7.0)
|
23
|
+
activemodel (4.1.5)
|
24
|
+
activesupport (= 4.1.5)
|
25
|
+
builder (~> 3.1)
|
26
|
+
activerecord (4.1.5)
|
27
|
+
activemodel (= 4.1.5)
|
28
|
+
activesupport (= 4.1.5)
|
29
|
+
arel (~> 5.0.0)
|
30
|
+
activesupport (4.1.5)
|
31
|
+
i18n (~> 0.6, >= 0.6.9)
|
32
|
+
json (~> 1.7, >= 1.7.7)
|
33
|
+
minitest (~> 5.1)
|
34
|
+
thread_safe (~> 0.1)
|
35
|
+
tzinfo (~> 1.1)
|
36
|
+
arel (5.0.1.20140414130214)
|
37
|
+
builder (3.2.2)
|
38
|
+
coderay (1.1.0)
|
39
|
+
erubis (2.7.0)
|
40
|
+
hike (1.2.3)
|
41
|
+
i18n (0.6.11)
|
42
|
+
json (1.8.1)
|
43
|
+
mail (2.5.4)
|
44
|
+
mime-types (~> 1.16)
|
45
|
+
treetop (~> 1.4.8)
|
46
|
+
method_source (0.8.2)
|
47
|
+
mime-types (1.25.1)
|
48
|
+
minitest (5.4.0)
|
49
|
+
multi_json (1.10.1)
|
50
|
+
polyglot (0.3.5)
|
51
|
+
pry (0.10.1)
|
52
|
+
coderay (~> 1.1.0)
|
53
|
+
method_source (~> 0.8.1)
|
54
|
+
slop (~> 3.4)
|
55
|
+
rack (1.5.2)
|
56
|
+
rack-test (0.6.2)
|
57
|
+
rack (>= 1.0)
|
58
|
+
rails (4.1.5)
|
59
|
+
actionmailer (= 4.1.5)
|
60
|
+
actionpack (= 4.1.5)
|
61
|
+
actionview (= 4.1.5)
|
62
|
+
activemodel (= 4.1.5)
|
63
|
+
activerecord (= 4.1.5)
|
64
|
+
activesupport (= 4.1.5)
|
65
|
+
bundler (>= 1.3.0, < 2.0)
|
66
|
+
railties (= 4.1.5)
|
67
|
+
sprockets-rails (~> 2.0)
|
68
|
+
railties (4.1.5)
|
69
|
+
actionpack (= 4.1.5)
|
70
|
+
activesupport (= 4.1.5)
|
71
|
+
rake (>= 0.8.7)
|
72
|
+
thor (>= 0.18.1, < 2.0)
|
73
|
+
rake (0.9.6)
|
74
|
+
slop (3.6.0)
|
75
|
+
sprockets (2.12.1)
|
76
|
+
hike (~> 1.2)
|
77
|
+
multi_json (~> 1.0)
|
78
|
+
rack (~> 1.0)
|
79
|
+
tilt (~> 1.1, != 1.3.0)
|
80
|
+
sprockets-rails (2.1.3)
|
81
|
+
actionpack (>= 3.0)
|
82
|
+
activesupport (>= 3.0)
|
83
|
+
sprockets (~> 2.8)
|
84
|
+
thor (0.19.1)
|
85
|
+
thread_safe (0.3.4)
|
86
|
+
tilt (1.4.1)
|
87
|
+
treetop (1.4.15)
|
88
|
+
polyglot
|
89
|
+
polyglot (>= 0.3.1)
|
90
|
+
tzinfo (1.2.2)
|
91
|
+
thread_safe (~> 0.1)
|
92
|
+
|
93
|
+
PLATFORMS
|
94
|
+
ruby
|
95
|
+
|
96
|
+
DEPENDENCIES
|
97
|
+
bundler (~> 1.3)
|
98
|
+
preseason!
|
99
|
+
pry (~> 0)
|
100
|
+
rake (~> 0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2014 Centresource Interactive Agency
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
data/README.md
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# Preseason
|
2
|
+
A Centresource Interactive Agency open internal project for generating new Rails applications.
|
3
|
+
|
4
|
+
### Why
|
5
|
+
We start new Ruby on Rails projects frequently. In doing so, we end up
|
6
|
+
repeating many of the same steps. As Rubyists, we are always looking for
|
7
|
+
ways to DRY things up. This project is intended to serve as a launching
|
8
|
+
pad for new Rails applications. Perhaps most importantly, it is **NOT** supposed to cover everything that every Rails app will ever need, but to be a good starting place.
|
9
|
+
|
10
|
+
### How
|
11
|
+
N.B. This project assumes you have a development environment setup that is capable of installing Rails projects. If not, start with the [Rails Guides](http://guides.rubyonrails.org/getting_started.html "Rails Guides"). You must also have the rvm gem installed. It also assumes that you are using SSH if you plan to make your project a Github repo.
|
12
|
+
|
13
|
+
0. Install the `rvm` gem if you don't already have it installed
|
14
|
+
|
15
|
+
`gem install rvm`
|
16
|
+
|
17
|
+
1. Install the preseason gem into your global gemset:
|
18
|
+
|
19
|
+
`gem install preseason`
|
20
|
+
|
21
|
+
2. Make sure your db is running (postgres/mysql/etc)
|
22
|
+
|
23
|
+
3. Install a new Rails application with:
|
24
|
+
|
25
|
+
`preseason <name_of_your_project>`
|
26
|
+
|
27
|
+
3. Follow the prompts to choose your database, etc.
|
28
|
+
|
29
|
+
4. Make a mistake? Just `rm -rf` your application's directory and repeat steps 1-4.
|
30
|
+
|
31
|
+
5. `cd` into your application directory
|
32
|
+
|
33
|
+
6. Make magic happen and dreams come true.
|
34
|
+
|
35
|
+
####Note About ERB Templates
|
36
|
+
If you need to write a template that executes ERB in the context of the running script and also outputs ERB for the purposes of the generated application code, be sure to escape your application-bound ERB as `<%%>`
|
37
|
+
|
38
|
+
### What
|
39
|
+
#### Preseason does the following:
|
40
|
+
|
41
|
+
+ asks for your db of preference
|
42
|
+
+ asks for your preferences on a few gems
|
43
|
+
+ creates an RVM gemset for your project and switches to that gemset
|
44
|
+
+ creates a new config/database.yml file with info from your db of choice
|
45
|
+
+ adds the database.yml to .gitignore and creates a database.yml.dist as a placeholder
|
46
|
+
+ adds .ruby-version, .ruby-gemset, swp files, public/assets, s3 files, etc to .gitignore
|
47
|
+
+ cleans up the Gemfile (removes comments and empty lines)
|
48
|
+
+ enables lograge for production (for non-Heroku apps)
|
49
|
+
+ installs gems via bundler
|
50
|
+
+ creates a database
|
51
|
+
+ cleans up routes.rb
|
52
|
+
+ sets up flash messages in the application layout
|
53
|
+
+ sets config.assets.initialize_on_precompile to false
|
54
|
+
+ sets config.autoload_paths += %W(\#{config.root}/lib)
|
55
|
+
+ sets up a template for using whenever for cronjobs (for non-Heroku apps)
|
56
|
+
+ installs rspec
|
57
|
+
+ installs and sets up bourbon and neat
|
58
|
+
+ creates a template for your whiskey_disk deploy in config/deploy.yml (for non-Heroku apps)
|
59
|
+
+ creates Procfile for foreman
|
60
|
+
+ starts guard
|
61
|
+
+ creates a new spec_helper with spork and simplecov
|
62
|
+
+ removes the test unit directory, the smoke test page, and the Rails logo.
|
63
|
+
+ migrates the db and recreates the test db from the DEV's schema
|
64
|
+
+ initializes a git repository, makes an "initial commit", and checks out a 'develop' branch
|
65
|
+
+ setup Heroku
|
66
|
+
|
67
|
+
#### Preseason offers use of the following technologies:
|
68
|
+
|
69
|
+
+ Either postgresql, mysql2, or sqlite3
|
70
|
+
+ [factory_girl](https://github.com/thoughtbot/factory_girl)
|
71
|
+
+ [authlogic](https://github.com/binarylogic/authlogic), [devise](https://github.com/plataformatec/devise), or [activeadmin](http://www.activeadmin.info/) (with devise)
|
72
|
+
+ [rvm](https://rvm.io/)
|
73
|
+
+ [whiskey_disk](https://github.com/flogic/whiskey_disk) (for embarrassingly fast deployments)
|
74
|
+
+ [lograge](https://github.com/roidrage/lograge)
|
75
|
+
+ [whenever](https://github.com/javan/whenever)
|
76
|
+
+ [foreman](https://github.com/ddollar/foreman)
|
77
|
+
+ [guard](https://github.com/guard/guard)
|
78
|
+
+ [spork](https://github.com/sporkrb/spork)
|
79
|
+
+ [pry](http://pryrepl.org/)
|
80
|
+
+ [awesome_print](https://github.com/michaeldv/awesome_print)
|
81
|
+
+ [quiet_assets](https://github.com/evrone/quiet_assets)
|
82
|
+
+ [rspec](http://rspec.info/)
|
83
|
+
+ [database_cleaner](https://github.com/bmabey/database_cleaner)
|
84
|
+
+ [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers)
|
85
|
+
+ [capybara-webkit](https://github.com/thoughtbot/capybara-webkit)
|
86
|
+
+ [launchy](https://github.com/copiousfreetime/launchy)
|
87
|
+
+ [fuubar](https://github.com/jeffkreeftmeijer/fuubar)
|
88
|
+
+ [simplecov](https://github.com/colszowka/simplecov)
|
89
|
+
+ [bourbon](http://bourbon.io/)
|
90
|
+
+ [neat](http://neat.bourbon.io/)
|
91
|
+
+ [bitters](http://bitters.bourbon.io)
|
92
|
+
|
93
|
+
### Who
|
94
|
+
|
95
|
+
Preseason is a project by the development team at the [Centresource Interactive Agency](http://www.centresource.com) in Nashville, TN. The main push for this project is from [Cade Truitt](https://github.com/cade), [Travis Roberts](https://github.com/travisr), [Jeremy Holland](https://github.com/awebneck), [Adam Scott](https://github.com/ascot21), [Rian Rainey](https://github.com/rianrainey), and [Max Beizer](https://github.com/maxbeizer)
|
96
|
+
|
97
|
+
### ToDos
|
98
|
+
* integration spec setup?
|
99
|
+
* add active admin precompile asset list to production.rb
|
100
|
+
* add logic to setup activeadmin for authlogic and allow choice between
|
101
|
+
devise and authlogic rather than y/n for authlogic
|
102
|
+
|
103
|
+
### Developing Locally
|
104
|
+
1. Fork the repo
|
105
|
+
2. Clone it to your local machine
|
106
|
+
3. `gem uninstall preseason` if you have it installed already
|
107
|
+
- you may be prompted about removing an executable called preseason. The answer is yes
|
108
|
+
4. Crack the project open and make magic happen
|
109
|
+
5. `gem build preseason.gemspec`
|
110
|
+
- should you receive an error message about the gem containing itself, try `rm preseason-0.0.1.gem` (or whatever version number we are on and stage that deletion
|
111
|
+
6. `gem install preseason` in your global gemset
|
112
|
+
7. In a separate terminal (or just outside the preseason dir), `presason <the name of your test project>`
|
113
|
+
8. Information on tests coming soon.
|
114
|
+
|
115
|
+
## Troubleshooting
|
116
|
+
* If you don't have QT libraries installed, you may get this error when installing Capybara
|
117
|
+
* `Command 'qmake -spec macx-g++' not available`
|
118
|
+
* Just run `brew install qt`. [Learn more](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit)
|
119
|
+
* If you get the following error when building the gem, you need to stage the deletion of
|
120
|
+
`preseason.gem` file by `git stage -u preseason.x.x.x.gem`
|
121
|
+
```
|
122
|
+
└[$] gem build preseason.gemspec
|
123
|
+
WARNING: See http://guides.rubygems.org/specification-reference/ for help
|
124
|
+
ERROR: While executing gem ... (Gem::InvalidSpecificationException)
|
125
|
+
from bin/rails:4:in `<main>'
|
126
|
+
```
|
127
|
+
|
128
|
+
## License
|
129
|
+
Preseason is Copyright © 2014 Centresource. It is free software, and may be redistributed under the terms specified in the [LICENSE](https://github.com/centresource/preseason/blob/master/LICENSE) file.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/preseason
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
require 'rails/generators/rails/app/app_generator'
|
5
|
+
|
6
|
+
#TODO remove any args except the project name
|
7
|
+
argv = ARGV + ['-m'] + ["#{File.dirname(__FILE__)}/../lib/play.rb"]
|
8
|
+
Rails::Generators::AppGenerator.start argv
|
data/lib/Gemfile
ADDED
data/lib/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/play.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
class Preseason
|
2
|
+
module Colorize
|
3
|
+
include Preseason::GeneratorContext
|
4
|
+
|
5
|
+
# override method from Thor::Shell::Basic
|
6
|
+
def ask(statement, *args)
|
7
|
+
statement = colorize(statement)
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
# override method from Thor::Shell::Basic
|
12
|
+
def yes?(statement, color = nil)
|
13
|
+
statement = colorize(statement)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
# override method from Rails::Generators::Actions
|
18
|
+
def readme(path)
|
19
|
+
begin
|
20
|
+
say "#{option_color}"
|
21
|
+
super
|
22
|
+
ensure
|
23
|
+
say "#{no_color}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def colorize(statement)
|
29
|
+
statement.insert 0, ask_color
|
30
|
+
statement.insert option_index(statement), option_color if option_index(statement)
|
31
|
+
statement.insert aside_index(statement) || -1, no_color
|
32
|
+
|
33
|
+
statement
|
34
|
+
end
|
35
|
+
|
36
|
+
def option_index(statement)
|
37
|
+
index = statement.rindex '['
|
38
|
+
index if index && index > ask_color.size
|
39
|
+
end
|
40
|
+
|
41
|
+
def aside_index(statement)
|
42
|
+
statement.rindex '('
|
43
|
+
end
|
44
|
+
|
45
|
+
def ask_color
|
46
|
+
"\033[35m" # magenta
|
47
|
+
end
|
48
|
+
|
49
|
+
def option_color
|
50
|
+
"\033[33m" # yellow
|
51
|
+
end
|
52
|
+
|
53
|
+
def no_color
|
54
|
+
"\033[0m" # reset
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Preseason
|
2
|
+
module Config
|
3
|
+
class Authentication
|
4
|
+
include Config
|
5
|
+
|
6
|
+
attr_accessor :library
|
7
|
+
|
8
|
+
def ask_user
|
9
|
+
if yes? "Will you be using Authlogic? [y/n]"
|
10
|
+
self.library = :authlogic
|
11
|
+
elsif yes? "Will you be using ActiveAdmin? [y/n]"
|
12
|
+
self.library = :active_admin
|
13
|
+
elsif yes? "Ok then, how about Devise? [y/n]"
|
14
|
+
self.library = :devise
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def authlogic?
|
19
|
+
library == :authlogic
|
20
|
+
end
|
21
|
+
|
22
|
+
def active_admin?
|
23
|
+
library == :active_admin
|
24
|
+
end
|
25
|
+
|
26
|
+
def devise?
|
27
|
+
library == :devise || active_admin?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Preseason
|
2
|
+
module Config
|
3
|
+
class Database
|
4
|
+
include Config
|
5
|
+
|
6
|
+
attr_accessor :database, :password
|
7
|
+
attr_reader :username
|
8
|
+
|
9
|
+
def ask_user
|
10
|
+
self.database ||= ask "What db will you be using?", :limited_to => gems.keys
|
11
|
+
|
12
|
+
unless database == 'sqlite'
|
13
|
+
self.username = ask "What is your #{database} database username? (leave blank for `whoami`)"
|
14
|
+
self.password = ask "What is your #{database} database password? (leave blank for none)"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def username=(other)
|
19
|
+
@username = other.blank? ? (`whoami`).chomp : other
|
20
|
+
end
|
21
|
+
|
22
|
+
def postgres?
|
23
|
+
database == 'postgres'
|
24
|
+
end
|
25
|
+
|
26
|
+
def sqlite?
|
27
|
+
database == 'sqlite'
|
28
|
+
end
|
29
|
+
|
30
|
+
def adapter_name
|
31
|
+
adapters[database]
|
32
|
+
end
|
33
|
+
|
34
|
+
def gem_name
|
35
|
+
gems[database]
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def adapters
|
40
|
+
{ 'postgres' => 'postgresql', 'mysql' => 'mysql2', 'sqlite' => 'sqlite3' }
|
41
|
+
end
|
42
|
+
|
43
|
+
def gems
|
44
|
+
{ 'postgres' => 'pg', 'mysql' => 'mysql2', 'sqlite' => 'sqlite3' }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Preseason
|
2
|
+
module Config
|
3
|
+
class Factory
|
4
|
+
include Config
|
5
|
+
|
6
|
+
attr_accessor :library
|
7
|
+
|
8
|
+
def ask_user
|
9
|
+
if yes? "Will you be using Factory Girl? [y/n]"
|
10
|
+
self.library = :factory_girl
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def factory_girl?
|
15
|
+
library == :factory_girl
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Preseason
|
2
|
+
module Config
|
3
|
+
class IE8
|
4
|
+
include Config
|
5
|
+
|
6
|
+
attr_accessor :enabled
|
7
|
+
|
8
|
+
def ask_user
|
9
|
+
self.enabled = yes? "Will this app need to support Internet Explorer 8 (install selectivizr.js and respond.js)? [y/n]"
|
10
|
+
end
|
11
|
+
|
12
|
+
def enabled?
|
13
|
+
enabled
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Preseason
|
2
|
+
module GeneratorContext
|
3
|
+
class << self
|
4
|
+
attr_reader :context
|
5
|
+
|
6
|
+
def context=(context)
|
7
|
+
# squashes `rails new` and `bundle exec spring binstub --all` attempts
|
8
|
+
# to run since we run it ourselves and the timing of `rails new` obscures
|
9
|
+
# our custom post_install messages
|
10
|
+
context.define_singleton_method(:run_bundle, -> {})
|
11
|
+
context.define_singleton_method(:generate_spring_binstubs, -> {})
|
12
|
+
@context = context
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def method_missing(meth, *args, &blk)
|
17
|
+
GeneratorContext.context.send meth, *args, &blk
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class Preseason::Recipe::Application < Preseason::Recipe
|
2
|
+
def prepare
|
3
|
+
insert_into_file 'config/application.rb', "\n config.assets.initialize_on_precompile = false\n", :before => /^ end$/
|
4
|
+
insert_into_file 'config/application.rb', " config.autoload_paths += %W(\#{config.root}/lib)", :after => /config.autoload_paths.*\n/
|
5
|
+
end
|
6
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Preseason::Recipe::Authlogic < Preseason::Recipe
|
2
|
+
def prepare
|
3
|
+
return unless config.authentication.authlogic?
|
4
|
+
|
5
|
+
setup_model
|
6
|
+
setup_factory
|
7
|
+
setup_routes
|
8
|
+
setup_controllers
|
9
|
+
setup_views
|
10
|
+
setup_mailer
|
11
|
+
end
|
12
|
+
|
13
|
+
def post_install_hook
|
14
|
+
'POST_INSTALL' if config.authentication.authlogic?
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def setup_model
|
19
|
+
# if you edit this, mirror your changes in the user_factory
|
20
|
+
generate 'model user first_name:string last_name:string email:string crypted_password:string password_salt:string persistence_token:string perishable_token:string'
|
21
|
+
|
22
|
+
insert 'app/models/user.rb', :before => /^end$/
|
23
|
+
mirror_file 'app/models/user_session.rb'
|
24
|
+
end
|
25
|
+
|
26
|
+
def setup_factory
|
27
|
+
mirror_file 'spec/factories/users.rb'
|
28
|
+
end
|
29
|
+
|
30
|
+
def setup_routes
|
31
|
+
insert 'config/routes.rb', :before => /^end$/
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup_controllers
|
35
|
+
mirror_file 'app/controllers/user_session_controller.rb'
|
36
|
+
insert 'app/controllers/application_controller.rb', :after => 'protect_from_forgery'
|
37
|
+
end
|
38
|
+
|
39
|
+
def setup_views
|
40
|
+
%w(new forgot_password acquire_password).each do |file_name|
|
41
|
+
mirror_file "app/views/user_session/#{file_name}.html.erb"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def setup_mailer
|
46
|
+
generate 'mailer SiteMailer'
|
47
|
+
insert 'app/mailers/site_mailer.rb', :before => /^end$/
|
48
|
+
mirror_file 'app/views/site_mailer/password_reset_instructions.html.erb'
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Preseason::Recipe::CustomErrorPages < Preseason::Recipe
|
2
|
+
def prepare
|
3
|
+
handle_errors_in_app
|
4
|
+
create_errors_controller
|
5
|
+
create_views
|
6
|
+
remove_default_error_pages
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
def handle_errors_in_app
|
11
|
+
insert_into_file 'config/application.rb', "\n\n config.exceptions_app = self.routes", :after => /config.active_record.whitelist_attributes = true$/
|
12
|
+
insert 'config/routes.rb', :before => /^end$/
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_errors_controller
|
16
|
+
generate 'controller errors --no-helper --no-assets'
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_views
|
20
|
+
mirror_file 'app/views/errors/application_error.html.erb'
|
21
|
+
mirror_file 'app/views/errors/not_found.html.erb'
|
22
|
+
mirror_file 'app/views/errors/unprocessable_entity.html.erb'
|
23
|
+
end
|
24
|
+
|
25
|
+
def remove_default_error_pages
|
26
|
+
remove_file 'public/404.html'
|
27
|
+
remove_file 'public/422.html'
|
28
|
+
remove_file 'public/500.html'
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Preseason::Recipe::Database < Preseason::Recipe
|
2
|
+
def recipe_root
|
3
|
+
# this is only used in the sqlite context
|
4
|
+
"#{template_path}/sqlite"
|
5
|
+
end
|
6
|
+
|
7
|
+
def prepare
|
8
|
+
config.database.sqlite? ? prepare_sqlite : prepare_default
|
9
|
+
append_to_file '.gitignore', "\n#{db_yml}"
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def prepare_default
|
14
|
+
remove_file db_yml
|
15
|
+
create_file "#{db_yml}.dist", parse_template("database/#{db_yml}.dist.erb")
|
16
|
+
create_file db_yml, parse_template("database/#{db_yml}.erb")
|
17
|
+
end
|
18
|
+
|
19
|
+
def prepare_sqlite
|
20
|
+
mirror_file db_yml
|
21
|
+
copy_file "#{recipe_root}/#{db_yml}", "#{db_yml}.dist"
|
22
|
+
append_to_file '.gitignore', db_yml
|
23
|
+
end
|
24
|
+
|
25
|
+
def db_yml
|
26
|
+
'config/database.yml'
|
27
|
+
end
|
28
|
+
end
|