├── .gitignore ├── README.textile ├── composer-Rails3_2.rb ├── composer.rb ├── files ├── .rubocop.yml ├── .rvmrc ├── README ├── README.md ├── README.textile ├── app │ ├── assets │ │ └── stylesheets │ │ │ ├── application-bootstrap.css.scss │ │ │ └── application.css.scss │ ├── controllers │ │ ├── application_controller-omniauth.rb │ │ └── registrations_controller-devise.rb │ ├── helpers │ │ └── application_helper-simple_form.rb │ └── views │ │ ├── devise │ │ ├── .DS_Store │ │ ├── registrations │ │ │ ├── edit-simple_form.html.erb │ │ │ ├── edit.html.erb │ │ │ ├── new-simple_form.html.erb │ │ │ └── new.html.erb │ │ ├── sessions │ │ │ └── new-simple_form.html.erb │ │ └── shared │ │ │ └── _links.html.erb │ │ ├── home │ │ ├── index-subdomains_app.html.erb │ │ └── index.html.erb │ │ ├── layouts │ │ ├── _messages-bootstrap.html.erb │ │ ├── _messages.html.erb │ │ ├── _navigation-cancan-omniauth.html.erb │ │ ├── _navigation-cancan.html.erb │ │ ├── _navigation-devise.html.erb │ │ ├── _navigation-omniauth.html.erb │ │ ├── _navigation-subdomains_app.html.erb │ │ ├── _navigation.html.erb │ │ ├── application-bootstrap.html.erb │ │ └── application.html.erb │ │ ├── profiles │ │ └── show-subdomains_app.html.erb │ │ └── users │ │ ├── _user-simple_form.html.erb │ │ ├── _user.html.erb │ │ ├── edit-omniauth.html.erb │ │ ├── index-admin_app.html.erb │ │ ├── index.html.erb │ │ ├── show-subdomains_app.html.erb │ │ └── show.html.erb ├── config │ ├── database-mysql.yml │ ├── database-postgresql.yml │ └── secrets.yml ├── gitignore.txt └── public │ └── humans.txt └── railsComposer.sh /.gitignore: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------------------- 2 | # This is the .gitignore file for the rails-composer repository. 3 | # 4 | # Rails Composer is an application template that creates a Rails starter app. 5 | # 6 | # The Rails Composer application template is generated by the rails_apps_composer gem: 7 | # https://github.com/RailsApps/rails_apps_composer 8 | # 9 | # The Rails Composer application template will create a .gitignore file for any starter app. 10 | # This file isn't used by the Rails Composer application template; instead the template uses: 11 | # https://github.com/RailsApps/rails-composer/blob/master/files/gitignore.txt 12 | # 13 | # Corrections? Improvements? Create a GitHub issue: 14 | # http://github.com/RailsApps/rails-composer/issues 15 | #---------------------------------------------------------------------------- 16 | 17 | # bundler state 18 | /.bundle 19 | /vendor/bundle/ 20 | /vendor/ruby/ 21 | 22 | # minimal Rails specific artifacts 23 | db/*.sqlite3 24 | /log/* 25 | /tmp/* 26 | 27 | # various artifacts 28 | **.war 29 | *.rbc 30 | *.sassc 31 | .rspec 32 | .redcar/ 33 | .sass-cache 34 | /config/config.yml 35 | /config/database.yml 36 | /coverage.data 37 | /coverage/ 38 | /db/*.javadb/ 39 | /db/*.sqlite3 40 | /doc/api/ 41 | /doc/app/ 42 | /doc/features.html 43 | /doc/specs.html 44 | /public/cache 45 | /public/stylesheets/compiled 46 | /public/system/* 47 | /spec/tmp/* 48 | /cache 49 | /capybara* 50 | /capybara-*.html 51 | /gems 52 | /spec/requests 53 | /spec/routing 54 | /spec/views 55 | /specifications 56 | rerun.txt 57 | pickle-email-*.html 58 | 59 | # If you find yourself ignoring temporary files generated by your text editor 60 | # or operating system, you probably want to add a global ignore instead: 61 | # git config --global core.excludesfile ~/.gitignore_global 62 | # 63 | # Here are some files you may want to ignore globally: 64 | 65 | # scm revert files 66 | **.orig 67 | 68 | # Mac finder artifacts 69 | .DS_Store 70 | 71 | # Netbeans project directory 72 | /nbproject/ 73 | 74 | # RubyMine project files 75 | .idea 76 | 77 | # Textmate project files 78 | /*.tmproj 79 | 80 | # vim artifacts 81 | **.swp 82 | -------------------------------------------------------------------------------- /README.textile: -------------------------------------------------------------------------------- 1 | h1. !http://railsapps.github.io/images/rails-36x36.jpg(Rails Composer)! Rails Composer 2 | 3 | An application template that creates starter applications for Rails. 4 | 5 | It's the Rails generator on steroids. 6 | 7 | Watch the videos: 8 | 9 | * "Rails Composer Introduction":https://fullstackvideos.com/videos/13 (for beginners) 10 | * "RailsClips Episode 007: Rails Composer":https://devchat.tv/rails-clips/007-railsclips-rails-composer from Charles Max Wood. 11 | 12 | |_. |_. | 13 | | !http://railsapps.github.io/images/rails-composer-mailing-list.png(Sign up for the Rails Composer mailing list)!:http://mailinglist.railscomposer.com/ | !http://railsapps.github.io/images/join/join-railsapps.png(Join the RailsApps Project)!:http://railsapps.github.io/ | 14 | | "Rails Composer mailing list":http://mailinglist.railscomposer.com/ | "Support the project":http://railsapps.github.io/ | 15 | 16 | h4. From the RailsApps Project 17 | 18 | The "RailsApps":http://railsapps.github.io/ open source project offers starter applications and tutorials for Rails developers. Generate the applications with the Rails Composer tool. 19 | 20 | All the code is explained in the Capstone Rails Tutorials. You can purchase the "Capstone Rails Tutorials":https://tutorials.railsapps.org/ to support the project. 21 | 22 | "Sign up for the Rails Composer mailing list":http://mailinglist.railscomposer.com/ for news and announcements. 23 | 24 | h2. Starter Apps and Tutorials 25 | 26 | |_. Example |_. Tutorial |_. Comments | 27 | | "learn-rails":https://github.com/RailsApps/learn-rails | "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html | from the book for beginners | 28 | | "rails-bootstrap":https://github.com/RailsApps/rails-bootstrap | "Rails and Bootstrap":http://railsapps.github.io/twitter-bootstrap-rails.html | Bootstrap front-end framework | 29 | | "rails-foundation":https://github.com/RailsApps/rails-foundation | "Rails and Foundation":http://railsapps.github.io/rails-foundation.html | Foundation front-end framework | 30 | | "rails-mailinglist-activejob":https://github.com/RailsApps/rails-mailinglist-activejob | "Mailing List with Active Job Tutorial":https://tutorials.railsapps.org/ | sign up for a mailing list using background processing | 31 | | "rails-omniauth":https://github.com/RailsApps/rails-omniauth | "OmniAuth Tutorial":https://tutorials.railsapps.org/ | authentication with OmniAuth | 32 | | "rails-devise":https://github.com/RailsApps/rails-devise | "Rails Devise Tutorial":https://tutorials.railsapps.org/ | authentication with Devise | 33 | | "rails-devise-roles":https://github.com/RailsApps/rails-devise-roles | "Role-Based Authorization":https://tutorials.railsapps.org/ | authorization with roles | 34 | | "rails-devise-pundit":https://github.com/RailsApps/rails-devise-pundit | "Rails Pundit Tutorial":https://tutorials.railsapps.org/ | authorization with Pundit | 35 | | "rails-signup-download":https://github.com/RailsApps/rails-signup-download | "Rails Signup Download":https://tutorials.railsapps.org/ | Devise plus download a PDF file | 36 | | "rails-stripe-checkout":https://github.com/RailsApps/rails-stripe-checkout | "Stripe Checkout":https://tutorials.railsapps.org/ | selling a product with Stripe Checkout | 37 | | "rails-stripe-coupons":https://github.com/RailsApps/rails-stripe-coupons | "Stripe JS With Coupons":https://tutorials.railsapps.org/ | complex Rails and Stripe integration | 38 | 39 | h4. The rails_apps_composer Gem 40 | 41 | Do you want to customize the Rails Composer application template? The Rails Composer application template is built from recipes provided by the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem. 42 | 43 | h4. If You Are New to Rails 44 | 45 | If you're new to Rails, see "What is Ruby on Rails?":http://railsapps.github.io/what-is-ruby-rails.html, the book "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html, and recommendations for a "Rails tutorial":https://tutorials.railsapps.org/rails-tutorial. 46 | 47 | h2. Dependencies 48 | 49 | Before running the Rails Composer tool, you need to install: 50 | 51 | * The Ruby language 52 | * Rails 53 | 54 | Check that appropriate versions of Ruby and Rails are installed in your development environment: 55 | @$ ruby -v@ 56 | @$ rails -v@ 57 | 58 | Be sure to read the article "Installing Rails":http://railsapps.github.io/installing-rails.html to make sure your development environment is set up properly. 59 | 60 | h2. How To Use Rails Composer 61 | 62 | To build a Rails application using the Rails Composer tool: 63 | 64 |
65 | $ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb 66 |67 | 68 | Replace @myapp@ with the name of your application. 69 | 70 | The @$@ character indicates a shell prompt; don't include it when you run the command. 71 | 72 | See the "Troubleshooting" section below if you see errors. In general, you'll avoid problems if you create your application using RVM as described in the next section. 73 | 74 | h3. Creating a Starter App Using RVM 75 | 76 | I recommend using "RVM":https://rvm.io/, the Ruby Version Manager, to manage your Rails versions, as described in the "Installing Rails":http://railsapps.github.io/installing-rails.html article. 77 | 78 | Here's how to generate a new Rails application using the Rails Composer tool and RVM: 79 | 80 |
81 | $ mkdir myapp 82 | $ cd myapp 83 | $ rvm use ruby-2.4.0@myapp --ruby-version --create 84 | $ gem install rails 85 | $ rails new . -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb 86 |87 | 88 | Instead of installing Rails into the global gemset and running @rails new@, we'll create a root directory for a new application, create a new gemset, install Rails, and then generate a starter application. 89 | 90 | When we create the gemset, the option "--ruby-version" creates *.ruby-version* and *.ruby-gemset* files in the root directory. RVM recognizes these files in an application's root directory and loads the required version of Ruby and the correct gemset whenever you enter the directory. 91 | 92 | When we create the gemset, it will be empty (though it inherits use of all the gems in the global gemset). We immediately install Rails. The command @gem install rails@ installs the most recent stable release of Rails. 93 | 94 | Finally we run @rails new .@. We use the Unix "dot" convention to refer to the current directory. This assigns the name of the directory to the new application. 95 | 96 | This approach is different from the way most beginners are taught to create a Rails application. Our approach makes it easy to create a project-specific gemset to avoid clashes between gem versions when using the Rails Composer tool. 97 | 98 | h2. Choose a RailsApps Starter Application 99 | 100 | Use Rails Composer to generate any of the example applications from the "RailsApps project":http://railsapps.github.io/. You'll be able to choose your own project name when you generate the app. Generating the application gives you additional options. 101 | 102 | To build the example application, Rails must be installed in your development environment. 103 | 104 | You'll see a prompt: 105 | 106 |
107 | option Build a starter application? 108 | 1) Build a RailsApps example application 109 | 2) Contributed applications 110 | 3) Custom application 111 |112 | 113 | Enter "1" to select *Build a starter application*. You'll see a prompt: 114 | 115 |
116 | option Choose a starter application. 117 | 1) learn-rails 118 | 2) rails-bootstrap 119 | 3) rails-foundation 120 | 4) rails-mailinglist-activejob 121 | 5) rails-omniauth 122 | 6) rails-devise 123 | 7) rails-devise-roles 124 | 8) rails-devise-pundit 125 | 9) rails-signup-download 126 | 10) rails-stripe-checkout 127 | 11) rails-stripe-coupons 128 |129 | 130 | Each of these applications is available as an example in the "RailsApps GitHub repo":https://github.com/RailsApps and each is accompanied by a tutorial on the "Capstone Rails Tutorials":https://tutorials.railsapps.org/ site. 131 | 132 | Make your choice. The Rails Composer tool may give you other options (other applications may have been added since these notes were written). 133 | 134 | h4. Options 135 | 136 | The application generator template will ask you for additional preferences. Options vary, depending on the example application you build. Options may have changed in a newer version of Rails Composer. 137 | 138 |
139 | option Web server for development? 140 | 1) WEBrick (default) 141 | 2) Thin 142 | 3) Unicorn 143 | 4) Puma 144 | 5) Phusion Passenger (Apache/Nginx) 145 | 6) Phusion Passenger (Standalone) 146 | option Web server for production? 147 | 1) Same as development 148 | 2) Thin 149 | 3) Unicorn 150 | 4) Puma 151 | 5) Phusion Passenger (Apache/Nginx) 152 | 6) Phusion Passenger (Standalone) 153 | option Database used in development? 154 | 1) SQLite 155 | 2) PostgreSQL 156 | 3) MySQL 157 | option Template engine? 158 | 1) ERB 159 | 2) Haml 160 | 3) Slim 161 | option Test framework? 162 | 1) None 163 | 2) RSpec with Capybara 164 | option Front-end framework? 165 | 1) None 166 | 2) Bootstrap 3.0 167 | 3) Bootstrap 2.3 168 | 4) Zurb Foundation 5.0 169 | 5) Zurb Foundation 4.0 170 | 6) Simple CSS 171 | option Install page-view analytics? 172 | 1) None 173 | 2) Google Analytics 174 | 3) Segment.io 175 | extras Set a robots.txt file to ban spiders? (y/n) 176 | extras Create a GitHub repository? (y/n) 177 | extras Use or create a project-specific rvm gemset? (y/n) 178 |179 | 180 | h4. Web Servers 181 | 182 | If you plan to deploy to Heroku, select Puma as your production webserver. Puma is recommended by Heroku. 183 | 184 | h4. Database 185 | 186 | Choose "SQLite" for the easiest setup. If you choose PostgreSQL or MySQL, the databases must be installed and running before you run Rails Composer. 187 | 188 | h4. Template Engine 189 | 190 | The example applications use the default "ERB" Rails template engine. Optionally, you can use another template engine, such as Haml or Slim. See instructions for "Haml and Rails":http://railsapps.github.io/rails-haml.html. 191 | 192 | h4. Testing 193 | 194 | If you are a beginner, select "None." Select "RSpec with Capybara" if you want tests. 195 | 196 | h4. Front-end Framework 197 | 198 | If you choose a front-end framework, you'll get an application layout file, plus navigation and flash messages, styled with a default theme. 199 | 200 | h4. Other Choices 201 | 202 | Set a robots.txt file to ban spiders if you want to keep your new site out of Google search results. 203 | 204 | If you choose to create a GitHub repository, the generator will prompt you for a GitHub username and password. 205 | 206 | It is a good idea to use "RVM":https://rvm.io/, the Ruby Version Manager, and create a project-specific rvm gemset (not available on Windows). See "Installing Rails":http://railsapps.github.io/installing-rails.html. 207 | 208 | h2. Contributed Applications 209 | 210 | Currently, there are no contributed applications available. If you would like to add your favorite starter application to Rails Composer, open an issue to let us know. 211 | 212 | h2. Build Your Own Application 213 | 214 | If you choose "Custom application," you will get a wide set of choices. Not all are actively supported. 215 | 216 | A large community of developers contributes code that supports additional gems and favorite configurations offered with the "build your own options." However, not all contributions are actively maintained. That means not all options are tested or fully supported, so you may need to spend time debugging a "build your own application." 217 | 218 | When you choose "Custom application," you will see something similar to this: 219 | 220 |
221 | option Build a starter application? 222 | 1) Build a RailsApps example application 223 | 2) Contributed applications 224 | 3) Custom application 225 | 226 | option Web server for development? 227 | 1) WEBrick (default) 228 | 2) Thin 229 | 3) Unicorn 230 | 4) Puma 231 | 5) Phusion Passenger (Apache/Nginx) 232 | 6) Phusion Passenger (Standalone) 233 | 234 | option Web server for production? 235 | 1) Same as development 236 | 2) Thin 237 | 3) Unicorn 238 | 4) Puma 239 | 5) Phusion Passenger (Apache/Nginx) 240 | 6) Phusion Passenger (Standalone) 241 | 242 | option Database used in development? 243 | 1) SQLite 244 | 2) PostgreSQL 245 | 3) MySQL 246 | 247 | option Template engine? 248 | 1) ERB 249 | 2) Haml 250 | 3) Slim 251 | 252 | option Test framework? 253 | 1) None 254 | 2) RSpec with Capybara 255 | 256 | option Continuous testing? 257 | 1) None 258 | 2) Guard 259 | 260 | option Front-end framework? 261 | 1) None 262 | 2) Bootstrap 3.0 263 | 3) Bootstrap 2.3 264 | 4) Zurb Foundation 5.0 265 | 5) Zurb Foundation 4.0 266 | 6) Simple CSS 267 | 268 | option Add support for sending email? 269 | 1) None 270 | 2) Gmail 271 | 3) SMTP 272 | 4) SendGrid 273 | 5) Mandrill 274 | 275 | option Authentication? 276 | 1) None 277 | 2) Devise 278 | 3) OmniAuth 279 | 280 | option Devise modules? 281 | 1) Devise with default modules 282 | 2) Devise with Confirmable module 283 | 284 | option Authorization? 285 | 1) None 286 | 2) Pundit 287 | 288 | option Use a form builder gem? 289 | 1) None 290 | 2) SimpleForm 291 | 292 | option Install a starter app? 293 | 1) None 294 | 2) Home Page 295 | 3) Home Page, User Accounts 296 | 4) Home Page, User Accounts, Admin Dashboard 297 | 298 | extras Add 'therubyracer' JavaScript runtime (for Linux users without node.js)? (y/n) 299 | extras Set a robots.txt file to ban spiders? (y/n) 300 | extras Create a GitHub repository? (y/n) 301 | 302 | option Add gem and file for environment variables? 303 | 1) None 304 | 2) Add .env with Foreman 305 | 3) Add application.yml with Figaro 306 | 307 | extras Reduce assets logger noise during development? (y/n) 308 | extras Improve error reporting with 'better_errors' during development? (y/n) 309 | extras Use 'pry' as console replacement during development and test? (y/n) 310 | extras Use or create a project-specific rvm gemset? (y/n) 311 | 312 | option Add a deployment mechanism? 313 | 1) None 314 | 2) Capistrano3 315 |316 | 317 | h2. Run the Application 318 | 319 | Switch to the application directory to examine and test what you've built. 320 | 321 |
322 | $ cd myapp 323 |324 | 325 | h4. Quick Test 326 | 327 | For a "smoke test" to see if everything runs, display a list of Rake tasks. 328 | 329 |
330 | $ rake -T 331 |332 | 333 | There's no need to run @bundle exec rake@ instead of @rake@ when you are using rvm (see "rvm and bundler integration":https://rvm.io/integration/bundler/). 334 | 335 | h4. Start the Web Server 336 | 337 | If you've chosen WEBrick or Thin for your web server, can run the app by entering the command: 338 | 339 | @$ rails server@ 340 | 341 | To see your application in action, open a browser window and navigate to "http://localhost:3000/":http://localhost:3000. 342 | 343 | For the Unicorn web server: 344 | 345 | @$ unicorn@ 346 | 347 | See the app at "http://localhost:8080/":http://localhost:8080. 348 | 349 | For the Puma web server: 350 | 351 | @$ rails server puma@ 352 | 353 | See the app at "http://localhost:3000/":http://localhost:3000. 354 | 355 | For Phusion Passenger (Apache or Nginx integration mode), please refer to "the official documentation":https://www.phusionpassenger.com/documentation_and_support. 356 | 357 | For Phusion Passenger (Standalone): 358 | 359 | @$ passenger start@ 360 | 361 | h4. Login 362 | 363 | If you've created a version of the application that sets up a default user, log in with: 364 | 365 | * email: user@example.com 366 | * password: changeme 367 | 368 | You should delete or change any pre-configured logins before you deploy your application. 369 | 370 | h2. Testing 371 | 372 | Some versions of the starter application will contain a suite of RSpec feature and unit tests. 373 | 374 | Run @rspec@ to run all RSpec tests. 375 | 376 | Please send the author a message, create an issue, or submit a pull request if you want to contribute improved RSpec tests. 377 | 378 | h2. Deployment 379 | 380 | For easy deployment, use a “platform as a service” provider such as: 381 | 382 | * "Heroku":http://www.heroku.com/ 383 | * "CloudFoundry":http://www.cloudfoundry.com/ 384 | * "EngineYard":http://www.engineyard.com/ 385 | * "OpenShift":https://openshift.redhat.com/app/ 386 | 387 | For deployment on Heroku, see the article: 388 | 389 | * "Rails on Heroku":http://railsapps.github.io/rails-heroku-tutorial.html 390 | 391 | h2. Troubleshooting 392 | 393 | Problems? Please check both "issues for the Rails Composer tool":https://github.com/RailsApps/rails-composer/issues and the "issues for the rails_apps_composer gem":https://github.com/RailsApps/rails_apps_composer/issues. 394 | 395 | You should review the article "Installing Rails":http://railsapps.github.io/installing-rails.html to make sure you've updated all the components that are required to run Rails successfully. 396 | 397 | h4. Problems with "Could not be loaded... You have already activated..." 398 | 399 | If you get an error like this: 400 | 401 |
402 | Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. 403 | composer Running 'after bundler' callbacks. 404 | The template [...] could not be loaded. 405 | Error: You have already activated ..., but your Gemfile requires .... 406 | Using bundle exec may solve this. 407 |408 | 409 | It's due to conflicting gem versions. See the article "Rails Error: “You have already activated (…)”":http://railsapps.github.io/rails-error-you-have-already-activated.html. 410 | 411 | h4. Problems with "Certificate Verify Failed" 412 | 413 | Are you getting an error "OpenSSL certificate verify failed" when you try to generate a new Rails app from an application template? See suggestions to resolve the error "Certificate Verify Failed":http://railsapps.github.io/openssl-certificate-verify-failed.html. 414 | 415 | h4. Problems with "Segmentation Fault" 416 | 417 | If you get a "segfault" when you try @rails new@, try removing and reinstalling rvm. 418 | 419 | h2. Application Template Default 420 | 421 | The @rails new@ command creates a new Rails application. If you want to use the Rails Composer application template for every Rails application you build, you can set options for the @rails new@ command in a *.railsrc* file in your home directory. Here's how to set up a *.railsrc* file to use the template when you create a new Rails application: 422 | 423 |
424 | # ~/.railsrc 425 | -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb 426 |427 | 428 | h2. Documentation and Support 429 | 430 | The Rails Composer application template is assembled from recipes supplied by the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem. See the rails_apps_composer project to understand how the Rails Composer application works. 431 | 432 | h4. Customizing the Template 433 | 434 | If you wish to change the template to generate an app with your own customized options, you can copy and edit the template file. However, it is better to use the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem to create a new application template. You'll find newer versions of the recipes that make up the application template. You may find issues have been identified and (perhaps) fixed. And it will be easier to maintain your application template if you work from the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem. 435 | 436 | h4. Writing Recipes 437 | 438 | To understand the code in these templates, take a look at "Thor::Actions":http://rdoc.info/github/wycats/thor/master/Thor/Actions. Your recipes can use any methods provided by "Thor::Actions":http://rdoc.info/github/wycats/thor/master/Thor/Actions or "Rails::Generators::Actions":http://railsapi.com/doc/rails-v3.0.3/classes/Rails/Generators/Actions.html. A big thanks to Yehuda Katz for "creating Thor":http://yehudakatz.com/2008/05/12/by-thors-hammer/. 439 | 440 | h4. About Rails Application Templates 441 | 442 | There is an unfinished Rails Guide on "Rails Application Templates":https://github.com/rails/rails/blob/master/guides/source/rails_application_templates.md. 443 | 444 | Also see: 445 | 446 | "Cooking Up A Custom Rails 3 Template (11 Oct 2010) by Andrea Singh":http://blog.madebydna.com/all/code/2010/10/11/cooking-up-a-custom-rails3-template.html 447 | "Rails Application Templates (16 Sept 2010) by Collin Schaafsma":http://quickleft.com/blog/rails-application-templates 448 | "Application templates in Rails 3 (18 Sept 2009) by Ben Scofield":http://benscofield.com/2009/09/application-templates-in-rails-3/ 449 | "Railscasts: App Templates in Rails 2.3 (9 Feb 2009) by Ryan Bates":http://railscasts.com/episodes/148-app-templates-in-rails-2-3 450 | "Rails templates (4 Dec 2008) by Pratik Naik":http://m.onkey.org/rails-templates 451 | 452 | h4. Similar Projects 453 | 454 | There are many similar projects: 455 | 456 | * "Rails application template projects":http://railsapps.github.io/rails-application-templates.html 457 | * "Rails examples, tutorials, and starter apps":http://railsapps.github.io/rails-examples-tutorials.html. 458 | 459 | h4. Issues 460 | 461 | Problems? Please check both "issues for the Rails Composer tool":https://github.com/RailsApps/rails-composer/issues and the "issues for the rails_apps_composer gem":https://github.com/RailsApps/rails_apps_composer/issues. 462 | 463 | h4. Where to Get Help 464 | 465 | Your best source for help with problems is "Stack Overflow":http://stackoverflow.com/questions/tagged/railsapps. Your issue may have been encountered and addressed by others. 466 | 467 | Use the tag "railsapps" on Stack Overflow for extra attention. 468 | 469 | h2. Contributing 470 | 471 | Please make changes to the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem rather than changing the Rails Composer application template. 472 | 473 | h2. Credits 474 | 475 | Daniel Kehoe initiated the "RailsApps project":https://github.com/RailsApps. The "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem is derived from Michael Bleigh’s RailsWizard gem. 476 | 477 | Is it useful to you? Follow the project on Twitter: 478 | "@rails_apps":http://twitter.com/rails_apps 479 | and tweet some praise. I'd love to know you were helped out by what I've put together. 480 | 481 | h2. License 482 | 483 | "MIT License":http://www.opensource.org/licenses/mit-license 484 | 485 | Copyright 2012-14 Daniel Kehoe 486 | 487 | h2. Useful Links 488 | 489 | |_. Getting Started |_. Articles |_. Tutorials | 490 | | "Ruby on Rails":http://railsapps.github.io/ruby-and-rails.html | "Analytics for Rails":http://railsapps.github.io/rails-google-analytics.html | "Rails Bootstrap":http://railsapps.github.io/twitter-bootstrap-rails.html | 491 | | "What is Ruby on Rails?":http://railsapps.github.io/what-is-ruby-rails.html | "Heroku and Rails":http://railsapps.github.io/rails-heroku-tutorial.html | "Rails Foundation":http://railsapps.github.io/rails-foundation.html | 492 | | "Learn Ruby on Rails":http://learn-rails.com/learn-ruby-on-rails.html | "JavaScript and Rails":http://railsapps.github.io/rails-javascript-include-external.html | "RSpec Tutorial":http://railsapps.github.io/rspec.html | 493 | | "Rails Tutorial":https://tutorials.railsapps.org/rails-tutorial | "Rails Environment Variables":http://railsapps.github.io/rails-environment-variables.html | "Rails Devise Tutorial":http://railsapps.github.io/tutorial-rails-devise.html | 494 | | "Ruby on Rails Tutorial for Beginners":http://learn-rails.com/ruby-on-rails-tutorial-for-beginners | "Git and GitHub with Rails":http://railsapps.github.io/rails-git.html | "Devise RSpec":http://railsapps.github.io/tutorial-rails-devise-rspec-cucumber.html | 495 | | "Install Ruby on Rails":http://railsapps.github.io/installing-rails.html | "Send Email with Rails":http://railsapps.github.io/rails-send-email.html | "Devise Bootstrap":http://railsapps.github.io/tutorial-rails-bootstrap-devise-cancan.html | 496 | | "Install Ruby on Rails - Mac OS X":http://railsapps.github.io/installrubyonrails-mac.html | "Haml and Rails":http://railsapps.github.io/rails-haml.html | "Rails Membership Site with Stripe":https://tutorials.railsapps.org/rails-stripe-membership-saas | 497 | | "Install Ruby on Rails - Ubuntu":http://railsapps.github.io/installrubyonrails-ubuntu.html | "Rails Application Layout":http://railsapps.github.io/rails-default-application-layout.html | "Rails Subscription Site with Recurly":https://tutorials.railsapps.org/rails-recurly-subscription-saas | 498 | | "Ruby on Rails - Nitrous.io":http://railsapps.github.io/rubyonrails-nitrous-io.html | "HTML5 Boilerplate for Rails":http://railsapps.github.io/rails-html5-boilerplate.html | "Startup Prelaunch Signup Application":https://tutorials.railsapps.org/rails-prelaunch-signup | 499 | | "Update Rails":http://railsapps.github.io/updating-rails.html | "Example Gemfiles for Rails":http://railsapps.github.io/rails-3-2-example-gemfile.html | 500 | | "Rails Composer":http://railsapps.github.io/rails-composer/ | "Rails Application Templates":http://railsapps.github.io/rails-application-templates.html | 501 | | "Rails Examples":http://railsapps.github.io/ | "Rails Product Planning":http://railsapps.github.io/rails-product-planning.html | 502 | | "Rails Starter Apps":http://railsapps.github.io/rails-examples-tutorials.html | "Rails Project Management":http://railsapps.github.io/rails-project-management.html | 503 | -------------------------------------------------------------------------------- /composer.rb: -------------------------------------------------------------------------------- 1 | # >---------------------------------------------------------------------------< 2 | # 3 | # _____ _ _ 4 | # | __ \ (_) | /\ 5 | # | |__) |__ _ _| |___ / \ _ __ _ __ ___ 6 | # | _ // _` | | / __| / /\ \ | '_ \| '_ \/ __| 7 | # | | \ \ (_| | | \__ \/ ____ \| |_) | |_) \__ \ 8 | # |_| \_\__,_|_|_|___/_/ \_\ .__/| .__/|___/ 9 | # | | | | 10 | # |_| |_| 11 | # 12 | # Application template generated by the rails_apps_composer gem. 13 | # Restrain your impulse to make changes to this file; instead, 14 | # make changes to the recipes in the rails_apps_composer gem. 15 | # 16 | # For more information, see: 17 | # https://github.com/RailsApps/rails_apps_composer/ 18 | # 19 | # Thank you to Michael Bleigh for leading the way with the RailsWizard gem. 20 | # 21 | # >---------------------------------------------------------------------------< 22 | 23 | # >----------------------------[ Initial Setup ]------------------------------< 24 | 25 | module Gemfile 26 | class GemInfo 27 | def initialize(name) @name=name; @group=[]; @opts={}; end 28 | attr_accessor :name, :version 29 | attr_reader :group, :opts 30 | 31 | def opts=(new_opts={}) 32 | new_group = new_opts.delete(:group) 33 | if (new_group && self.group != new_group) 34 | @group = ([self.group].flatten + [new_group].flatten).compact.uniq.sort 35 | end 36 | @opts = (self.opts || {}).merge(new_opts) 37 | end 38 | 39 | def group_key() @group end 40 | 41 | def gem_args_string 42 | args = ["'#{@name}'"] 43 | args << "'#{@version}'" if @version 44 | @opts.each do |name,value| 45 | args << ":#{name}=>#{value.inspect}" 46 | end 47 | args.join(', ') 48 | end 49 | end 50 | 51 | @geminfo = {} 52 | 53 | class << self 54 | # add(name, version, opts={}) 55 | def add(name, *args) 56 | name = name.to_s 57 | version = args.first && !args.first.is_a?(Hash) ? args.shift : nil 58 | opts = args.first && args.first.is_a?(Hash) ? args.shift : {} 59 | @geminfo[name] = (@geminfo[name] || GemInfo.new(name)).tap do |info| 60 | info.version = version if version 61 | info.opts = opts 62 | end 63 | end 64 | 65 | def write 66 | File.open('Gemfile', 'a') do |file| 67 | file.puts 68 | grouped_gem_names.sort.each do |group, gem_names| 69 | indent = "" 70 | unless group.empty? 71 | file.puts "group :#{group.join(', :')} do" unless group.empty? 72 | indent=" " 73 | end 74 | gem_names.sort.each do |gem_name| 75 | file.puts "#{indent}gem #{@geminfo[gem_name].gem_args_string}" 76 | end 77 | file.puts "end" unless group.empty? 78 | file.puts 79 | end 80 | end 81 | end 82 | 83 | private 84 | #returns {group=>[...gem names...]}, ie {[:development, :test]=>['rspec-rails', 'mocha'], :assets=>[], ...} 85 | def grouped_gem_names 86 | {}.tap do |_groups| 87 | @geminfo.each do |gem_name, geminfo| 88 | (_groups[geminfo.group_key] ||= []).push(gem_name) 89 | end 90 | end 91 | end 92 | end 93 | end 94 | def add_gem(*all) Gemfile.add(*all); end 95 | 96 | @recipes = ["core", "git", "railsapps", "learn_rails", "rails_bootstrap", "rails_foundation", "rails_omniauth", "rails_devise", "rails_devise_roles", "rails_devise_pundit", "rails_shortcut_app", "rails_signup_download", "rails_signup_thankyou", "rails_mailinglist_activejob", "rails_stripe_checkout", "rails_stripe_coupons", "rails_stripe_membership_saas", "setup", "locale", "readme", "gems", "tests", "email", "devise", "omniauth", "roles", "frontend", "pages", "init", "analytics", "deployment", "extras"] 97 | @prefs = {} 98 | @gems = [] 99 | @diagnostics_recipes = [["example"], ["setup"], ["railsapps"], ["gems", "setup"], ["gems", "readme", "setup"], ["extras", "gems", "readme", "setup"], ["example", "git"], ["git", "setup"], ["git", "railsapps"], ["gems", "git", "setup"], ["gems", "git", "readme", "setup"], ["extras", "gems", "git", "readme", "setup"], ["email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["core", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["core", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["core", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["email", "example", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["email", "example", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["email", "example", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["apps4", "core", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["apps4", "core", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "tests"], ["apps4", "core", "deployment", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "testing"], ["apps4", "core", "deployment", "email", "extras", "frontend", "gems", "git", "init", "railsapps", "readme", "setup", "tests"], ["apps4", "core", "deployment", "devise", "email", "extras", "frontend", "gems", "git", "init", "omniauth", "pundit", "railsapps", "readme", "setup", "tests"]] 100 | @diagnostics_prefs = [] 101 | diagnostics = {} 102 | 103 | # >-------------------------- templates/helpers.erb --------------------------start< 104 | def recipes; @recipes end 105 | def recipe?(name); @recipes.include?(name) end 106 | def prefs; @prefs end 107 | def prefer(key, value); @prefs[key].eql? value end 108 | def gems; @gems end 109 | def diagnostics_recipes; @diagnostics_recipes end 110 | def diagnostics_prefs; @diagnostics_prefs end 111 | 112 | def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + " #{text}" end 113 | def say_loud(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + " #{text}" + "\033[0m" end 114 | def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end 115 | def say_wizard(text); say_custom(@current_recipe || 'composer', text) end 116 | 117 | def ask_wizard(question) 118 | ask "\033[1m\033[36m" + ("option").rjust(10) + "\033[1m\033[36m" + " #{question}\033[0m" 119 | end 120 | 121 | def whisper_ask_wizard(question) 122 | ask "\033[1m\033[36m" + ("choose").rjust(10) + "\033[0m" + " #{question}" 123 | end 124 | 125 | def yes_wizard?(question) 126 | answer = ask_wizard(question + " \033[33m(y/n)\033[0m") 127 | case answer.downcase 128 | when "yes", "y" 129 | true 130 | when "no", "n" 131 | false 132 | else 133 | yes_wizard?(question) 134 | end 135 | end 136 | 137 | def no_wizard?(question); !yes_wizard?(question) end 138 | 139 | def multiple_choice(question, choices) 140 | say_custom('option', "\033[1m\033[36m" + "#{question}\033[0m") 141 | values = {} 142 | choices.each_with_index do |choice,i| 143 | values[(i + 1).to_s] = choice[1] 144 | say_custom( (i + 1).to_s + ')', choice[0] ) 145 | end 146 | answer = whisper_ask_wizard("Enter your selection:") while !values.keys.include?(answer) 147 | values[answer] 148 | end 149 | 150 | @current_recipe = nil 151 | @configs = {} 152 | 153 | @after_blocks = [] 154 | def stage_two(&block); @after_blocks << [@current_recipe, block]; end 155 | @stage_three_blocks = [] 156 | def stage_three(&block); @stage_three_blocks << [@current_recipe, block]; end 157 | @stage_four_blocks = [] 158 | def stage_four(&block); @stage_four_blocks << [@current_recipe, block]; end 159 | @before_configs = {} 160 | def before_config(&block); @before_configs[@current_recipe] = block; end 161 | 162 | def copy_from(source, destination) 163 | begin 164 | remove_file destination 165 | get source, destination 166 | rescue OpenURI::HTTPError 167 | say_wizard "Unable to obtain #{source}" 168 | end 169 | end 170 | 171 | def copy_from_repo(filename, opts = {}) 172 | repo = 'https://raw.github.com/RailsApps/rails-composer/master/files/' 173 | repo = opts[:repo] unless opts[:repo].nil? 174 | if (!opts[:prefs].nil?) && (!prefs.has_value? opts[:prefs]) 175 | return 176 | end 177 | source_filename = filename 178 | destination_filename = filename 179 | unless opts[:prefs].nil? 180 | if filename.include? opts[:prefs] 181 | destination_filename = filename.gsub(/\-#{opts[:prefs]}/, '') 182 | end 183 | end 184 | if (prefer :templates, 'haml') && (filename.include? 'views') 185 | remove_file destination_filename 186 | destination_filename = destination_filename.gsub(/.erb/, '.haml') 187 | end 188 | if (prefer :templates, 'slim') && (filename.include? 'views') 189 | remove_file destination_filename 190 | destination_filename = destination_filename.gsub(/.erb/, '.slim') 191 | end 192 | begin 193 | remove_file destination_filename 194 | if (prefer :templates, 'haml') && (filename.include? 'views') 195 | create_file destination_filename, html_to_haml(repo + source_filename) 196 | elsif (prefer :templates, 'slim') && (filename.include? 'views') 197 | create_file destination_filename, html_to_slim(repo + source_filename) 198 | else 199 | get repo + source_filename, destination_filename 200 | end 201 | rescue OpenURI::HTTPError 202 | say_wizard "Unable to obtain #{source_filename} from the repo #{repo}" 203 | end 204 | end 205 | 206 | def html_to_haml(source) 207 | begin 208 | html = open(source) {|input| input.binmode.read } 209 | Html2haml::HTML.new(html, :erb => true, :xhtml => true).render 210 | rescue RubyParser::SyntaxError 211 | say_wizard "Ignoring RubyParser::SyntaxError" 212 | # special case to accommodate https://github.com/RailsApps/rails-composer/issues/55 213 | html = open(source) {|input| input.binmode.read } 214 | say_wizard "applying patch" if html.include? 'card_month' 215 | say_wizard "applying patch" if html.include? 'card_year' 216 | html = html.gsub(/, {add_month_numbers: true}, {name: nil, id: "card_month"}/, '') 217 | html = html.gsub(/, {start_year: Date\.today\.year, end_year: Date\.today\.year\+10}, {name: nil, id: "card_year"}/, '') 218 | result = Html2haml::HTML.new(html, :erb => true, :xhtml => true).render 219 | result = result.gsub(/select_month nil/, "select_month nil, {add_month_numbers: true}, {name: nil, id: \"card_month\"}") 220 | result = result.gsub(/select_year nil/, "select_year nil, {start_year: Date.today.year, end_year: Date.today.year+10}, {name: nil, id: \"card_year\"}") 221 | end 222 | end 223 | 224 | def html_to_slim(source) 225 | html = open(source) {|input| input.binmode.read } 226 | haml = Html2haml::HTML.new(html, :erb => true, :xhtml => true).render 227 | Haml2Slim.convert!(haml) 228 | end 229 | 230 | # full credit to @mislav in this StackOverflow answer for the #which() method: 231 | # - http://stackoverflow.com/a/5471032 232 | def which(cmd) 233 | exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] 234 | ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| 235 | exts.each do |ext| 236 | exe = "#{path}#{File::SEPARATOR}#{cmd}#{ext}" 237 | return exe if File.executable? exe 238 | end 239 | end 240 | return nil 241 | end 242 | # >-------------------------- templates/helpers.erb --------------------------end< 243 | 244 | say_wizard("\033[1m\033[36m" + "" + "\033[0m") 245 | 246 | say_wizard("\033[1m\033[36m" + ' _____ _ _' + "\033[0m") 247 | say_wizard("\033[1m\033[36m" + "| __ \\ \(_\) | /\\" + "\033[0m") 248 | say_wizard("\033[1m\033[36m" + "| |__) |__ _ _| |___ / \\ _ __ _ __ ___" + "\033[0m") 249 | say_wizard("\033[1m\033[36m" + "| _ /\/ _` | | / __| / /\\ \\ | \'_ \| \'_ \\/ __|" + "\033[0m") 250 | say_wizard("\033[1m\033[36m" + "| | \\ \\ (_| | | \\__ \\/ ____ \\| |_) | |_) \\__ \\" + "\033[0m") 251 | say_wizard("\033[1m\033[36m" + "|_| \\_\\__,_|_|_|___/_/ \\_\\ .__/| .__/|___/" + "\033[0m") 252 | say_wizard("\033[1m\033[36m" + " \| \| \| \|" + "\033[0m") 253 | say_wizard("\033[1m\033[36m" + " \| \| \| \|" + "\033[0m") 254 | say_wizard("\033[1m\033[36m" + '' + "\033[0m") 255 | say_wizard("Need help? Ask on Stack Overflow with the tag \'railsapps.\'") 256 | say_wizard("Your new application will contain diagnostics in its README file.") 257 | 258 | if diagnostics_recipes.sort.include? recipes.sort 259 | diagnostics[:recipes] = 'success' 260 | else 261 | diagnostics[:recipes] = 'fail' 262 | end 263 | 264 | # this application template only supports Rails version 4.1 and newer 265 | case Rails::VERSION::MAJOR.to_s 266 | when "5" 267 | say_wizard "You are using Rails version #{Rails::VERSION::STRING}. Please report any issues." 268 | when "3" 269 | say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer." 270 | raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer." 271 | when "4" 272 | case Rails::VERSION::MINOR.to_s 273 | when "0" 274 | say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer." 275 | raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer." 276 | end 277 | else 278 | say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Use Rails 4.1 or newer." 279 | raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Use Rails 4.1 or newer." 280 | end 281 | 282 | # >---------------------------[ Autoload Modules/Classes ]-----------------------------< 283 | 284 | inject_into_file 'config/application.rb', :after => 'config.autoload_paths += %W(#{config.root}/extras)' do <<-'RUBY' 285 | 286 | config.autoload_paths += %W(#{config.root}/lib) 287 | RUBY 288 | end 289 | 290 | # >---------------------------------[ Recipes ]----------------------------------< 291 | 292 | # >-------------------------- templates/recipe.erb ---------------------------start< 293 | # >---------------------------------[ core ]----------------------------------< 294 | @current_recipe = "core" 295 | @before_configs["core"].call if @before_configs["core"] 296 | say_recipe 'core' 297 | @configs[@current_recipe] = config 298 | # >----------------------------- recipes/core.rb -----------------------------start< 299 | 300 | # Application template recipe for the rails_apps_composer. Change the recipe here: 301 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/core.rb 302 | 303 | ## Git 304 | say_wizard "selected all core recipes" 305 | # >----------------------------- recipes/core.rb -----------------------------end< 306 | # >-------------------------- templates/recipe.erb ---------------------------end< 307 | 308 | # >-------------------------- templates/recipe.erb ---------------------------start< 309 | # >----------------------------------[ git ]----------------------------------< 310 | @current_recipe = "git" 311 | @before_configs["git"].call if @before_configs["git"] 312 | say_recipe 'git' 313 | @configs[@current_recipe] = config 314 | # >----------------------------- recipes/git.rb ------------------------------start< 315 | 316 | # Application template recipe for the rails_apps_composer. Change the recipe here: 317 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/git.rb 318 | 319 | ## Git 320 | say_wizard "initialize git" 321 | prefs[:git] = true unless prefs.has_key? :git 322 | if prefer :git, true 323 | copy_from 'https://raw.github.com/RailsApps/rails-composer/master/files/gitignore.txt', '.gitignore' 324 | git :init 325 | git :add => '-A' 326 | git :commit => '-qm "rails_apps_composer: initial commit"' 327 | else 328 | stage_three do 329 | say_wizard "recipe stage three" 330 | say_wizard "removing .gitignore and .gitkeep files" 331 | git_files = Dir[File.join('**','.gitkeep')] + Dir[File.join('**','.gitignore')] 332 | File.unlink git_files 333 | end 334 | end 335 | # >----------------------------- recipes/git.rb ------------------------------end< 336 | # >-------------------------- templates/recipe.erb ---------------------------end< 337 | 338 | # >-------------------------- templates/recipe.erb ---------------------------start< 339 | # >-------------------------------[ railsapps ]-------------------------------< 340 | @current_recipe = "railsapps" 341 | @before_configs["railsapps"].call if @before_configs["railsapps"] 342 | say_recipe 'railsapps' 343 | @configs[@current_recipe] = config 344 | # >-------------------------- recipes/railsapps.rb ---------------------------start< 345 | 346 | # Application template recipe for the rails_apps_composer. Change the recipe here: 347 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/railsapps.rb 348 | 349 | raise if (defined? defaults) || (defined? preferences) # Shouldn't happen. 350 | if options[:verbose] 351 | print "\nrecipes: ";p recipes 352 | print "\ngems: " ;p gems 353 | print "\nprefs: " ;p prefs 354 | print "\nconfig: " ;p config 355 | end 356 | 357 | case Rails::VERSION::MAJOR.to_s 358 | when "5" 359 | prefs[:apps4] = multiple_choice "Build a starter application?", 360 | [["Build a RailsApps example application", "railsapps"], 361 | ["Contributed applications", "contributed_app"], 362 | ["Custom application (experimental)", "none"]] unless prefs.has_key? :apps4 363 | case prefs[:apps4] 364 | when 'railsapps' 365 | prefs[:apps4] = multiple_choice "Choose a starter application.", 366 | [["learn-rails", "learn-rails"], 367 | ["rails-bootstrap", "rails-bootstrap"], 368 | ["rails-foundation", "rails-foundation"], 369 | ["rails-mailinglist-activejob", "rails-mailinglist-activejob"], 370 | ["rails-omniauth", "rails-omniauth"], 371 | ["rails-devise", "rails-devise"], 372 | ["rails-devise-roles", "rails-devise-roles"], 373 | ["rails-devise-pundit", "rails-devise-pundit"], 374 | ["rails-signup-download", "rails-signup-download"], 375 | ["rails-stripe-checkout", "rails-stripe-checkout"], 376 | ["rails-stripe-coupons", "rails-stripe-coupons"]] 377 | when 'contributed_app' 378 | prefs[:apps4] = multiple_choice "Choose a starter application.", 379 | [["rails-shortcut-app", "rails-shortcut-app"], 380 | ["rails-signup-thankyou", "rails-signup-thankyou"]] 381 | end 382 | when "3" 383 | say_wizard "Please upgrade to Rails 4.1 or newer." 384 | when "4" 385 | case Rails::VERSION::MINOR.to_s 386 | when "0" 387 | say_wizard "Please upgrade to Rails 4.1 or newer." 388 | else 389 | prefs[:apps4] = multiple_choice "Build a starter application?", 390 | [["Build a RailsApps example application", "railsapps"], 391 | ["Contributed applications (none available)", "contributed_app"], 392 | ["Custom application (experimental)", "none"]] unless prefs.has_key? :apps4 393 | case prefs[:apps4] 394 | when 'railsapps' 395 | case Rails::VERSION::MINOR.to_s 396 | when "2" 397 | prefs[:apps4] = multiple_choice "Choose a starter application.", 398 | [["learn-rails", "learn-rails"], 399 | ["rails-bootstrap", "rails-bootstrap"], 400 | ["rails-foundation", "rails-foundation"], 401 | ["rails-mailinglist-activejob", "rails-mailinglist-activejob"], 402 | ["rails-omniauth", "rails-omniauth"], 403 | ["rails-devise", "rails-devise"], 404 | ["rails-devise-roles", "rails-devise-roles"], 405 | ["rails-devise-pundit", "rails-devise-pundit"], 406 | ["rails-signup-download", "rails-signup-download"], 407 | ["rails-stripe-checkout", "rails-stripe-checkout"], 408 | ["rails-stripe-coupons", "rails-stripe-coupons"], 409 | ["rails-stripe-membership-saas", "rails-stripe-membership-saas"]] 410 | else 411 | prefs[:apps4] = multiple_choice "Upgrade to Rails 4.2 for more choices.", 412 | [["learn-rails", "learn-rails"], 413 | ["rails-bootstrap", "rails-bootstrap"], 414 | ["rails-foundation", "rails-foundation"], 415 | ["rails-omniauth", "rails-omniauth"], 416 | ["rails-devise", "rails-devise"], 417 | ["rails-devise-roles", "rails-devise-roles"], 418 | ["rails-devise-pundit", "rails-devise-pundit"]] 419 | end 420 | when 'contributed_app' 421 | prefs[:apps4] = multiple_choice "No contributed applications are available.", 422 | [["create custom application", "railsapps"]] 423 | end 424 | end 425 | end 426 | 427 | unless prefs[:announcements] 428 | say_loud '', 'Get on the mailing list for Rails Composer news?' 429 | prefs[:announcements] = ask_wizard('Enter your email address:') 430 | if prefs[:announcements].present? 431 | system "curl --silent http://mailinglist.railscomposer.com/api -d'visitor[email]=#{prefs[:announcements]}' > /dev/null" 432 | prefs[:announcements] = 'mailinglist' 433 | else 434 | prefs[:announcements] = 'none' 435 | end 436 | end 437 | # >-------------------------- recipes/railsapps.rb ---------------------------end< 438 | # >-------------------------- templates/recipe.erb ---------------------------end< 439 | 440 | # >-------------------------- templates/recipe.erb ---------------------------start< 441 | # >------------------------------[ learn_rails ]------------------------------< 442 | @current_recipe = "learn_rails" 443 | @before_configs["learn_rails"].call if @before_configs["learn_rails"] 444 | say_recipe 'learn_rails' 445 | @configs[@current_recipe] = config 446 | # >------------------------- recipes/learn_rails.rb --------------------------start< 447 | 448 | # Application template recipe for the rails_apps_composer. Change the recipe here: 449 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/learn_rails.rb 450 | 451 | if prefer :apps4, 'learn-rails' 452 | 453 | # preferences 454 | prefs[:authentication] = false 455 | prefs[:authorization] = false 456 | prefs[:dashboard] = 'none' 457 | prefs[:ban_spiders] = false 458 | prefs[:better_errors] = true 459 | prefs[:database] = 'sqlite' 460 | prefs[:deployment] = 'heroku' 461 | prefs[:devise_modules] = false 462 | prefs[:dev_webserver] = 'puma' 463 | prefs[:email] = 'sendgrid' 464 | prefs[:frontend] = 'bootstrap3' 465 | prefs[:layouts] = 'none' 466 | prefs[:pages] = 'none' 467 | prefs[:github] = false 468 | prefs[:git] = true 469 | prefs[:local_env_file] = 'none' 470 | prefs[:prod_webserver] = 'same' 471 | prefs[:pry] = false 472 | prefs[:secrets] = ['owner_email', 'mailchimp_list_id', 'mailchimp_api_key'] 473 | prefs[:templates] = 'erb' 474 | prefs[:tests] = false 475 | prefs[:locale] = 'none' 476 | prefs[:analytics] = 'none' 477 | prefs[:rubocop] = false 478 | prefs[:disable_turbolinks] = false 479 | prefs[:rvmrc] = true 480 | 481 | if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1 482 | prefs[:form_builder] = false 483 | prefs[:jquery] = 'gem' 484 | else 485 | # Rails 5.0 version uses SimpleForm 486 | prefs[:form_builder] = 'simple_form' 487 | add_gem 'minitest-rails-capybara', :group => :test 488 | end 489 | 490 | # gems 491 | add_gem 'high_voltage' 492 | add_gem 'gibbon' 493 | add_gem 'minitest-spec-rails', :group => :test 494 | gsub_file 'Gemfile', /gem 'sqlite3'\n/, '' 495 | add_gem 'sqlite3', :group => :development 496 | 497 | stage_three do 498 | say_wizard "recipe stage three" 499 | repo = 'https://raw.github.com/RailsApps/learn-rails/master/' 500 | 501 | # >-------------------------------[ Models ]--------------------------------< 502 | 503 | copy_from_repo 'app/models/contact.rb', :repo => repo 504 | copy_from_repo 'app/models/visitor.rb', :repo => repo 505 | 506 | # >-------------------------------[ Controllers ]--------------------------------< 507 | 508 | copy_from_repo 'app/controllers/contacts_controller.rb', :repo => repo 509 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 510 | 511 | # >-------------------------------[ Mailers ]--------------------------------< 512 | 513 | generate 'mailer UserMailer' 514 | copy_from_repo 'app/mailers/user_mailer.rb', :repo => repo 515 | 516 | # >-------------------------------[ Views ]--------------------------------< 517 | 518 | if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1 519 | copy_from_repo 'app/views/visitors/new.html.erb', :repo => repo 520 | copy_from_repo 'app/views/contacts/new.html.erb', :repo => repo 521 | else 522 | # Rails 5.0 version uses SimpleForm 523 | copy_from_repo 'app/views/visitors/new.html.erb', :repo => 'https://raw.githubusercontent.com/RailsApps/learn-rails/rails50/' 524 | copy_from_repo 'app/views/contacts/new.html.erb', :repo => 'https://raw.githubusercontent.com/RailsApps/learn-rails/rails50/' 525 | end 526 | 527 | copy_from_repo 'app/views/pages/about.html.erb', :repo => repo 528 | copy_from_repo 'app/views/user_mailer/contact_email.html.erb', :repo => repo 529 | copy_from_repo 'app/views/user_mailer/contact_email.text.erb', :repo => repo 530 | 531 | # create navigation links using the rails_layout gem 532 | generate 'layout:navigation -f' 533 | 534 | # >-------------------------------[ Routes ]--------------------------------< 535 | 536 | copy_from_repo 'config/routes.rb', :repo => repo 537 | 538 | # >-------------------------------[ Assets ]--------------------------------< 539 | 540 | copy_from_repo 'app/assets/javascripts/segment.js', :repo => repo 541 | 542 | # >-------------------------------[ Tests ]--------------------------------< 543 | 544 | copy_from_repo 'test/test_helper.rb', :repo => repo 545 | copy_from_repo 'test/integration/home_page_test.rb', :repo => repo 546 | copy_from_repo 'test/models/visitor_test.rb', :repo => repo 547 | 548 | run 'bundle exec rake db:migrate' 549 | end 550 | end 551 | # >------------------------- recipes/learn_rails.rb --------------------------end< 552 | # >-------------------------- templates/recipe.erb ---------------------------end< 553 | 554 | # >-------------------------- templates/recipe.erb ---------------------------start< 555 | # >----------------------------[ rails_bootstrap ]----------------------------< 556 | @current_recipe = "rails_bootstrap" 557 | @before_configs["rails_bootstrap"].call if @before_configs["rails_bootstrap"] 558 | say_recipe 'rails_bootstrap' 559 | @configs[@current_recipe] = config 560 | # >----------------------- recipes/rails_bootstrap.rb ------------------------start< 561 | 562 | # Application template recipe for the rails_apps_composer. Change the recipe here: 563 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_bootstrap.rb 564 | 565 | if prefer :apps4, 'rails-bootstrap' 566 | prefs[:authentication] = false 567 | prefs[:authorization] = false 568 | prefs[:dashboard] = 'none' 569 | prefs[:better_errors] = true 570 | prefs[:devise_modules] = false 571 | prefs[:email] = 'none' 572 | prefs[:git] = true 573 | prefs[:local_env_file] = false 574 | prefs[:pry] = false 575 | prefs[:pages] = 'about' 576 | prefs[:locale] = 'none' 577 | prefs[:rubocop] = false 578 | prefs[:frontend] = multiple_choice "Front-end framework?", 579 | [["Bootstrap 4.0", "bootstrap4"], ["Bootstrap 3.3", "bootstrap3"]] unless prefs.has_key? :frontend 580 | prefs[:rvmrc] = true 581 | end 582 | # >----------------------- recipes/rails_bootstrap.rb ------------------------end< 583 | # >-------------------------- templates/recipe.erb ---------------------------end< 584 | 585 | # >-------------------------- templates/recipe.erb ---------------------------start< 586 | # >---------------------------[ rails_foundation ]----------------------------< 587 | @current_recipe = "rails_foundation" 588 | @before_configs["rails_foundation"].call if @before_configs["rails_foundation"] 589 | say_recipe 'rails_foundation' 590 | @configs[@current_recipe] = config 591 | # >----------------------- recipes/rails_foundation.rb -----------------------start< 592 | 593 | # Application template recipe for the rails_apps_composer. Change the recipe here: 594 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_foundation.rb 595 | 596 | if prefer :apps4, 'rails-foundation' 597 | prefs[:authentication] = false 598 | prefs[:authorization] = false 599 | prefs[:dashboard] = 'none' 600 | prefs[:better_errors] = true 601 | prefs[:devise_modules] = false 602 | prefs[:email] = 'none' 603 | prefs[:frontend] = 'foundation5' 604 | prefs[:git] = true 605 | prefs[:local_env_file] = false 606 | prefs[:pry] = false 607 | prefs[:pages] = 'about' 608 | prefs[:locale] = 'none' 609 | prefs[:rubocop] = false 610 | prefs[:rvmrc] = true 611 | end 612 | # >----------------------- recipes/rails_foundation.rb -----------------------end< 613 | # >-------------------------- templates/recipe.erb ---------------------------end< 614 | 615 | # >-------------------------- templates/recipe.erb ---------------------------start< 616 | # >----------------------------[ rails_omniauth ]-----------------------------< 617 | @current_recipe = "rails_omniauth" 618 | @before_configs["rails_omniauth"].call if @before_configs["rails_omniauth"] 619 | say_recipe 'rails_omniauth' 620 | @configs[@current_recipe] = config 621 | # >------------------------ recipes/rails_omniauth.rb ------------------------start< 622 | 623 | # Application template recipe for the rails_apps_composer. Change the recipe here: 624 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_omniauth.rb 625 | 626 | if prefer :apps4, 'rails-omniauth' 627 | prefs[:authentication] = 'omniauth' 628 | prefs[:authorization] = 'none' 629 | prefs[:dashboard] = 'none' 630 | prefs[:better_errors] = true 631 | prefs[:email] = 'none' 632 | prefs[:git] = true 633 | prefs[:local_env_file] = false 634 | prefs[:pry] = false 635 | prefs[:pages] = 'about+users' 636 | prefs[:locale] = 'none' 637 | prefs[:rubocop] = false 638 | prefs[:rvmrc] = true 639 | end 640 | # >------------------------ recipes/rails_omniauth.rb ------------------------end< 641 | # >-------------------------- templates/recipe.erb ---------------------------end< 642 | 643 | # >-------------------------- templates/recipe.erb ---------------------------start< 644 | # >-----------------------------[ rails_devise ]------------------------------< 645 | @current_recipe = "rails_devise" 646 | @before_configs["rails_devise"].call if @before_configs["rails_devise"] 647 | say_recipe 'rails_devise' 648 | @configs[@current_recipe] = config 649 | # >------------------------- recipes/rails_devise.rb -------------------------start< 650 | 651 | # Application template recipe for the rails_apps_composer. Change the recipe here: 652 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_devise.rb 653 | 654 | if prefer :apps4, 'rails-devise' 655 | prefs[:authentication] = 'devise' 656 | prefs[:authorization] = false 657 | prefs[:dashboard] = 'none' 658 | prefs[:better_errors] = true 659 | prefs[:git] = true 660 | prefs[:local_env_file] = false 661 | prefs[:pry] = false 662 | prefs[:pages] = 'about+users' 663 | prefs[:locale] = 'none' 664 | prefs[:rubocop] = false 665 | prefs[:rvmrc] = true 666 | end 667 | # >------------------------- recipes/rails_devise.rb -------------------------end< 668 | # >-------------------------- templates/recipe.erb ---------------------------end< 669 | 670 | # >-------------------------- templates/recipe.erb ---------------------------start< 671 | # >--------------------------[ rails_devise_roles ]---------------------------< 672 | @current_recipe = "rails_devise_roles" 673 | @before_configs["rails_devise_roles"].call if @before_configs["rails_devise_roles"] 674 | say_recipe 'rails_devise_roles' 675 | @configs[@current_recipe] = config 676 | # >---------------------- recipes/rails_devise_roles.rb ----------------------start< 677 | 678 | # Application template recipe for the rails_apps_composer. Change the recipe here: 679 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_devise_roles.rb 680 | 681 | if prefer :apps4, 'rails-devise-roles' 682 | prefs[:authentication] = 'devise' 683 | prefs[:authorization] = 'roles' 684 | prefs[:better_errors] = true 685 | prefs[:git] = true 686 | prefs[:local_env_file] = false 687 | prefs[:pry] = false 688 | prefs[:pages] = 'about+users' 689 | prefs[:locale] = 'none' 690 | prefs[:rubocop] = false 691 | prefs[:rvmrc] = true 692 | end 693 | # >---------------------- recipes/rails_devise_roles.rb ----------------------end< 694 | # >-------------------------- templates/recipe.erb ---------------------------end< 695 | 696 | # >-------------------------- templates/recipe.erb ---------------------------start< 697 | # >--------------------------[ rails_devise_pundit ]--------------------------< 698 | @current_recipe = "rails_devise_pundit" 699 | @before_configs["rails_devise_pundit"].call if @before_configs["rails_devise_pundit"] 700 | say_recipe 'rails_devise_pundit' 701 | @configs[@current_recipe] = config 702 | # >--------------------- recipes/rails_devise_pundit.rb ----------------------start< 703 | 704 | # Application template recipe for the rails_apps_composer. Change the recipe here: 705 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_devise_pundit.rb 706 | 707 | if prefer :apps4, 'rails-devise-pundit' 708 | prefs[:authentication] = 'devise' 709 | prefs[:authorization] = 'pundit' 710 | prefs[:better_errors] = true 711 | prefs[:git] = true 712 | prefs[:local_env_file] = false 713 | prefs[:pry] = false 714 | prefs[:pages] = 'about+users' 715 | prefs[:locale] = 'none' 716 | prefs[:rubocop] = false 717 | prefs[:rvmrc] = true 718 | end 719 | # >--------------------- recipes/rails_devise_pundit.rb ----------------------end< 720 | # >-------------------------- templates/recipe.erb ---------------------------end< 721 | 722 | # >-------------------------- templates/recipe.erb ---------------------------start< 723 | # >--------------------------[ rails_shortcut_app ]---------------------------< 724 | @current_recipe = "rails_shortcut_app" 725 | @before_configs["rails_shortcut_app"].call if @before_configs["rails_shortcut_app"] 726 | say_recipe 'rails_shortcut_app' 727 | @configs[@current_recipe] = config 728 | # >---------------------- recipes/rails_shortcut_app.rb ----------------------start< 729 | 730 | # Application template recipe for the rails_apps_composer. Change the recipe here: 731 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_shortcut_app.rb 732 | 733 | if prefer :apps4, 'rails-shortcut-app' 734 | prefs[:authentication] = 'devise' 735 | prefs[:authorization] = 'roles' 736 | prefs[:dashboard] = 'none' 737 | prefs[:ban_spiders] = false 738 | prefs[:better_errors] = true 739 | prefs[:database] = 'sqlite' 740 | prefs[:deployment] = 'none' 741 | prefs[:devise_modules] = false 742 | prefs[:dev_webserver] = 'puma' 743 | prefs[:email] = 'none' 744 | prefs[:frontend] = 'bootstrap3' 745 | prefs[:layouts] = 'none' 746 | prefs[:pages] = 'none' 747 | prefs[:github] = false 748 | prefs[:git] = true 749 | prefs[:local_env_file] = false 750 | prefs[:prod_webserver] = 'same' 751 | prefs[:pry] = false 752 | prefs[:pages] = 'about+users' 753 | prefs[:templates] = 'erb' 754 | prefs[:tests] = 'none' 755 | prefs[:locale] = 'none' 756 | prefs[:analytics] = 'none' 757 | prefs[:rubocop] = false 758 | prefs[:disable_turbolinks] = true 759 | prefs[:rvmrc] = true 760 | prefs[:form_builder] = false 761 | prefs[:jquery] = 'gem' 762 | end 763 | # >---------------------- recipes/rails_shortcut_app.rb ----------------------end< 764 | # >-------------------------- templates/recipe.erb ---------------------------end< 765 | 766 | # >-------------------------- templates/recipe.erb ---------------------------start< 767 | # >-------------------------[ rails_signup_download ]-------------------------< 768 | @current_recipe = "rails_signup_download" 769 | @before_configs["rails_signup_download"].call if @before_configs["rails_signup_download"] 770 | say_recipe 'rails_signup_download' 771 | @configs[@current_recipe] = config 772 | # >-------------------- recipes/rails_signup_download.rb ---------------------start< 773 | 774 | # Application template recipe for the rails_apps_composer. Change the recipe here: 775 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_signup_download.rb 776 | 777 | if prefer :apps4, 'rails-signup-download' 778 | prefs[:authentication] = 'devise' 779 | prefs[:authorization] = 'roles' 780 | prefs[:better_errors] = true 781 | prefs[:devise_modules] = false 782 | prefs[:form_builder] = false 783 | prefs[:git] = true 784 | prefs[:local_env_file] = false 785 | prefs[:pry] = false 786 | prefs[:secrets] = ['mailchimp_list_id', 'mailchimp_api_key'] 787 | prefs[:pages] = 'about+users' 788 | prefs[:locale] = 'none' 789 | prefs[:rubocop] = false 790 | prefs[:rvmrc] = true 791 | 792 | # gems 793 | add_gem 'gibbon' 794 | add_gem 'sucker_punch' 795 | 796 | stage_three do 797 | say_wizard "recipe stage three" 798 | repo = 'https://raw.github.com/RailsApps/rails-signup-download/master/' 799 | 800 | # >-------------------------------[ Config ]---------------------------------< 801 | 802 | copy_from_repo 'config/initializers/active_job.rb', :repo => repo 803 | 804 | # >-------------------------------[ Models ]--------------------------------< 805 | 806 | copy_from_repo 'app/models/user.rb', :repo => repo 807 | 808 | # >-------------------------------[ Controllers ]--------------------------------< 809 | 810 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 811 | copy_from_repo 'app/controllers/products_controller.rb', :repo => repo 812 | 813 | # >-------------------------------[ Jobs ]---------------------------------< 814 | 815 | copy_from_repo 'app/jobs/mailing_list_signup_job.rb', :repo => repo 816 | 817 | # >-------------------------------[ Views ]--------------------------------< 818 | 819 | copy_from_repo 'app/views/visitors/index.html.erb', :repo => repo 820 | copy_from_repo 'app/views/products/product.pdf', :repo => repo 821 | 822 | # >-------------------------------[ Routes ]--------------------------------< 823 | 824 | copy_from_repo 'config/routes.rb', :repo => repo 825 | 826 | # >-------------------------------[ Tests ]--------------------------------< 827 | 828 | copy_from_repo 'spec/features/users/product_acquisition_spec.rb', :repo => repo 829 | copy_from_repo 'spec/controllers/products_controller_spec.rb', :repo => repo 830 | 831 | end 832 | end 833 | # >-------------------- recipes/rails_signup_download.rb ---------------------end< 834 | # >-------------------------- templates/recipe.erb ---------------------------end< 835 | 836 | # >-------------------------- templates/recipe.erb ---------------------------start< 837 | # >-------------------------[ rails_signup_thankyou ]-------------------------< 838 | @current_recipe = "rails_signup_thankyou" 839 | @before_configs["rails_signup_thankyou"].call if @before_configs["rails_signup_thankyou"] 840 | say_recipe 'rails_signup_thankyou' 841 | @configs[@current_recipe] = config 842 | # >-------------------- recipes/rails_signup_thankyou.rb ---------------------start< 843 | 844 | # Application template recipe for the rails_apps_composer. Change the recipe here: 845 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_signup_thankyou.rb 846 | 847 | if prefer :apps4, 'rails-signup-thankyou' 848 | prefs[:authentication] = 'devise' 849 | prefs[:authorization] = 'roles' 850 | prefs[:dashboard] = 'none' 851 | prefs[:ban_spiders] = false 852 | prefs[:better_errors] = true 853 | prefs[:database] = 'sqlite' 854 | prefs[:deployment] = 'none' 855 | prefs[:devise_modules] = false 856 | prefs[:dev_webserver] = 'puma' 857 | prefs[:email] = 'none' 858 | prefs[:frontend] = 'bootstrap3' 859 | prefs[:layouts] = 'none' 860 | prefs[:pages] = 'none' 861 | prefs[:github] = false 862 | prefs[:git] = true 863 | prefs[:local_env_file] = false 864 | prefs[:prod_webserver] = 'same' 865 | prefs[:pry] = false 866 | prefs[:pages] = 'about+users' 867 | prefs[:templates] = 'erb' 868 | prefs[:tests] = 'none' 869 | prefs[:locale] = 'none' 870 | prefs[:analytics] = 'none' 871 | prefs[:rubocop] = false 872 | prefs[:disable_turbolinks] = true 873 | prefs[:rvmrc] = true 874 | prefs[:form_builder] = false 875 | prefs[:jquery] = 'gem' 876 | 877 | stage_three do 878 | say_wizard "recipe stage three" 879 | repo = 'https://raw.github.com/RailsApps/rails-signup-thankyou/master/' 880 | 881 | # >-------------------------------[ Models ]--------------------------------< 882 | 883 | copy_from_repo 'app/models/user.rb', :repo => repo 884 | 885 | # >-------------------------------[ Controllers ]--------------------------------< 886 | 887 | copy_from_repo 'app/controllers/application_controller.rb', :repo => repo 888 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 889 | copy_from_repo 'app/controllers/products_controller.rb', :repo => repo 890 | copy_from_repo 'app/controllers/thank_you_controller.rb', :repo => repo 891 | 892 | # >-------------------------------[ Views ]--------------------------------< 893 | 894 | copy_from_repo 'app/views/visitors/index.html.erb', :repo => repo 895 | copy_from_repo 'app/views/products/product.pdf', :repo => repo 896 | copy_from_repo 'app/views/thank_you/index.html.erb', :repo => repo 897 | 898 | # >-------------------------------[ Routes ]--------------------------------< 899 | 900 | copy_from_repo 'config/routes.rb', :repo => repo 901 | 902 | # >-------------------------------[ Tests ]--------------------------------< 903 | 904 | copy_from_repo 'spec/features/users/product_acquisition_spec.rb', :repo => repo 905 | copy_from_repo 'spec/controllers/products_controller_spec.rb', :repo => repo 906 | 907 | end 908 | end 909 | # >-------------------- recipes/rails_signup_thankyou.rb ---------------------end< 910 | # >-------------------------- templates/recipe.erb ---------------------------end< 911 | 912 | # >-------------------------- templates/recipe.erb ---------------------------start< 913 | # >----------------------[ rails_mailinglist_activejob ]----------------------< 914 | @current_recipe = "rails_mailinglist_activejob" 915 | @before_configs["rails_mailinglist_activejob"].call if @before_configs["rails_mailinglist_activejob"] 916 | say_recipe 'rails_mailinglist_activejob' 917 | @configs[@current_recipe] = config 918 | # >----------------- recipes/rails_mailinglist_activejob.rb ------------------start< 919 | 920 | # Application template recipe for the rails_apps_composer. Change the recipe here: 921 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_mailinglist_activejob.rb 922 | 923 | if prefer :apps4, 'rails-mailinglist-activejob' 924 | prefs[:authentication] = false 925 | prefs[:authorization] = false 926 | prefs[:dashboard] = 'none' 927 | prefs[:better_errors] = true 928 | prefs[:form_builder] = 'simple_form' 929 | prefs[:git] = true 930 | prefs[:local_env_file] = false 931 | prefs[:pry] = false 932 | prefs[:secrets] = ['mailchimp_list_id', 'mailchimp_api_key'] 933 | prefs[:pages] = 'about' 934 | prefs[:locale] = 'none' 935 | prefs[:rubocop] = false 936 | prefs[:rvmrc] = true 937 | 938 | # gems 939 | add_gem 'gibbon' 940 | add_gem 'high_voltage' 941 | add_gem 'sucker_punch' 942 | 943 | stage_two do 944 | say_wizard "recipe stage two" 945 | generate 'model Visitor email:string' 946 | end 947 | 948 | stage_three do 949 | say_wizard "recipe stage three" 950 | repo = 'https://raw.github.com/RailsApps/rails-mailinglist-activejob/master/' 951 | 952 | # >-------------------------------[ Config ]---------------------------------< 953 | 954 | copy_from_repo 'config/initializers/active_job.rb', :repo => repo 955 | 956 | # >-------------------------------[ Models ]--------------------------------< 957 | 958 | copy_from_repo 'app/models/visitor.rb', :repo => repo 959 | 960 | # >-------------------------------[ Controllers ]--------------------------< 961 | 962 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 963 | 964 | # >-------------------------------[ Jobs ]---------------------------------< 965 | 966 | copy_from_repo 'app/jobs/mailing_list_signup_job.rb', :repo => repo 967 | 968 | # >-------------------------------[ Views ]--------------------------------< 969 | 970 | remove_file 'app/views/visitors/index.html.erb' 971 | copy_from_repo 'app/views/visitors/new.html.erb', :repo => repo 972 | 973 | # >-------------------------------[ Routes ]-------------------------------< 974 | 975 | gsub_file 'config/routes.rb', / root to: 'visitors#index'\n/, '' 976 | inject_into_file 'config/routes.rb', " root to: 'visitors#new'\n", :after => "routes.draw do\n" 977 | route = ' resources :visitors, only: [:new, :create]' 978 | inject_into_file 'config/routes.rb', route + "\n", :after => "routes.draw do\n" 979 | 980 | # >-------------------------------[ Tests ]--------------------------------< 981 | 982 | ### tests not implemented 983 | 984 | end 985 | end 986 | # >----------------- recipes/rails_mailinglist_activejob.rb ------------------end< 987 | # >-------------------------- templates/recipe.erb ---------------------------end< 988 | 989 | # >-------------------------- templates/recipe.erb ---------------------------start< 990 | # >-------------------------[ rails_stripe_checkout ]-------------------------< 991 | @current_recipe = "rails_stripe_checkout" 992 | @before_configs["rails_stripe_checkout"].call if @before_configs["rails_stripe_checkout"] 993 | say_recipe 'rails_stripe_checkout' 994 | @configs[@current_recipe] = config 995 | # >-------------------- recipes/rails_stripe_checkout.rb ---------------------start< 996 | 997 | # Application template recipe for the rails_apps_composer. Change the recipe here: 998 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_stripe_checkout.rb 999 | 1000 | if prefer :apps4, 'rails-stripe-checkout' 1001 | prefs[:frontend] = 'bootstrap3' 1002 | prefs[:authentication] = 'devise' 1003 | prefs[:authorization] = 'roles' 1004 | prefs[:better_errors] = true 1005 | prefs[:devise_modules] = false 1006 | prefs[:form_builder] = false 1007 | prefs[:git] = true 1008 | prefs[:local_env_file] = false 1009 | prefs[:pry] = false 1010 | prefs[:secrets] = ['product_price', 1011 | 'product_title', 1012 | 'stripe_publishable_key', 1013 | 'stripe_api_key', 1014 | 'mailchimp_list_id', 1015 | 'mailchimp_api_key'] 1016 | prefs[:pages] = 'about+users' 1017 | prefs[:locale] = 'none' 1018 | prefs[:rubocop] = false 1019 | prefs[:rvmrc] = true 1020 | 1021 | # gems 1022 | add_gem 'gibbon' 1023 | add_gem 'stripe' 1024 | add_gem 'sucker_punch' 1025 | 1026 | stage_three do 1027 | say_wizard "recipe stage three" 1028 | repo = 'https://raw.github.com/RailsApps/rails-stripe-checkout/master/' 1029 | 1030 | # >-------------------------------[ Config ]---------------------------------< 1031 | 1032 | copy_from_repo 'config/initializers/active_job.rb', :repo => repo 1033 | copy_from_repo 'config/initializers/devise_permitted_parameters.rb', :repo => repo 1034 | copy_from_repo 'config/initializers/stripe.rb', :repo => repo 1035 | 1036 | # >-------------------------------[ Assets ]--------------------------------< 1037 | 1038 | copy_from_repo 'app/assets/images/rubyonrails.png', :repo => repo 1039 | 1040 | # >-------------------------------[ Models ]--------------------------------< 1041 | 1042 | copy_from_repo 'app/models/user.rb', :repo => repo 1043 | 1044 | # >-------------------------------[ Controllers ]--------------------------------< 1045 | 1046 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 1047 | copy_from_repo 'app/controllers/products_controller.rb', :repo => repo 1048 | copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo 1049 | 1050 | # >-------------------------------[ Jobs ]---------------------------------< 1051 | 1052 | copy_from_repo 'app/jobs/mailing_list_signup_job.rb', :repo => repo 1053 | 1054 | # >-------------------------------[ Views ]--------------------------------< 1055 | 1056 | copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo 1057 | copy_from_repo 'app/views/visitors/_purchase.html.erb', :repo => repo 1058 | copy_from_repo 'app/views/visitors/index.html.erb', :repo => repo 1059 | copy_from_repo 'app/views/products/product.pdf', :repo => repo 1060 | 1061 | # >-------------------------------[ Routes ]--------------------------------< 1062 | 1063 | copy_from_repo 'config/routes.rb', :repo => repo 1064 | 1065 | # >-------------------------------[ Tests ]--------------------------------< 1066 | 1067 | ### tests not implemented 1068 | 1069 | end 1070 | end 1071 | # >-------------------- recipes/rails_stripe_checkout.rb ---------------------end< 1072 | # >-------------------------- templates/recipe.erb ---------------------------end< 1073 | 1074 | # >-------------------------- templates/recipe.erb ---------------------------start< 1075 | # >-------------------------[ rails_stripe_coupons ]--------------------------< 1076 | @current_recipe = "rails_stripe_coupons" 1077 | @before_configs["rails_stripe_coupons"].call if @before_configs["rails_stripe_coupons"] 1078 | say_recipe 'rails_stripe_coupons' 1079 | @configs[@current_recipe] = config 1080 | # >--------------------- recipes/rails_stripe_coupons.rb ---------------------start< 1081 | 1082 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1083 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_stripe_coupons.rb 1084 | 1085 | if prefer :apps4, 'rails-stripe-coupons' 1086 | prefs[:frontend] = 'bootstrap3' 1087 | prefs[:authentication] = 'devise' 1088 | prefs[:authorization] = 'roles' 1089 | prefs[:better_errors] = true 1090 | prefs[:devise_modules] = false 1091 | prefs[:form_builder] = false 1092 | prefs[:git] = true 1093 | prefs[:local_env_file] = false 1094 | prefs[:pry] = false 1095 | prefs[:secrets] = ['stripe_publishable_key', 1096 | 'stripe_api_key', 1097 | 'product_price', 1098 | 'product_title', 1099 | 'mailchimp_list_id', 1100 | 'mailchimp_api_key'] 1101 | prefs[:pages] = 'about+users' 1102 | prefs[:locale] = 'none' 1103 | prefs[:rubocop] = false 1104 | prefs[:rvmrc] = true 1105 | 1106 | # gems 1107 | add_gem 'gibbon' 1108 | add_gem 'stripe' 1109 | add_gem 'sucker_punch' 1110 | 1111 | stage_three do 1112 | say_wizard "recipe stage three" 1113 | repo = 'https://raw.github.com/RailsApps/rails-stripe-coupons/master/' 1114 | 1115 | # >-------------------------------[ Migrations ]---------------------------------< 1116 | 1117 | generate 'migration AddStripeTokenToUsers stripe_token:string' 1118 | generate 'scaffold Coupon code role mailing_list_id list_group price:integer --no-test-framework --no-helper --no-assets --no-jbuilder' 1119 | generate 'migration AddCouponRefToUsers coupon:references' 1120 | run 'bundle exec rake db:migrate' 1121 | 1122 | # >-------------------------------[ Config ]---------------------------------< 1123 | 1124 | copy_from_repo 'config/initializers/active_job.rb', :repo => repo 1125 | copy_from_repo 'config/initializers/stripe.rb', :repo => repo 1126 | 1127 | # >-------------------------------[ Assets ]--------------------------------< 1128 | 1129 | copy_from_repo 'app/assets/images/rubyonrails.png', :repo => repo 1130 | 1131 | # >-------------------------------[ Controllers ]--------------------------------< 1132 | 1133 | copy_from_repo 'app/controllers/coupons_controller.rb', :repo => repo 1134 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 1135 | copy_from_repo 'app/controllers/products_controller.rb', :repo => repo 1136 | copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo 1137 | 1138 | # >-------------------------------[ Helpers ]--------------------------------< 1139 | 1140 | copy_from_repo 'app/helpers/application_helper.rb', :repo => repo 1141 | 1142 | # >-------------------------------[ Jobs ]---------------------------------< 1143 | 1144 | copy_from_repo 'app/jobs/mailing_list_signup_job.rb', :repo => repo 1145 | copy_from_repo 'app/jobs/payment_job.rb', :repo => repo 1146 | 1147 | # >-------------------------------[ Mailers ]--------------------------------< 1148 | 1149 | copy_from_repo 'app/mailers/application_mailer.rb', :repo => repo 1150 | copy_from_repo 'app/mailers/payment_failure_mailer.rb', :repo => repo 1151 | 1152 | # >-------------------------------[ Models ]--------------------------------< 1153 | 1154 | copy_from_repo 'app/models/coupon.rb', :repo => repo 1155 | copy_from_repo 'app/models/user.rb', :repo => repo 1156 | 1157 | # >-------------------------------[ Services ]---------------------------------< 1158 | 1159 | copy_from_repo 'app/services/create_couponcodes_service.rb', :repo => repo 1160 | copy_from_repo 'app/services/mailing_list_signup_service.rb', :repo => repo 1161 | copy_from_repo 'app/services/make_payment_service.rb', :repo => repo 1162 | 1163 | # >-------------------------------[ Views ]--------------------------------< 1164 | 1165 | copy_from_repo 'app/views/coupons/_form.html.erb', :repo => repo 1166 | copy_from_repo 'app/views/coupons/edit.html.erb', :repo => repo 1167 | copy_from_repo 'app/views/coupons/index.html.erb', :repo => repo 1168 | copy_from_repo 'app/views/coupons/new.html.erb', :repo => repo 1169 | copy_from_repo 'app/views/coupons/show.html.erb', :repo => repo 1170 | copy_from_repo 'app/views/devise/registrations/_javascript.html.erb', :repo => repo 1171 | copy_from_repo 'app/views/devise/registrations/edit.html.erb', :repo => repo 1172 | copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo 1173 | copy_from_repo 'app/views/layouts/_navigation_links.html.erb', :repo => repo 1174 | copy_from_repo 'app/views/layouts/application.html.erb', :repo => repo 1175 | copy_from_repo 'app/views/layouts/mailer.html.erb', :repo => repo 1176 | copy_from_repo 'app/views/layouts/mailer.text.erb', :repo => repo 1177 | copy_from_repo 'app/views/pages/downloads.html.erb', :repo => repo 1178 | copy_from_repo 'app/views/payment_failure_mailer/failed_payment_email.html.erb', :repo => repo 1179 | copy_from_repo 'app/views/payment_failure_mailer/failed_payment_email.text.erb', :repo => repo 1180 | copy_from_repo 'app/views/users/show.html.erb', :repo => repo 1181 | copy_from_repo 'app/views/visitors/_purchase.html.erb', :repo => repo 1182 | copy_from_repo 'app/views/visitors/index.html.erb', :repo => repo 1183 | copy_from_repo 'app/views/products/product.pdf', :repo => repo 1184 | copy_from_repo 'public/offer.html', :repo => repo 1185 | 1186 | # >-------------------------------[ Routes ]--------------------------------< 1187 | 1188 | copy_from_repo 'config/routes.rb', :repo => repo 1189 | 1190 | # >-------------------------------[ Tests ]--------------------------------< 1191 | 1192 | ### tests not implemented 1193 | 1194 | end 1195 | end 1196 | # >--------------------- recipes/rails_stripe_coupons.rb ---------------------end< 1197 | # >-------------------------- templates/recipe.erb ---------------------------end< 1198 | 1199 | # >-------------------------- templates/recipe.erb ---------------------------start< 1200 | # >---------------------[ rails_stripe_membership_saas ]----------------------< 1201 | @current_recipe = "rails_stripe_membership_saas" 1202 | @before_configs["rails_stripe_membership_saas"].call if @before_configs["rails_stripe_membership_saas"] 1203 | say_recipe 'rails_stripe_membership_saas' 1204 | @configs[@current_recipe] = config 1205 | # >----------------- recipes/rails_stripe_membership_saas.rb -----------------start< 1206 | 1207 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1208 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rails_stripe_membership_saas.rb 1209 | 1210 | if prefer :apps4, 'rails-stripe-membership-saas' 1211 | prefs[:frontend] = 'bootstrap3' 1212 | prefs[:authentication] = 'devise' 1213 | prefs[:authorization] = 'roles' 1214 | prefs[:better_errors] = true 1215 | prefs[:devise_modules] = false 1216 | prefs[:form_builder] = false 1217 | prefs[:git] = true 1218 | prefs[:local_env_file] = false 1219 | prefs[:pry] = false 1220 | prefs[:disable_turbolinks] = true 1221 | prefs[:secrets] = ['stripe_publishable_key', 1222 | 'stripe_api_key', 1223 | 'mailchimp_list_id', 1224 | 'mailchimp_api_key'] 1225 | prefs[:pages] = 'about+users' 1226 | prefs[:locale] = 'none' 1227 | prefs[:rubocop] = false 1228 | prefs[:rvmrc] = true 1229 | 1230 | # gems 1231 | add_gem 'gibbon' 1232 | add_gem 'payola-payments' 1233 | add_gem 'sucker_punch' 1234 | 1235 | stage_three do 1236 | say_wizard "recipe stage three" 1237 | repo = 'https://raw.github.com/RailsApps/rails-stripe-membership-saas/master/' 1238 | 1239 | # >-------------------------------[ Migrations ]---------------------------------< 1240 | 1241 | generate 'payola:install' 1242 | generate 'model Plan name stripe_id interval amount:integer --no-test-framework' 1243 | generate 'migration AddPlanRefToUsers plan:references' 1244 | generate 'migration RemoveNameFromUsers name' 1245 | run 'bundle exec rake db:migrate' 1246 | 1247 | # >-------------------------------[ Config ]---------------------------------< 1248 | 1249 | copy_from_repo 'config/initializers/active_job.rb', :repo => repo 1250 | copy_from_repo 'config/initializers/payola.rb', :repo => repo 1251 | copy_from_repo 'db/seeds.rb', :repo => repo 1252 | 1253 | # >-------------------------------[ Assets ]--------------------------------< 1254 | 1255 | copy_from_repo 'app/assets/stylesheets/pricing.css.scss', :repo => repo 1256 | 1257 | # >-------------------------------[ Controllers ]--------------------------------< 1258 | 1259 | copy_from_repo 'app/controllers/application_controller.rb', :repo => repo 1260 | copy_from_repo 'app/controllers/content_controller.rb', :repo => repo 1261 | copy_from_repo 'app/controllers/visitors_controller.rb', :repo => repo 1262 | copy_from_repo 'app/controllers/products_controller.rb', :repo => repo 1263 | copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo 1264 | 1265 | # >-------------------------------[ Jobs ]---------------------------------< 1266 | 1267 | copy_from_repo 'app/jobs/mailing_list_signup_job.rb', :repo => repo 1268 | 1269 | # >-------------------------------[ Mailers ]--------------------------------< 1270 | 1271 | copy_from_repo 'app/mailers/application_mailer.rb', :repo => repo 1272 | copy_from_repo 'app/mailers/user_mailer.rb', :repo => repo 1273 | 1274 | # >-------------------------------[ Models ]--------------------------------< 1275 | 1276 | copy_from_repo 'app/models/plan.rb', :repo => repo 1277 | copy_from_repo 'app/models/user.rb', :repo => repo 1278 | 1279 | # >-------------------------------[ Services ]---------------------------------< 1280 | 1281 | copy_from_repo 'app/services/create_plan_service.rb', :repo => repo 1282 | 1283 | # >-------------------------------[ Views ]--------------------------------< 1284 | 1285 | copy_from_repo 'app/views/content/gold.html.erb', :repo => repo 1286 | copy_from_repo 'app/views/content/platinum.html.erb', :repo => repo 1287 | copy_from_repo 'app/views/content/silver.html.erb', :repo => repo 1288 | copy_from_repo 'app/views/devise/registrations/edit.html.erb', :repo => repo 1289 | copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo 1290 | copy_from_repo 'app/views/layouts/_navigation_links.html.erb', :repo => repo 1291 | copy_from_repo 'app/views/layouts/application.html.erb', :repo => repo 1292 | copy_from_repo 'app/views/layouts/mailer.html.erb', :repo => repo 1293 | copy_from_repo 'app/views/layouts/mailer.text.erb', :repo => repo 1294 | copy_from_repo 'app/views/user_mailer/expire_email.html.erb', :repo => repo 1295 | copy_from_repo 'app/views/user_mailer/expire_email.text.erb', :repo => repo 1296 | copy_from_repo 'app/views/visitors/index.html.erb', :repo => repo 1297 | copy_from_repo 'app/views/products/product.pdf', :repo => repo 1298 | 1299 | # >-------------------------------[ Routes ]--------------------------------< 1300 | 1301 | copy_from_repo 'config/routes.rb', :repo => repo 1302 | 1303 | # >-------------------------------[ Tests ]--------------------------------< 1304 | 1305 | ### tests not implemented 1306 | 1307 | end 1308 | end 1309 | # >----------------- recipes/rails_stripe_membership_saas.rb -----------------end< 1310 | # >-------------------------- templates/recipe.erb ---------------------------end< 1311 | 1312 | # >-------------------------- templates/recipe.erb ---------------------------start< 1313 | # >---------------------------------[ setup ]---------------------------------< 1314 | @current_recipe = "setup" 1315 | @before_configs["setup"].call if @before_configs["setup"] 1316 | say_recipe 'setup' 1317 | @configs[@current_recipe] = config 1318 | # >---------------------------- recipes/setup.rb -----------------------------start< 1319 | 1320 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1321 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/setup.rb 1322 | 1323 | ## Ruby on Rails 1324 | HOST_OS = RbConfig::CONFIG['host_os'] 1325 | say_wizard "Your operating system is #{HOST_OS}." 1326 | say_wizard "You are using Ruby version #{RUBY_VERSION}." 1327 | say_wizard "You are using Rails version #{Rails::VERSION::STRING}." 1328 | 1329 | ## Is sqlite3 in the Gemfile? 1330 | gemfile = File.read(destination_root() + '/Gemfile') 1331 | sqlite_detected = gemfile.include? 'sqlite3' 1332 | 1333 | ## Web Server 1334 | prefs[:dev_webserver] = multiple_choice "Web server for development?", [["Puma (default)", "puma"], 1335 | ["Thin", "thin"], ["Unicorn", "unicorn"], ["Phusion Passenger (Apache/Nginx)", "passenger"], 1336 | ["Phusion Passenger (Standalone)", "passenger_standalone"]] unless prefs.has_key? :dev_webserver 1337 | prefs[:prod_webserver] = multiple_choice "Web server for production?", [["Same as development", "same"], 1338 | ["Thin", "thin"], ["Unicorn", "unicorn"], ["Phusion Passenger (Apache/Nginx)", "passenger"], 1339 | ["Phusion Passenger (Standalone)", "passenger_standalone"]] unless prefs.has_key? :prod_webserver 1340 | prefs[:prod_webserver] = prefs[:dev_webserver] if prefs[:prod_webserver] == 'same' 1341 | 1342 | ## Database Adapter 1343 | prefs[:database] = "sqlite" if prefer :database, 'default' 1344 | prefs[:database] = multiple_choice "Database used in development?", [["SQLite", "sqlite"], ["PostgreSQL", "postgresql"], 1345 | ["MySQL", "mysql"]] unless prefs.has_key? :database 1346 | 1347 | ## Template Engine 1348 | prefs[:templates] = multiple_choice "Template engine?", [["ERB", "erb"], ["Haml", "haml"], ["Slim", "slim"]] unless prefs.has_key? :templates 1349 | 1350 | ## Testing Framework 1351 | if recipes.include? 'tests' 1352 | prefs[:tests] = multiple_choice "Test framework?", [["None", "none"], 1353 | ["RSpec", "rspec"]] unless prefs.has_key? :tests 1354 | case prefs[:tests] 1355 | when 'rspec' 1356 | say_wizard "Adding DatabaseCleaner, FactoryGirl, Faker, Launchy, Selenium" 1357 | prefs[:continuous_testing] = multiple_choice "Continuous testing?", [["None", "none"], ["Guard", "guard"]] unless prefs.has_key? :continuous_testing 1358 | end 1359 | end 1360 | 1361 | ## Front-end Framework 1362 | if recipes.include? 'frontend' 1363 | prefs[:frontend] = multiple_choice "Front-end framework?", [["None", "none"], 1364 | ["Bootstrap 4.0", "bootstrap4"], ["Bootstrap 3.3", "bootstrap3"], ["Bootstrap 2.3", "bootstrap2"], 1365 | ["Zurb Foundation 5.5", "foundation5"], ["Zurb Foundation 4.0", "foundation4"], 1366 | ["Simple CSS", "simple"]] unless prefs.has_key? :frontend 1367 | end 1368 | 1369 | ## jQuery 1370 | if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1 1371 | if prefs[:frontend] == 'none' 1372 | prefs[:jquery] = multiple_choice "Add jQuery?", [["No", "none"], 1373 | ["Add jquery-rails gem", "gem"], 1374 | ["Add using yarn", "yarn"]] unless prefs.has_key? :jquery 1375 | else 1376 | prefs[:jquery] = multiple_choice "How to install jQuery?", 1377 | [["Add jquery-rails gem", "gem"], 1378 | ["Add using yarn", "yarn"]] unless prefs.has_key? :jquery 1379 | end 1380 | end 1381 | 1382 | ## Email 1383 | if recipes.include? 'email' 1384 | unless prefs.has_key? :email 1385 | say_wizard "The Devise 'forgot password' feature requires email." if prefer :authentication, 'devise' 1386 | prefs[:email] = multiple_choice "Add support for sending email?", [["None", "none"], ["Gmail","gmail"], ["SMTP","smtp"], 1387 | ["SendGrid","sendgrid"], ["Mandrill","mandrill"]] 1388 | end 1389 | else 1390 | prefs[:email] = 'none' 1391 | end 1392 | 1393 | ## Authentication and Authorization 1394 | if (recipes.include? 'devise') || (recipes.include? 'omniauth') 1395 | prefs[:authentication] = multiple_choice "Authentication?", [["None", "none"], ["Devise", "devise"], ["OmniAuth", "omniauth"]] unless prefs.has_key? :authentication 1396 | case prefs[:authentication] 1397 | when 'devise' 1398 | prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"], 1399 | ["Devise with Confirmable module","confirmable"], 1400 | ["Devise with Confirmable and Invitable modules","invitable"]] unless prefs.has_key? :devise_modules 1401 | when 'omniauth' 1402 | prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"], 1403 | ["LinkedIn", "linkedin"], ["Google-Oauth-2", "google_oauth2"], ["Tumblr", "tumblr"]] unless prefs.has_key? :omniauth_provider 1404 | end 1405 | prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["Simple role-based", "roles"], ["Pundit", "pundit"]] unless prefs.has_key? :authorization 1406 | if prefer :authentication, 'devise' 1407 | if (prefer :authorization, 'roles') || (prefer :authorization, 'pundit') 1408 | prefs[:dashboard] = multiple_choice "Admin interface for database?", [["None", "none"], 1409 | ["Thoughtbot Administrate", "administrate"]] unless prefs.has_key? :dashboard 1410 | end 1411 | end 1412 | end 1413 | 1414 | ## Form Builder 1415 | ## (no simple_form for Bootstrap 4 yet) 1416 | unless prefs[:frontend] == 'bootstrap4' 1417 | prefs[:form_builder] = multiple_choice "Use a form builder gem?", [["None", "none"], ["SimpleForm", "simple_form"]] unless prefs.has_key? :form_builder 1418 | end 1419 | 1420 | ## Pages 1421 | if recipes.include? 'pages' 1422 | prefs[:pages] = multiple_choice "Add pages?", [["None", "none"], 1423 | ["Home", "home"], ["Home and About", "about"], 1424 | ["Home and Users", "users"], 1425 | ["Home, About, and Users", "about+users"]] unless prefs.has_key? :pages 1426 | end 1427 | 1428 | ## Bootstrap Page Templates 1429 | if recipes.include? 'pages' 1430 | if prefs[:frontend] == 'bootstrap3' 1431 | say_wizard "Which Bootstrap page template? Visit startbootstrap.com." 1432 | prefs[:layouts] = multiple_choice "Add Bootstrap page templates?", [["None", "none"], 1433 | ["1 Col Portfolio", "one_col_portfolio"], 1434 | ["2 Col Portfolio", "two_col_portfolio"], 1435 | ["3 Col Portfolio", "three_col_portfolio"], 1436 | ["4 Col Portfolio", "four_col_portfolio"], 1437 | ["Bare", "bare"], 1438 | ["Blog Home", "blog_home"], 1439 | ["Business Casual", "business_casual"], 1440 | ["Business Frontpage", "business_frontpage"], 1441 | ["Clean Blog", "clean_blog"], 1442 | ["Full Width Pics", "full_width_pics"], 1443 | ["Heroic Features", "heroic_features"], 1444 | ["Landing Page", "landing_page"], 1445 | ["Modern Business", "modern_business"], 1446 | ["One Page Wonder", "one_page_wonder"], 1447 | ["Portfolio Item", "portfolio_item"], 1448 | ["Round About", "round_about"], 1449 | ["Shop Homepage", "shop_homepage"], 1450 | ["Shop Item", "shop_item"], 1451 | ["Simple Sidebar", "simple_sidebar"], 1452 | ["Small Business", "small_business"], 1453 | ["Stylish Portfolio", "stylish_portfolio"], 1454 | ["The Big Picture", "the_big_picture"], 1455 | ["Thumbnail Gallery", "thumbnail_gallery"]] unless prefs.has_key? :layouts 1456 | end 1457 | end 1458 | 1459 | # save configuration before anything can fail 1460 | create_file 'config/railscomposer.yml', "# This application was generated with Rails Composer\n\n" 1461 | append_to_file 'config/railscomposer.yml' do <<-TEXT 1462 | development: 1463 | apps4: #{prefs[:apps4]} 1464 | announcements: #{prefs[:announcements]} 1465 | dev_webserver: #{prefs[:dev_webserver]} 1466 | prod_webserver: #{prefs[:prod_webserver]} 1467 | database: #{prefs[:database]} 1468 | templates: #{prefs[:templates]} 1469 | tests: #{prefs[:tests]} 1470 | continuous_testing: #{prefs[:continuous_testing]} 1471 | frontend: #{prefs[:frontend]} 1472 | email: #{prefs[:email]} 1473 | authentication: #{prefs[:authentication]} 1474 | devise_modules: #{prefs[:devise_modules]} 1475 | omniauth_provider: #{prefs[:omniauth_provider]} 1476 | authorization: #{prefs[:authorization]} 1477 | form_builder: #{prefs[:form_builder]} 1478 | pages: #{prefs[:pages]} 1479 | layouts: #{prefs[:layouts]} 1480 | locale: #{prefs[:locale]} 1481 | analytics: #{prefs[:analytics]} 1482 | deployment: #{prefs[:deployment]} 1483 | ban_spiders: #{prefs[:ban_spiders]} 1484 | github: #{prefs[:github]} 1485 | local_env_file: #{prefs[:local_env_file]} 1486 | better_errors: #{prefs[:better_errors]} 1487 | pry: #{prefs[:pry]} 1488 | rvmrc: #{prefs[:rvmrc]} 1489 | dashboard: #{prefs[:dashboard]} 1490 | TEXT 1491 | end 1492 | # >---------------------------- recipes/setup.rb -----------------------------end< 1493 | # >-------------------------- templates/recipe.erb ---------------------------end< 1494 | 1495 | # >-------------------------- templates/recipe.erb ---------------------------start< 1496 | # >--------------------------------[ locale ]---------------------------------< 1497 | @current_recipe = "locale" 1498 | @before_configs["locale"].call if @before_configs["locale"] 1499 | say_recipe 'locale' 1500 | @configs[@current_recipe] = config 1501 | # >---------------------------- recipes/locale.rb ----------------------------start< 1502 | 1503 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1504 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/locale.rb 1505 | 1506 | unless prefs[:locale] 1507 | prefs[:locale] = ask_wizard('Set a locale? Enter nothing for English, or es, de, etc:') 1508 | prefs[:locale] = 'none' unless prefs[:locale].present? 1509 | end 1510 | 1511 | unless prefer :locale, 'none' 1512 | add_gem 'devise-i18n' if prefer :authentication, 'devise' 1513 | end 1514 | 1515 | stage_two do 1516 | unless prefer :locale, 'none' 1517 | locale_for_app = prefs[:locale].include?('-') ? "'#{prefs[:locale]}'" : prefs[:locale] 1518 | gsub_file 'config/application.rb', /# config.i18n.default_locale.*$/, "config.i18n.default_locale = :#{locale_for_app}" 1519 | locale_filename = "config/locales/#{prefs[:locale]}.yml" 1520 | create_file locale_filename 1521 | append_to_file locale_filename, "#{prefs[:locale]}:" 1522 | end 1523 | end 1524 | # >---------------------------- recipes/locale.rb ----------------------------end< 1525 | # >-------------------------- templates/recipe.erb ---------------------------end< 1526 | 1527 | # >-------------------------- templates/recipe.erb ---------------------------start< 1528 | # >--------------------------------[ readme ]---------------------------------< 1529 | @current_recipe = "readme" 1530 | @before_configs["readme"].call if @before_configs["readme"] 1531 | say_recipe 'readme' 1532 | @configs[@current_recipe] = config 1533 | # >---------------------------- recipes/readme.rb ----------------------------start< 1534 | 1535 | # Application template recipe for the rails_apps_composer. Change the recipe here: 1536 | # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/readme.rb 1537 | 1538 | stage_three do 1539 | say_wizard "recipe stage three" 1540 | 1541 | # remove default READMEs 1542 | %w{ 1543 | README 1544 | README.rdoc 1545 | doc/README_FOR_APP 1546 | }.each { |file| remove_file file } 1547 | 1548 | # add diagnostics to README 1549 | create_file 'README', "#{app_name.humanize.titleize}\n================\n\n" 1550 | append_to_file 'README' do <<-TEXT 1551 | Rails Composer is supported by developers who purchase our RailsApps tutorials. 1552 | Need help? Ask on Stack Overflow with the tag 'railsapps.' 1553 | Problems? Submit an issue: https://github.com/RailsApps/rails_apps_composer/issues 1554 | Your application contains diagnostics in this README file. 1555 | Please provide a copy of this README file when reporting any issues. 1556 | \n 1557 | TEXT 1558 | end 1559 | append_to_file 'README' do <<-TEXT 1560 | option Build a starter application? 1561 | choose Enter your selection: [#{prefs[:apps4]}] 1562 | option Get on the mailing list for Rails Composer news? 1563 | choose Enter your selection: [#{prefs[:announcements]}] 1564 | option Web server for development? 1565 | choose Enter your selection: [#{prefs[:dev_webserver]}] 1566 | option Web server for production? 1567 | choose Enter your selection: [#{prefs[:prod_webserver]}] 1568 | option Database used in development? 1569 | choose Enter your selection: [#{prefs[:database]}] 1570 | option Template engine? 1571 | choose Enter your selection: [#{prefs[:templates]}] 1572 | option Test framework? 1573 | choose Enter your selection: [#{prefs[:tests]}] 1574 | option Continuous testing? 1575 | choose Enter your selection: [#{prefs[:continuous_testing]}] 1576 | option Front-end framework? 1577 | choose Enter your selection: [#{prefs[:frontend]}] 1578 | option Add support for sending email? 1579 | choose Enter your selection: [#{prefs[:email]}] 1580 | option Authentication? 1581 | choose Enter your selection: [#{prefs[:authentication]}] 1582 | option Devise modules? 1583 | choose Enter your selection: [#{prefs[:devise_modules]}] 1584 | option OmniAuth provider? 1585 | choose Enter your selection: [#{prefs[:omniauth_provider]}] 1586 | option Authorization? 1587 | choose Enter your selection: [#{prefs[:authorization]}] 1588 | option Use a form builder gem? 1589 | choose Enter your selection: [#{prefs[:form_builder]}] 1590 | option Add pages? 1591 | choose Enter your selection: [#{prefs[:pages]}] 1592 | option Set a locale? 1593 | choose Enter your selection: [#{prefs[:locale]}] 1594 | option Install page-view analytics? 1595 | choose Enter your selection: [#{prefs[:analytics]}] 1596 | option Add a deployment mechanism? 1597 | choose Enter your selection: [#{prefs[:deployment]}] 1598 | option Set a robots.txt file to ban spiders? 1599 | choose Enter your selection: [#{prefs[:ban_spiders]}] 1600 | option Create a GitHub repository? (y/n) 1601 | choose Enter your selection: [#{prefs[:github]}] 1602 | option Add gem and file for environment variables? 1603 | choose Enter your selection: [#{prefs[:local_env_file]}] 1604 | option Improve error reporting with 'better_errors' during development? 1605 | choose Enter your selection: [#{prefs[:better_errors]}] 1606 | option Use 'pry' as console replacement during development and test? 1607 | choose Enter your selection: [#{prefs[:pry]}] 1608 | option Use or create a project-specific rvm gemset? 1609 | choose Enter your selection: [#{prefs[:rvmrc]}] 1610 | TEXT 1611 | end 1612 | 1613 | create_file 'public/humans.txt' do <<-TEXT 1614 | /* the humans responsible & colophon */ 1615 | /* humanstxt.org */ 1616 | 1617 | 1618 | /* TEAM */ 1619 |
Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.
14 | <%= link_to "Back", :back %> 15 | -------------------------------------------------------------------------------- /files/app/views/devise/registrations/edit.html.erb: -------------------------------------------------------------------------------- 1 |<%= f.label :name %>
6 | <%= f.text_field :name %>
Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.
26 | 27 | <%= link_to "Back", :back %> 28 | -------------------------------------------------------------------------------- /files/app/views/devise/registrations/new-simple_form.html.erb: -------------------------------------------------------------------------------- 1 |<%= f.label :name %>
6 | <%= f.text_field :name %>
<%= user.name %> <%= link_to root_url(:subdomain => user.name), root_url(:subdomain => user.name) %>
4 | <% end %> 5 | -------------------------------------------------------------------------------- /files/app/views/home/index.html.erb: -------------------------------------------------------------------------------- 1 |Username | 7 |Registered | 9 |Role | 10 |11 | | 12 | | |
---|---|---|---|---|---|
<%= link_to user.name, user %> | 18 |<%= user.email %> | 19 |<%= user.created_at.to_date %> | 20 |<%= user.roles.first.name.titleize unless user.roles.first.nil? %> | 21 |22 | Change role 23 | <%= render user %> 24 | | 25 |<%= link_to("Delete user", user_path(user), :data => { :confirm => "Are you sure?" }, :method => :delete, :class => 'btn btn-mini') unless user == current_user %> | 26 |
User: <%= @user.name %>
2 |Email: <%= @user.email if @user.email %>
3 |Profile: <%= link_to root_url(:subdomain => @user.name), root_url(:subdomain => @user.name) %>
4 | -------------------------------------------------------------------------------- /files/app/views/users/show.html.erb: -------------------------------------------------------------------------------- 1 |User: <%= @user.name %>
3 |Email: <%= @user.email if @user.email %>
4 | <%= link_to 'Edit account', edit_user_path %> 5 | -------------------------------------------------------------------------------- /files/config/database-mysql.yml: -------------------------------------------------------------------------------- 1 | # MySQL. Versions 4.1 and 5.0 are recommended. 2 | # 3 | # Install the MYSQL driver 4 | # gem install mysql2 5 | # 6 | # Ensure the MySQL gem is defined in your Gemfile 7 | # gem 'mysql2' 8 | # 9 | # And be sure to use new-style password hashing: 10 | # http://dev.mysql.com/doc/refman/5.0/en/old-client.html 11 | development: 12 | adapter: mysql2 13 | encoding: utf8 14 | reconnect: false 15 | database: myapp_development 16 | pool: 5 17 | username: root 18 | password: 19 | host: localhost 20 | 21 | # Warning: The database defined as "test" will be erased and 22 | # re-generated from your development database when you run "rake". 23 | # Do not set this db to the same as development or production. 24 | test: 25 | adapter: mysql2 26 | encoding: utf8 27 | reconnect: false 28 | database: myapp_test 29 | pool: 5 30 | username: root 31 | password: 32 | host: localhost 33 | 34 | production: 35 | adapter: mysql2 36 | encoding: utf8 37 | reconnect: false 38 | database: myapp_production 39 | pool: 5 40 | username: root 41 | password: 42 | host: localhost 43 | -------------------------------------------------------------------------------- /files/config/database-postgresql.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 8.2 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On Mac OS X with macports: 6 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 7 | # On Windows: 8 | # gem install pg 9 | # Choose the win32 build. 10 | # Install PostgreSQL and put its /bin directory on your path. 11 | # 12 | # Configure Using Gemfile 13 | # gem 'pg' 14 | # 15 | development: 16 | adapter: postgresql 17 | host: localhost 18 | encoding: unicode 19 | database: myapp_development 20 | pool: 5 21 | username: myapp 22 | password: 23 | template: template0 24 | 25 | # Connect on a TCP socket. Omitted by default since the client uses a 26 | # domain socket that doesn't need configuration. Windows does not have 27 | # domain sockets, so uncomment these lines. 28 | #host: localhost 29 | #port: 5432 30 | 31 | # Schema search path. The server defaults to $user,public 32 | #schema_search_path: myapp,sharedapp,public 33 | 34 | # Minimum log levels, in increasing order: 35 | # debug5, debug4, debug3, debug2, debug1, 36 | # log, notice, warning, error, fatal, and panic 37 | # The server defaults to notice. 38 | #min_messages: warning 39 | 40 | # Warning: The database defined as "test" will be erased and 41 | # re-generated from your development database when you run "rake". 42 | # Do not set this db to the same as development or production. 43 | test: 44 | adapter: postgresql 45 | host: localhost 46 | encoding: unicode 47 | database: myapp_test 48 | pool: 5 49 | username: myapp 50 | password: 51 | template: template0 52 | 53 | production: 54 | adapter: postgresql 55 | host: localhost 56 | encoding: unicode 57 | database: myapp_production 58 | pool: 5 59 | username: myapp 60 | password: 61 | template: template0 62 | -------------------------------------------------------------------------------- /files/config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rails secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | # If you are using Rails 5.2 or newer, consider using the 14 | # encrypted credentials feature described here: 15 | # http://edgeguides.rubyonrails.org/security.html#custom-credentials 16 | 17 | development: 18 | secret_key_base: very_long_random_string 19 | 20 | test: 21 | secret_key_base: very_long_random_string 22 | 23 | # Do not keep production secrets in the repository, 24 | # instead read values from the environment. 25 | production: 26 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 27 | -------------------------------------------------------------------------------- /files/gitignore.txt: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------------------- 2 | # Ignore these files when committing to a git repository. 3 | # 4 | # See http://help.github.com/ignore-files/ for more about ignoring files. 5 | # 6 | # The original version of this file is found here: 7 | # https://github.com/RailsApps/rails-composer/blob/master/files/gitignore.txt 8 | # 9 | # Corrections? Improvements? Create a GitHub issue: 10 | # http://github.com/RailsApps/rails-composer/issues 11 | #---------------------------------------------------------------------------- 12 | 13 | # bundler state 14 | /.bundle 15 | /vendor/bundle/ 16 | /vendor/ruby/ 17 | 18 | # minimal Rails specific artifacts 19 | db/*.sqlite3 20 | /db/*.sqlite3-journal 21 | /log/* 22 | /tmp/* 23 | 24 | # add /config/database.yml if it contains passwords 25 | # /config/database.yml 26 | 27 | # various artifacts 28 | **.war 29 | *.rbc 30 | *.sassc 31 | .redcar/ 32 | .sass-cache 33 | /config/config.yml 34 | /coverage.data 35 | /coverage/ 36 | /db/*.javadb/ 37 | /db/*.sqlite3 38 | /doc/api/ 39 | /doc/app/ 40 | /doc/features.html 41 | /doc/specs.html 42 | /public/cache 43 | /public/stylesheets/compiled 44 | /public/system/* 45 | /spec/tmp/* 46 | /cache 47 | /capybara* 48 | /capybara-*.html 49 | /gems 50 | /specifications 51 | rerun.txt 52 | pickle-email-*.html 53 | .zeus.sock 54 | 55 | # If you find yourself ignoring temporary files generated by your text editor 56 | # or operating system, you probably want to add a global ignore instead: 57 | # git config --global core.excludesfile ~/.gitignore_global 58 | # 59 | # Here are some files you may want to ignore globally: 60 | 61 | # scm revert files 62 | **.orig 63 | 64 | # Mac finder artifacts 65 | .DS_Store 66 | 67 | # Netbeans project directory 68 | /nbproject/ 69 | 70 | # RubyMine project files 71 | .idea 72 | 73 | # Textmate project files 74 | /*.tmproj 75 | 76 | # vim artifacts 77 | **.swp 78 | 79 | # Environment files that may contain sensitive data 80 | .env 81 | .powenv 82 | 83 | # tilde files are usually backup files from a text editor 84 | *~ 85 | -------------------------------------------------------------------------------- /files/public/humans.txt: -------------------------------------------------------------------------------- 1 | /* the humans responsible & colophon */ 2 | /* humanstxt.org */ 3 | 4 | 5 | /* TEAM */ 6 |