phoenixbricks 3.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +674 -0
- data/README.md +85 -0
- data/bin/rbricks +5 -0
- data/lib/railsbricks.rb +115 -0
- data/lib/railsbricks/app_generator.rb +352 -0
- data/lib/railsbricks/assets/config/admin_post_routes.rbr +3 -0
- data/lib/railsbricks/assets/config/application.yml +9 -0
- data/lib/railsbricks/assets/config/contact_routes.rbr +2 -0
- data/lib/railsbricks/assets/config/initializers/devise_email/devise.rb +267 -0
- data/lib/railsbricks/assets/config/initializers/devise_username/devise.rb +267 -0
- data/lib/railsbricks/assets/config/post_routes.rbr +2 -0
- data/lib/railsbricks/assets/config/routes.rb +15 -0
- data/lib/railsbricks/assets/config/unicorn.rb +22 -0
- data/lib/railsbricks/assets/controllers/admin/base_controller.rb +10 -0
- data/lib/railsbricks/assets/controllers/admin/devise_email/users_controller.rb +66 -0
- data/lib/railsbricks/assets/controllers/admin/devise_username/users_controller.rb +69 -0
- data/lib/railsbricks/assets/controllers/admin/posts_controller.rb +73 -0
- data/lib/railsbricks/assets/controllers/brick_contact.rbr +23 -0
- data/lib/railsbricks/assets/controllers/devise_email/application_controller.rb +54 -0
- data/lib/railsbricks/assets/controllers/devise_username/application_controller.rb +56 -0
- data/lib/railsbricks/assets/controllers/pages_controller.rb +13 -0
- data/lib/railsbricks/assets/controllers/posts_controller.rbr +10 -0
- data/lib/railsbricks/assets/database/postgresql.yml +12 -0
- data/lib/railsbricks/assets/database/sqlite3.yml +8 -0
- data/lib/railsbricks/assets/gemfile/Gemfile +44 -0
- data/lib/railsbricks/assets/git/gitignore +30 -0
- data/lib/railsbricks/assets/javascripts/analytics.js.coffee +5 -0
- data/lib/railsbricks/assets/lib/markdown_writer.rb +19 -0
- data/lib/railsbricks/assets/mailers/contact_mailer.rb +13 -0
- data/lib/railsbricks/assets/migrations/20141010133702_create_posts.rb +17 -0
- data/lib/railsbricks/assets/migrations/devise_email/20141010133701_devise_create_users.rb +48 -0
- data/lib/railsbricks/assets/migrations/devise_username/20141010133701_devise_create_users.rb +54 -0
- data/lib/railsbricks/assets/models/devise_email/user.rb +41 -0
- data/lib/railsbricks/assets/models/devise_username/user.rb +57 -0
- data/lib/railsbricks/assets/models/post.rb +30 -0
- data/lib/railsbricks/assets/procfile/Procfile +1 -0
- data/lib/railsbricks/assets/seeds/devise_email/seeds_no_test_users.rb +11 -0
- data/lib/railsbricks/assets/seeds/devise_email/seeds_test_users.rb +24 -0
- data/lib/railsbricks/assets/seeds/devise_username/seeds_no_test_users.rb +12 -0
- data/lib/railsbricks/assets/seeds/devise_username/seeds_test_users.rb +26 -0
- data/lib/railsbricks/assets/stylesheets/application.scss +6 -0
- data/lib/railsbricks/assets/stylesheets/railsbricks_custom.scss +562 -0
- data/lib/railsbricks/assets/views/admin/base/admin_posts_link.rbr +1 -0
- data/lib/railsbricks/assets/views/admin/base/devise_email/index.html.erb +41 -0
- data/lib/railsbricks/assets/views/admin/base/devise_username/index.html.erb +41 -0
- data/lib/railsbricks/assets/views/admin/posts/_form.html.erb +54 -0
- data/lib/railsbricks/assets/views/admin/posts/dashboard.html.erb +9 -0
- data/lib/railsbricks/assets/views/admin/posts/drafts.html.erb +23 -0
- data/lib/railsbricks/assets/views/admin/posts/edit.html.erb +10 -0
- data/lib/railsbricks/assets/views/admin/posts/index.html.erb +23 -0
- data/lib/railsbricks/assets/views/admin/posts/new.html.erb +6 -0
- data/lib/railsbricks/assets/views/admin/users/devise_email/edit.html.erb +65 -0
- data/lib/railsbricks/assets/views/admin/users/devise_email/index.html.erb +54 -0
- data/lib/railsbricks/assets/views/admin/users/devise_username/edit.html.erb +74 -0
- data/lib/railsbricks/assets/views/admin/users/devise_username/index.html.erb +56 -0
- data/lib/railsbricks/assets/views/contact_mailer/contact_message.html.erb +5 -0
- data/lib/railsbricks/assets/views/devise/allow_signup_links.rbr +11 -0
- data/lib/railsbricks/assets/views/devise/devise_email/confirmations/new.html.erb +31 -0
- data/lib/railsbricks/assets/views/devise/devise_email/mailer/confirmation_instructions.html.erb +12 -0
- data/lib/railsbricks/assets/views/devise/devise_email/mailer/reset_password_instructions.html.erb +15 -0
- data/lib/railsbricks/assets/views/devise/devise_email/passwords/edit.html.erb +43 -0
- data/lib/railsbricks/assets/views/devise/devise_email/passwords/new.html.erb +31 -0
- data/lib/railsbricks/assets/views/devise/devise_email/registrations/edit.html.erb +63 -0
- data/lib/railsbricks/assets/views/devise/devise_email/registrations/new.html.erb +49 -0
- data/lib/railsbricks/assets/views/devise/devise_email/sessions/new.html.erb +49 -0
- data/lib/railsbricks/assets/views/devise/devise_email/shared/_links.erb +19 -0
- data/lib/railsbricks/assets/views/devise/devise_username/confirmations/new.html.erb +31 -0
- data/lib/railsbricks/assets/views/devise/devise_username/mailer/confirmation_instructions.html.erb +12 -0
- data/lib/railsbricks/assets/views/devise/devise_username/mailer/reset_password_instructions.html.erb +15 -0
- data/lib/railsbricks/assets/views/devise/devise_username/passwords/edit.html.erb +43 -0
- data/lib/railsbricks/assets/views/devise/devise_username/passwords/new.html.erb +31 -0
- data/lib/railsbricks/assets/views/devise/devise_username/registrations/edit.html.erb +63 -0
- data/lib/railsbricks/assets/views/devise/devise_username/registrations/new.html.erb +58 -0
- data/lib/railsbricks/assets/views/devise/devise_username/sessions/new.html.erb +49 -0
- data/lib/railsbricks/assets/views/devise/devise_username/shared/_links.erb +19 -0
- data/lib/railsbricks/assets/views/layouts/_navigation_links.html.erb +15 -0
- data/lib/railsbricks/assets/views/layouts/brick_analytics.rbr +11 -0
- data/lib/railsbricks/assets/views/pages/contact.html.erb +46 -0
- data/lib/railsbricks/assets/views/pages/inside.html.erb +4 -0
- data/lib/railsbricks/assets/views/pages/posts.html.erb +18 -0
- data/lib/railsbricks/assets/views/pages/show_post.html.erb +6 -0
- data/lib/railsbricks/auth_builder.rb +147 -0
- data/lib/railsbricks/config_helpers.rb +27 -0
- data/lib/railsbricks/config_values.rb +14 -0
- data/lib/railsbricks/errors.rb +18 -0
- data/lib/railsbricks/file_helpers.rb +54 -0
- data/lib/railsbricks/foundation/README.md +24 -0
- data/lib/railsbricks/foundation/Rakefile +6 -0
- data/lib/railsbricks/foundation/app/assets/images/.keep +0 -0
- data/lib/railsbricks/foundation/app/assets/images/apple-touch-icon-precomposed.png +0 -0
- data/lib/railsbricks/foundation/app/assets/images/apple-touch-icon.png +0 -0
- data/lib/railsbricks/foundation/app/assets/images/favicon.ico +0 -0
- data/lib/railsbricks/foundation/app/assets/javascripts/application.js +17 -0
- data/lib/railsbricks/foundation/app/assets/javascripts/common.js +7 -0
- data/lib/railsbricks/foundation/app/controllers/application_controller.rb +5 -0
- data/lib/railsbricks/foundation/app/controllers/concerns/.keep +0 -0
- data/lib/railsbricks/foundation/app/controllers/pages_controller.rb +7 -0
- data/lib/railsbricks/foundation/app/helpers/application_helper.rb +7 -0
- data/lib/railsbricks/foundation/app/helpers/email_helper.rb +5 -0
- data/lib/railsbricks/foundation/app/mailers/.keep +0 -0
- data/lib/railsbricks/foundation/app/models/.keep +0 -0
- data/lib/railsbricks/foundation/app/models/concerns/.keep +0 -0
- data/lib/railsbricks/foundation/app/views/layouts/_footer.html.erb +18 -0
- data/lib/railsbricks/foundation/app/views/layouts/_messages.html.erb +9 -0
- data/lib/railsbricks/foundation/app/views/layouts/_navigation.html.erb +18 -0
- data/lib/railsbricks/foundation/app/views/layouts/_navigation_links.html.erb +3 -0
- data/lib/railsbricks/foundation/app/views/layouts/application.html.erb +38 -0
- data/lib/railsbricks/foundation/app/views/pages/home.html.erb +2 -0
- data/lib/railsbricks/foundation/bin/bundle +3 -0
- data/lib/railsbricks/foundation/bin/rails +4 -0
- data/lib/railsbricks/foundation/bin/rake +4 -0
- data/lib/railsbricks/foundation/config.ru +4 -0
- data/lib/railsbricks/foundation/config/application.rb +34 -0
- data/lib/railsbricks/foundation/config/boot.rb +4 -0
- data/lib/railsbricks/foundation/config/environment.rb +5 -0
- data/lib/railsbricks/foundation/config/environments/development.rb +41 -0
- data/lib/railsbricks/foundation/config/environments/production.rb +95 -0
- data/lib/railsbricks/foundation/config/environments/test.rb +51 -0
- data/lib/railsbricks/foundation/config/initializers/backtrace_silencers.rb +7 -0
- data/lib/railsbricks/foundation/config/initializers/date_format.rb +27 -0
- data/lib/railsbricks/foundation/config/initializers/filter_parameter_logging.rb +4 -0
- data/lib/railsbricks/foundation/config/initializers/friendly_id.rb +88 -0
- data/lib/railsbricks/foundation/config/initializers/inflections.rb +16 -0
- data/lib/railsbricks/foundation/config/initializers/kaminari_config.rb +10 -0
- data/lib/railsbricks/foundation/config/initializers/mime_types.rb +5 -0
- data/lib/railsbricks/foundation/config/initializers/secret_token.rb +25 -0
- data/lib/railsbricks/foundation/config/initializers/session_store.rb +3 -0
- data/lib/railsbricks/foundation/config/initializers/wrap_parameters.rb +14 -0
- data/lib/railsbricks/foundation/config/locales/en.yml +23 -0
- data/lib/railsbricks/foundation/config/routes.rb +7 -0
- data/lib/railsbricks/foundation/db/migrate/20131103142222_create_friendly_id_slugs.rb +15 -0
- data/lib/railsbricks/foundation/db/schema.rb +29 -0
- data/lib/railsbricks/foundation/db/seeds.rb +0 -0
- data/lib/railsbricks/foundation/lib/assets/.keep +0 -0
- data/lib/railsbricks/foundation/lib/tasks/.keep +0 -0
- data/lib/railsbricks/foundation/public/404.html +58 -0
- data/lib/railsbricks/foundation/public/422.html +58 -0
- data/lib/railsbricks/foundation/public/500.html +57 -0
- data/lib/railsbricks/foundation/public/favicon.ico +0 -0
- data/lib/railsbricks/foundation/public/robots.txt +5 -0
- data/lib/railsbricks/foundation/vendor/assets/javascripts/.keep +0 -0
- data/lib/railsbricks/foundation/vendor/assets/stylesheets/.keep +0 -0
- data/lib/railsbricks/gemfile_builder.rb +118 -0
- data/lib/railsbricks/menu.rb +533 -0
- data/lib/railsbricks/post_builder.rb +103 -0
- data/lib/railsbricks/string_helpers.rb +39 -0
- data/lib/railsbricks/style_builder.rb +97 -0
- data/lib/railsbricks/ui_helpers.rb +11 -0
- data/lib/railsbricks/validator.rb +68 -0
- data/lib/railsbricks/version.rb +34 -0
- data/railsbricks.gemspec +16 -0
- metadata +198 -0
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# RailsBricks
|
2
|
+
|
3
|
+
_Create **Rails** apps. **Faster**._
|
4
|
+
|
5
|
+
---
|
6
|
+
- Title: RailsBricks
|
7
|
+
- Version: 3.2.6
|
8
|
+
- Author: Nico Schuele (www.nicoschuele.com)
|
9
|
+
- Contact: [contact page](http://railsbricks.net/contact)
|
10
|
+
- Homepage: http://www.railsbricks.net
|
11
|
+
- Github: https://github.com/nicoschuele/railsbricks
|
12
|
+
- Twitter: @railsbricks
|
13
|
+
|
14
|
+
---
|
15
|
+
|
16
|
+
## Features
|
17
|
+
|
18
|
+
* replaces the `rails new` command with `rbricks -n`
|
19
|
+
* includes useful gems and sets them up for you
|
20
|
+
* offers different UI choices for your web app
|
21
|
+
* creates and configures a Devise authentication scheme
|
22
|
+
* adds the necessary resources for a blog, contact form, and more
|
23
|
+
* builds an admin zone
|
24
|
+
* configures your mailers
|
25
|
+
* inits local and remote git repositories
|
26
|
+
* ...and much more to boost your productivity!
|
27
|
+
|
28
|
+
## Prerequisites
|
29
|
+
|
30
|
+
In order to use RailsBricks, you need the following:
|
31
|
+
|
32
|
+
* A nix-based OS. That can be any flavour of Linux or OS X
|
33
|
+
* Ruby (version 2.0+)
|
34
|
+
* Some knowledge of Rails (!)
|
35
|
+
|
36
|
+
## What about Windows?
|
37
|
+
|
38
|
+
**RailsBricks doesn't run out of the box on Windows**. Read the [Windows Installation Guide](http://railsbricks.net/windows) to know what to do. You will first need to install the [DevKit](http://rubyinstaller.org/downloads/) as well as the [tzinfo-data](https://github.com/tzinfo/tzinfo-data) gem.
|
39
|
+
|
40
|
+
## Ruby support
|
41
|
+
|
42
|
+
RailsBricks generates Rails apps with support for the current major Ruby release (currently, 2.0.0) + the current point release and the previous one, for example 2.1.4 & 2.2.0. If you need to use another version of Ruby, you will have to manually edit the Gemfile after the app gets created and update the following line with your chosen version number:
|
43
|
+
|
44
|
+
`ruby '2.1.5'`
|
45
|
+
|
46
|
+
## Install
|
47
|
+
|
48
|
+
Like any other gem, you simply issue `gem install railsbricks`
|
49
|
+
|
50
|
+
**Notice:** If you still have RailsBricks 1.x installed, remove it manually *before* installing RailsBricks 3.x
|
51
|
+
|
52
|
+
## Usage
|
53
|
+
|
54
|
+
To create a new app, just type `rbricks --new` and follow the wizard.
|
55
|
+
|
56
|
+
You can read the documentation, see a video and go through the *Get Started* tutorial at [railsbricks.net](http://www.railsbricks.net)
|
57
|
+
|
58
|
+
## Contribute
|
59
|
+
|
60
|
+
You like RailsBricks and want to contribute to its development? Cool! You can do it in 2 ways:
|
61
|
+
|
62
|
+
* Fork the code and implement an awesome feature
|
63
|
+
* Found a bug or a quirk? Fix it!
|
64
|
+
|
65
|
+
**Important**: before working on a new feature, [contact me](http://railsbricks.net/contact) or [open an issue](https://github.com/nicoschuele/railsbricks/issues) on Github explaining what you'd like to implement. I'm trying to keep the maintenance of RailsBricks as easy and fast as possible so before accepting a feature or a PR, we need to make sure it will be maintained properly and within an appropriate timeframe.
|
66
|
+
|
67
|
+
## Questions, Feedback
|
68
|
+
|
69
|
+
If you have any question or feedback, [drop me a line](http://railsbricks.net/contact) or tweet at @railsbricks
|
70
|
+
|
71
|
+
## Acknowledgements
|
72
|
+
|
73
|
+
* [Nikkau](https://github.com/Nikkau), for showing me how to segregate gems without using RVM
|
74
|
+
* [Joelle Gobbo](http://ch.linkedin.com/pub/joelle-gobbo/32/4b5/a9b), for the elegant snippet used to generate a valid Rails app name
|
75
|
+
* [Jim Meyer](https://github.com/purp), for forking RailsBricks and creating an alternative version I also use
|
76
|
+
* [David Hsu](https://github.com/dvdhsu), for adding a new Brick: Devise authentication using only an email address
|
77
|
+
* the authors of the many gems used by RailsBricks
|
78
|
+
* the [Geneva.rb](http://www.meetup.com/genevarb/) Meetup Group for the beer!
|
79
|
+
* David Camarena for producing a [fork](https://github.com/athalas/railsbricks) with support for MySQL
|
80
|
+
* [Felix Wolfsteller](https://github.com/fwolfst) for doing a bit of cleanup
|
81
|
+
* everyone who emailed me, gave feedback, opened an issue on Github, submitted a pull request, tweeted, etc. I truly love the Rails community.
|
82
|
+
|
83
|
+
## License
|
84
|
+
|
85
|
+
Released under GNU GPL-3. Copyright (c) 2014-2015 Nico Schuele. See LICENSE.txt for further details.
|
data/bin/rbricks
ADDED
data/lib/railsbricks.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
require_relative "railsbricks/version"
|
2
|
+
require_relative "railsbricks/string_helpers"
|
3
|
+
require_relative "railsbricks/errors"
|
4
|
+
require_relative "railsbricks/menu"
|
5
|
+
require_relative "railsbricks/app_generator"
|
6
|
+
require_relative "railsbricks/config_helpers"
|
7
|
+
|
8
|
+
class Railsbricks
|
9
|
+
|
10
|
+
def self.main(args)
|
11
|
+
# new app
|
12
|
+
if args[0] == '-n' || args[0] == '--new'
|
13
|
+
new_app
|
14
|
+
elsif args[0] == '-r' || args[0] == '--recreate-db'
|
15
|
+
recreate_db
|
16
|
+
elsif args[0] == '-a' || args[0] == '--annotate'
|
17
|
+
annotate
|
18
|
+
elsif args[0] == '--robocop'
|
19
|
+
prime_directives
|
20
|
+
elsif args[0] == '-v' || args[0] == '--version'
|
21
|
+
display_version
|
22
|
+
elsif args[0] == '--config'
|
23
|
+
display_config
|
24
|
+
else
|
25
|
+
display_help
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.new_app
|
30
|
+
menu = Menu.new
|
31
|
+
@options = menu.new_app_menu
|
32
|
+
generator = AppGenerator.new(@options)
|
33
|
+
generator.generate_app
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.recreate_db
|
37
|
+
options = ConfigHelpers.load_config
|
38
|
+
puts
|
39
|
+
StringHelpers.wputs "----> Recreating the database ...", :info
|
40
|
+
system "#{options["rake_command"]} db:drop"
|
41
|
+
system "#{options["rake_command"]} db:create:all"
|
42
|
+
system "#{options["rake_command"]} db:migrate"
|
43
|
+
system "#{options["rake_command"]} db:seed"
|
44
|
+
puts
|
45
|
+
StringHelpers.wputs "----> Database recreated.", :info
|
46
|
+
puts
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.annotate
|
50
|
+
puts
|
51
|
+
StringHelpers.wputs "----> Annotating models and routes ...", :info
|
52
|
+
puts
|
53
|
+
system "bundle exec annotate"
|
54
|
+
system "bundle exec annotate --routes"
|
55
|
+
puts
|
56
|
+
StringHelpers.wputs "----> Models and routes annotated.", :info
|
57
|
+
puts
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.prime_directives
|
61
|
+
Errors.display_error "1. Serve the public trust"
|
62
|
+
Errors.display_error "2. Protect the innocent"
|
63
|
+
Errors.display_error "3. Uphold the law"
|
64
|
+
Errors.display_error "4. Classified"
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.display_version
|
68
|
+
puts
|
69
|
+
StringHelpers.wputs "RailsBricks #{Version.current} (#{Version.current_date})", :info
|
70
|
+
StringHelpers.wputs "www.railsbricks.net", :info
|
71
|
+
StringHelpers.wputs "source: https://github.com/nicoschuele/railsbricks", :help
|
72
|
+
StringHelpers.wputs "by Nico Schuele (www.nicoschuele.com)", :help
|
73
|
+
puts
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.display_config
|
77
|
+
puts
|
78
|
+
StringHelpers.wputs "----> Retrieving your app's RailsBricks config values ...", :info
|
79
|
+
options = ConfigHelpers.load_config
|
80
|
+
puts
|
81
|
+
if options.count > 1
|
82
|
+
options.each do |k,v|
|
83
|
+
StringHelpers.wputs "#{k}: #{v}"
|
84
|
+
end
|
85
|
+
else
|
86
|
+
Errors.display_error "Config values couldn't be found. In most cases, this is because '#{ConfigHelpers::CONFIG_PATH}/config' is not within your app.", true
|
87
|
+
end
|
88
|
+
puts
|
89
|
+
StringHelpers.wputs "----> App config values retrieved.", :info
|
90
|
+
rescue
|
91
|
+
Errors.display_error "Config values couldn't be found. In most cases, this is because '#{ConfigHelpers::CONFIG_PATH}/config' is not within your app.", true
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.display_help
|
95
|
+
puts
|
96
|
+
StringHelpers.wputs "RailsBricks usage:", :info
|
97
|
+
StringHelpers.wputs "------------------", :info
|
98
|
+
puts
|
99
|
+
puts "rbricks --new (or -n) :"
|
100
|
+
puts " --> create a new RailsBricks app."
|
101
|
+
puts
|
102
|
+
puts "rbricks --recreate-db (or -r) :"
|
103
|
+
puts " --> drop, create, migrate & seed the DB"
|
104
|
+
puts
|
105
|
+
puts "rbricks --config"
|
106
|
+
puts " --> display your app config"
|
107
|
+
puts
|
108
|
+
puts "rbricks --version (or -v) :"
|
109
|
+
puts " --> display the RailsBricks version"
|
110
|
+
puts
|
111
|
+
StringHelpers.wputs "More help, tutorials and documentation at http://www.railsbricks.net/get-started", :info
|
112
|
+
puts
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
@@ -0,0 +1,352 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "net/http"
|
3
|
+
require "uri"
|
4
|
+
require_relative "ui_helpers"
|
5
|
+
require_relative "version"
|
6
|
+
require_relative "string_helpers"
|
7
|
+
require_relative "file_helpers"
|
8
|
+
require_relative "gemfile_builder"
|
9
|
+
require_relative "style_builder"
|
10
|
+
require_relative "auth_builder"
|
11
|
+
require_relative "post_builder"
|
12
|
+
require_relative "config_helpers"
|
13
|
+
|
14
|
+
class AppGenerator
|
15
|
+
|
16
|
+
attr_accessor :options
|
17
|
+
|
18
|
+
def initialize(options)
|
19
|
+
@options = options
|
20
|
+
@app_dir = Dir.pwd + "/#{@options[:app_name]}"
|
21
|
+
@rbricks_dir = File.dirname(__FILE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
def generate_app
|
25
|
+
# Drop creation if necessary
|
26
|
+
if !@options[:generate]
|
27
|
+
wputs "App creation aborted...", :error
|
28
|
+
new_line
|
29
|
+
abort
|
30
|
+
end
|
31
|
+
|
32
|
+
# log creation
|
33
|
+
log_creation
|
34
|
+
|
35
|
+
# updating necessary global gems
|
36
|
+
update_essential_gems
|
37
|
+
|
38
|
+
# install Rails
|
39
|
+
install_rails
|
40
|
+
|
41
|
+
# copy foundation app to directory
|
42
|
+
create_foundation
|
43
|
+
|
44
|
+
# ui
|
45
|
+
StyleBuilder.build_style(@app_dir, @options)
|
46
|
+
|
47
|
+
# database config
|
48
|
+
config_db
|
49
|
+
|
50
|
+
# environment variables
|
51
|
+
config_env_var
|
52
|
+
|
53
|
+
# authentication
|
54
|
+
if @options[:devise]
|
55
|
+
AuthBuilder.build_auth(@app_dir, @options)
|
56
|
+
end
|
57
|
+
|
58
|
+
# contact form
|
59
|
+
add_contact_form
|
60
|
+
|
61
|
+
# google analytics
|
62
|
+
set_google_analytics
|
63
|
+
|
64
|
+
# post resource
|
65
|
+
if @options[:devise] && @options[:post_resources]
|
66
|
+
PostBuilder.build_post(@app_dir, @options)
|
67
|
+
elsif @options[:devise] && !@options[:post_resources]
|
68
|
+
PostBuilder.clean(@app_dir)
|
69
|
+
end
|
70
|
+
|
71
|
+
# prod settings
|
72
|
+
if @options[:production]
|
73
|
+
set_production
|
74
|
+
end
|
75
|
+
|
76
|
+
# Set app name
|
77
|
+
set_app_name
|
78
|
+
|
79
|
+
# build Gemfile
|
80
|
+
GemfileBuilder.build_gemfile(@app_dir, @options)
|
81
|
+
|
82
|
+
# install gems
|
83
|
+
bundle_install
|
84
|
+
|
85
|
+
# create database
|
86
|
+
create_database
|
87
|
+
|
88
|
+
# save config
|
89
|
+
ConfigHelpers.create_config(@app_dir, @options)
|
90
|
+
|
91
|
+
# annotate models and routes
|
92
|
+
annotate
|
93
|
+
|
94
|
+
# git
|
95
|
+
set_git
|
96
|
+
|
97
|
+
# Summary
|
98
|
+
new_line(2)
|
99
|
+
wputs "----> #{@options[:rails_app_name]} created successfully!", :help
|
100
|
+
if @options[:devise]
|
101
|
+
new_line
|
102
|
+
wputs "Admin username: #{@options[:devise_config][:scheme] == 'email' ? 'admin@example.com' : 'admin' }", :info
|
103
|
+
wputs "Admin password: 1234", :info
|
104
|
+
end
|
105
|
+
new_line
|
106
|
+
wputs "Run 'rails server' within #{@options[:app_name]} to start it.", :help
|
107
|
+
new_line
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
# Private/shortcut/alias methods
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
def update_essential_gems
|
116
|
+
new_line
|
117
|
+
wputs "----> Updating Rake & Bundler ... ", :info
|
118
|
+
system "#{@options[:gem_command]} install rake --no-rdoc --no-ri"
|
119
|
+
system "#{@options[:gem_command]} update rake"
|
120
|
+
system "#{@options[:gem_command]} install bundler --no-rdoc --no-ri"
|
121
|
+
system "#{@options[:gem_command]} update bundler"
|
122
|
+
new_line
|
123
|
+
wputs "----> Rake & Bundler updated to their latest versions.", :info
|
124
|
+
rescue
|
125
|
+
Errors.display_error("Required gems (rake & bundler) couldn't be updated properly. Stopping app creation.", true)
|
126
|
+
abort
|
127
|
+
end
|
128
|
+
|
129
|
+
def log_creation
|
130
|
+
url = 'http://railsbricks.net/stats/'
|
131
|
+
uri = URI.parse(url)
|
132
|
+
params = {appname: "#{@options[:rails_app_name]}"}
|
133
|
+
Net::HTTP.post_form(uri, params)
|
134
|
+
rescue
|
135
|
+
nil
|
136
|
+
end
|
137
|
+
|
138
|
+
def install_rails
|
139
|
+
new_line(2)
|
140
|
+
wputs "----> Installing Rails #{@options[:rails_version]} ...", :info
|
141
|
+
system "#{@options[:gem_command]} install rails -v #{@options[:rails_version]} --no-rdoc --no-ri"
|
142
|
+
new_line
|
143
|
+
wputs "----> Rails #{@options[:rails_version]} installed.", :info
|
144
|
+
rescue
|
145
|
+
Errors.display_error("Something went wrong and Rails #{@options[:rails_version]} couldn't be installed. Stopping app creation.", true)
|
146
|
+
abort
|
147
|
+
end
|
148
|
+
|
149
|
+
def create_foundation
|
150
|
+
FileUtils::mkdir_p @app_dir
|
151
|
+
FileUtils.cp_r(@rbricks_dir + "/foundation/.", @app_dir)
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
def config_db
|
156
|
+
new_line(2)
|
157
|
+
wputs "----> Configuring database ...", :info
|
158
|
+
|
159
|
+
if @options[:development_db] == "postgresql"
|
160
|
+
FileUtils.cp_r(@rbricks_dir + "/assets/database/postgresql.yml", @app_dir + "/config/database.yml")
|
161
|
+
FileHelpers.replace_string(/BRICK_DB_SERVER/, @options[:db_config][:server], @app_dir + "/config/database.yml")
|
162
|
+
FileHelpers.replace_string(/BRICK_DB_PORT/, @options[:db_config][:port].to_s, @app_dir + "/config/database.yml")
|
163
|
+
FileHelpers.replace_string(/BRICK_DB_NAME/, @options[:db_config][:name], @app_dir + "/config/database.yml")
|
164
|
+
FileHelpers.replace_string(/BRICK_DB_USERNAME/, @options[:db_config][:username], @app_dir + "/config/database.yml")
|
165
|
+
if @options[:db_config][:password].to_s == ''
|
166
|
+
FileHelpers.replace_string(/BRICK_DB_PASSWORD/, '', @app_dir + "/config/database.yml")
|
167
|
+
else
|
168
|
+
FileHelpers.replace_string(/BRICK_DB_PASSWORD/, "password: #{@options[:db_config][:password]}", @app_dir + "/config/database.yml")
|
169
|
+
end
|
170
|
+
else
|
171
|
+
FileUtils.cp_r(@rbricks_dir + "/assets/database/sqlite3.yml", @app_dir + "/config/database.yml")
|
172
|
+
end
|
173
|
+
|
174
|
+
new_line
|
175
|
+
wputs "----> Database configuration set.", :info
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
def config_env_var
|
180
|
+
new_line(2)
|
181
|
+
wputs "----> Setting environment variables ...", :info
|
182
|
+
FileUtils.cp_r(@rbricks_dir + "/assets/config/application.yml", @app_dir + "/config")
|
183
|
+
FileHelpers.replace_string(/BRICK_VERSION/, @options[:railsbricks_version], @app_dir + "/config/application.yml")
|
184
|
+
|
185
|
+
if @options[:email_settings]
|
186
|
+
FileHelpers.replace_string(/BRICK_SENDER/, @options[:email_config][:sender], @app_dir + "/config/application.yml")
|
187
|
+
FileHelpers.replace_string(/BRICK_SMTP_SERVER/, @options[:email_config][:smtp], @app_dir + "/config/application.yml")
|
188
|
+
FileHelpers.replace_string(/BRICK_MAILER_DOMAIN/, @options[:email_config][:domain], @app_dir + "/config/application.yml")
|
189
|
+
FileHelpers.replace_string(/BRICK_SMTP_PORT/, @options[:email_config][:port], @app_dir + "/config/application.yml")
|
190
|
+
FileHelpers.replace_string(/BRICK_SMTP_USERNAME/, @options[:email_config][:username], @app_dir + "/config/application.yml")
|
191
|
+
FileHelpers.replace_string(/BRICK_SMTP_PASSWORD/, @options[:email_config][:password], @app_dir + "/config/application.yml")
|
192
|
+
end
|
193
|
+
|
194
|
+
if @options[:production]
|
195
|
+
FileHelpers.replace_string(/BRICK_DOMAIN/, @options[:production_settings][:url], @app_dir + "/config/application.yml")
|
196
|
+
end
|
197
|
+
|
198
|
+
new_line
|
199
|
+
wputs "----> Environment variables set.", :info
|
200
|
+
end
|
201
|
+
|
202
|
+
def add_contact_form
|
203
|
+
if @options[:contact_form]
|
204
|
+
new_line(2)
|
205
|
+
wputs "----> Creating contact form ...", :info
|
206
|
+
|
207
|
+
# Views
|
208
|
+
FileUtils.mkdir_p(@app_dir + "/app/views/contact_mailer")
|
209
|
+
FileUtils.cp_r(@rbricks_dir + "/assets/views/pages/contact.html.erb", @app_dir + "/app/views/pages")
|
210
|
+
FileUtils.cp_r(@rbricks_dir + "/assets/views/contact_mailer/contact_message.html.erb", @app_dir + "/app/views/contact_mailer")
|
211
|
+
|
212
|
+
# Mailer
|
213
|
+
FileUtils.cp_r(@rbricks_dir + "/assets/mailers/contact_mailer.rb", @app_dir + "/app/mailers")
|
214
|
+
|
215
|
+
# Navbar link
|
216
|
+
FileHelpers.replace_string(/BRICK_CONTACT/, "<li><%= link_to \"Contact\", contact_path %></li>", @app_dir + "/app/views/layouts/_navigation_links.html.erb")
|
217
|
+
|
218
|
+
# Controller
|
219
|
+
FileHelpers.replace_string(/BRICK_CONTACT_CONTROLLER/, FileHelpers.get_file(:brick_contact_controller), @app_dir + "/app/controllers/pages_controller.rb")
|
220
|
+
|
221
|
+
# Routes
|
222
|
+
FileHelpers.replace_string(/BRICK_CONTACT_ROUTES/, FileHelpers.get_file(:brick_contact_routes), @app_dir + "/config/routes.rb")
|
223
|
+
|
224
|
+
new_line
|
225
|
+
wputs "----> Contact form created.", :info
|
226
|
+
else
|
227
|
+
# Navbar link
|
228
|
+
FileHelpers.replace_string(/BRICK_CONTACT/, '', @app_dir + "/app/views/layouts/_navigation_links.html.erb")
|
229
|
+
# Controller
|
230
|
+
FileHelpers.replace_string(/BRICK_CONTACT_CONTROLLER/, '', @app_dir + "/app/controllers/pages_controller.rb")
|
231
|
+
# Routes
|
232
|
+
FileHelpers.replace_string(/BRICK_CONTACT_ROUTES/, '', @app_dir + "/config/routes.rb")
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
|
237
|
+
def set_google_analytics
|
238
|
+
if @options[:google_analytics]
|
239
|
+
new_line(2)
|
240
|
+
wputs "----> Setting up Google Analytics ...", :info
|
241
|
+
|
242
|
+
FileUtils.cp_r(@rbricks_dir + "/assets/javascripts/analytics.js.coffee", @app_dir + "/app/assets/javascripts")
|
243
|
+
FileHelpers.replace_string(/BRICK_ANALYTICS/, FileHelpers.get_file(:brick_analytics), @app_dir + "/app/views/layouts/_footer.html.erb")
|
244
|
+
FileHelpers.replace_string(/BRICK_ANALYTICS_ID/, @options[:google_tracking_id], @app_dir + "/app/views/layouts/_footer.html.erb")
|
245
|
+
FileHelpers.replace_string(/BRICK_ANALYTICS_SCRIPT/, "\n//= require analytics", @app_dir + "/app/assets/javascripts/application.js")
|
246
|
+
|
247
|
+
new_line
|
248
|
+
wputs "----> Google Analytics set.", :info
|
249
|
+
else
|
250
|
+
FileHelpers.replace_string(/BRICK_ANALYTICS/, '', @app_dir + "/app/views/layouts/_footer.html.erb")
|
251
|
+
FileHelpers.replace_string(/BRICK_ANALYTICS_SCRIPT/, '', @app_dir + "/app/assets/javascripts/application.js")
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def set_production
|
256
|
+
new_line(2)
|
257
|
+
wputs "----> Production settings ...", :info
|
258
|
+
|
259
|
+
if @options[:production_settings][:unicorn]
|
260
|
+
FileUtils.cp_r(@rbricks_dir + "/assets/procfile/Procfile", @app_dir)
|
261
|
+
FileUtils.cp_r(@rbricks_dir + "/assets/config/unicorn.rb", @app_dir + "/config")
|
262
|
+
wputs "--> Unicorn config created."
|
263
|
+
end
|
264
|
+
|
265
|
+
new_line
|
266
|
+
wputs "----> Production settings updated.", :info
|
267
|
+
end
|
268
|
+
|
269
|
+
def set_app_name
|
270
|
+
new_line(2)
|
271
|
+
wputs "----> Setting app name ...", :info
|
272
|
+
FileHelpers.replace_string(/BRICK_APP_NAME/, @options[:rails_app_name], @app_dir + "/config/routes.rb")
|
273
|
+
FileHelpers.replace_string(/BRICK_APP_NAME/, @options[:rails_app_name], @app_dir + "/Rakefile")
|
274
|
+
FileHelpers.replace_string(/BRICK_APP_NAME/, @options[:rails_app_name], @app_dir + "/app/helpers/application_helper.rb")
|
275
|
+
FileHelpers.replace_string(/BRICK_APP_NAME/, @options[:rails_app_name], @app_dir + "/app/views/layouts/application.html.erb")
|
276
|
+
FileHelpers.replace_string(/BRICK_APP_NAME/, @options[:rails_app_name], @app_dir + "/config/application.rb")
|
277
|
+
FileHelpers.replace_string(/BRICK_APP_NAME/, @options[:rails_app_name], @app_dir + "/config/environment.rb")
|
278
|
+
FileHelpers.replace_string(/BRICK_APP_NAME/, @options[:rails_app_name], @app_dir + "/config/environments/development.rb")
|
279
|
+
FileHelpers.replace_string(/BRICK_APP_NAME/, @options[:rails_app_name], @app_dir + "/config/environments/test.rb")
|
280
|
+
FileHelpers.replace_string(/BRICK_APP_NAME/, @options[:rails_app_name], @app_dir + "/config/environments/production.rb")
|
281
|
+
FileHelpers.replace_string(/BRICK_APP_NAME/, @options[:rails_app_name], @app_dir + "/config/initializers/secret_token.rb")
|
282
|
+
FileHelpers.replace_string(/BRICK_APP_NAME/, @options[:rails_app_name], @app_dir + "/config/initializers/session_store.rb")
|
283
|
+
FileHelpers.replace_string(/BRICK_SESSION/, @options[:rails_app_name].downcase, @app_dir + "/config/initializers/session_store.rb")
|
284
|
+
new_line
|
285
|
+
wputs "----> App name set.", :info
|
286
|
+
end
|
287
|
+
|
288
|
+
def bundle_install
|
289
|
+
new_line(2)
|
290
|
+
wputs "----> Installing gems into 'vendor/bundle/' ...", :info
|
291
|
+
Dir.chdir "#{@app_dir}" do
|
292
|
+
system "bundle install --without production --path vendor/bundle"
|
293
|
+
end
|
294
|
+
new_line
|
295
|
+
wputs "----> Gems installed in 'vendor/bundle/'.", :info
|
296
|
+
end
|
297
|
+
|
298
|
+
def annotate
|
299
|
+
new_line(2)
|
300
|
+
wputs "----> Annotating models and routes ...", :info
|
301
|
+
Dir.chdir "#{@app_dir}" do
|
302
|
+
system "bundle exec annotate"
|
303
|
+
system "bundle exec annotate --routes"
|
304
|
+
end
|
305
|
+
new_line
|
306
|
+
wputs "----> Models and routes annotated.", :info
|
307
|
+
end
|
308
|
+
|
309
|
+
def create_database
|
310
|
+
new_line(2)
|
311
|
+
wputs "----> Creating database ...", :info
|
312
|
+
Dir.chdir "#{@app_dir}" do
|
313
|
+
system "#{@options[:rake_command]} db:create:all"
|
314
|
+
system "#{@options[:rake_command]} db:migrate"
|
315
|
+
system "#{@options[:rake_command]} db:seed"
|
316
|
+
end
|
317
|
+
new_line
|
318
|
+
wputs "----> Database created.", :info
|
319
|
+
end
|
320
|
+
|
321
|
+
def set_git
|
322
|
+
# Always copy .gitignore
|
323
|
+
FileUtils.cp_r(@rbricks_dir + "/assets/git/gitignore", @app_dir + "/.gitignore")
|
324
|
+
|
325
|
+
if @options[:local_git]
|
326
|
+
new_line(2)
|
327
|
+
wputs "----> Setting up Git ...", :info
|
328
|
+
Dir.chdir "#{@app_dir}" do
|
329
|
+
system "git init"
|
330
|
+
system "git add -A ."
|
331
|
+
system "git commit -m 'initial commit (RailsBricks #{@options[:railsbricks_version]})'"
|
332
|
+
|
333
|
+
if @options[:remote_git]
|
334
|
+
system "git remote add origin #{@options[:git_url]}"
|
335
|
+
system "git push origin master"
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
new_line
|
340
|
+
wputs "----> Git set up.", :info
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
def wputs(text, highlight = :none)
|
345
|
+
StringHelpers.wputs(text, highlight)
|
346
|
+
end
|
347
|
+
|
348
|
+
def new_line(lines=1)
|
349
|
+
StringHelpers.new_line(lines)
|
350
|
+
end
|
351
|
+
|
352
|
+
end
|