yupi 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +11 -0
  5. data/CONTRIBUTING.md +33 -0
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +139 -0
  8. data/LICENSE +21 -0
  9. data/NEWS.md +8 -0
  10. data/README.md +72 -0
  11. data/Rakefile +11 -0
  12. data/bin/rake +16 -0
  13. data/bin/rspec +16 -0
  14. data/bin/setup +9 -0
  15. data/bin/yupi +13 -0
  16. data/lib/yupi.rb +4 -0
  17. data/lib/yupi/actions.rb +33 -0
  18. data/lib/yupi/app_builder.rb +368 -0
  19. data/lib/yupi/generators/app_generator.rb +201 -0
  20. data/lib/yupi/version.rb +5 -0
  21. data/spec/features/new_project_spec.rb +135 -0
  22. data/spec/spec_helper.rb +24 -0
  23. data/spec/support/yupi.rb +51 -0
  24. data/templates/Gemfile.erb +52 -0
  25. data/templates/Procfile +2 -0
  26. data/templates/README.md.erb +32 -0
  27. data/templates/assets/application.css.scss +4 -0
  28. data/templates/assets/application.js +3 -0
  29. data/templates/bin/setup.erb +23 -0
  30. data/templates/config/application.yml.sample +4 -0
  31. data/templates/config/i18n_tasks.yml +13 -0
  32. data/templates/config/initializers/disable_xml_params.rb +3 -0
  33. data/templates/config/initializers/errors.rb +34 -0
  34. data/templates/config/initializers/json_encoding.rb +1 -0
  35. data/templates/config/initializers/mail_interceptor.rb +3 -0
  36. data/templates/config/initializers/rack_timeout.rb +1 -0
  37. data/templates/config/locales_en.yml.erb +19 -0
  38. data/templates/config/newrelic.yml.erb +30 -0
  39. data/templates/config/postgresql_database.yml.erb +12 -0
  40. data/templates/config/rails_secrets.yml +11 -0
  41. data/templates/config/smtp.rb +9 -0
  42. data/templates/dot_gitignore +15 -0
  43. data/templates/spec/rails_helper.rb +23 -0
  44. data/templates/spec/spec_helper.rb +17 -0
  45. data/templates/spec/support/action_mailer.rb +5 -0
  46. data/templates/spec/support/database_cleaner_rspec.rb +21 -0
  47. data/templates/spec/support/factory_girl_rspec.rb +3 -0
  48. data/templates/spec/support/i18n.rb +3 -0
  49. data/templates/tasks/bundler_audit.rake +12 -0
  50. data/templates/tasks/development_seeds.rake +12 -0
  51. data/templates/views/application/_analytics.html.erb +7 -0
  52. data/templates/views/application/_flashes.html.erb +6 -0
  53. data/templates/views/application/_footer.html.erb +17 -0
  54. data/templates/views/application/_javascript.html.erb +12 -0
  55. data/templates/views/application/_navigation.html.erb +18 -0
  56. data/templates/views/application/_navigation_links.html.erb +2 -0
  57. data/templates/views/layouts/application.html.erb.erb +43 -0
  58. data/templates/views/pages/home.html.erb +1 -0
  59. data/yupi.gemspec +36 -0
  60. metadata +187 -0
@@ -0,0 +1,2 @@
1
+ web: ./bin/puma -t ${PUMA_MIN_THREADS:-8}:${PUMA_MAX_THREADS:-12} -w ${PUMA_WORKERS:-2} -p $PORT -e ${RACK_ENV:-development}
2
+ worker: bundle exec rake jobs:work
@@ -0,0 +1,32 @@
1
+ # <%= app_name.humanize %>
2
+
3
+ ## Getting Started
4
+
5
+ After you have cloned this repo, run this setup script to set up your machine
6
+ with the necessary dependencies to run and test this app:
7
+
8
+ % ./bin/setup
9
+
10
+ It assumes you have a machine equipped with Ruby, Postgres, etc. If not, set up
11
+ your machine with [this script].
12
+
13
+ [this script]: https://github.com/thoughtbot/laptop
14
+
15
+ After setting up, you can run the application using [foreman]:
16
+
17
+ % foreman start
18
+
19
+ If you don't have `foreman`, see [Foreman's install instructions][foreman]. It
20
+ is [purposefully excluded from the project's `Gemfile`][exclude].
21
+
22
+ [foreman]: https://github.com/ddollar/foreman
23
+ [exclude]: https://github.com/ddollar/foreman/pull/437#issuecomment-41110407
24
+
25
+ ## Guidelines
26
+
27
+ Use the following guides for getting things done, programming well, and
28
+ programming in style.
29
+
30
+ * [Protocol](http://github.com/thoughtbot/guides/blob/master/protocol)
31
+ * [Best Practices](http://github.com/thoughtbot/guides/blob/master/best-practices)
32
+ * [Style](http://github.com/thoughtbot/guides/blob/master/style)
@@ -0,0 +1,4 @@
1
+ @charset "utf-8";
2
+
3
+ @import "bootstrap-sprockets";
4
+ @import "bootstrap";
@@ -0,0 +1,3 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require bootstrap-sprockets
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Set up Rails app. Run this script immediately after cloning the codebase.
4
+ # https://github.com/thoughtbot/guides/tree/master/protocol
5
+
6
+ # Exit if any subcommand fails
7
+ set -e
8
+
9
+ # Set up Ruby dependencies via Bundler
10
+ gem install bundler --conservative
11
+ bundle check || bundle install
12
+
13
+ # Set up configurable environment variables
14
+ if [ ! -f config/application.yml ]; then
15
+ cp config/application.yml.sample config/application.yml
16
+ fi
17
+
18
+ # Set up database and add any development seed data
19
+ bundle exec rake db:setup dev:prime
20
+
21
+ # Only if this isn't CI
22
+ # if [ -z "$CI" ]; then
23
+ # fi
@@ -0,0 +1,4 @@
1
+ # http://ddollar.github.com/foreman/
2
+ ASSET_HOST: "localhost:3000"
3
+ HOST: "localhost:3000"
4
+ SECRET_KEY_BASE: "development_secret"
@@ -0,0 +1,13 @@
1
+ search:
2
+ paths:
3
+ - "app/controllers"
4
+ - "app/helpers"
5
+ - "app/presenters"
6
+ - "app/views"
7
+
8
+ ignore_unused:
9
+ - activerecord.*
10
+ - date.*
11
+ - simple_form.*
12
+ - time.*
13
+ - titles.*
@@ -0,0 +1,3 @@
1
+ # Protect against injection attacks
2
+ # http://www.kb.cert.org/vuls/id/380039
3
+ ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
@@ -0,0 +1,34 @@
1
+ require "net/http"
2
+ require "net/smtp"
3
+
4
+ # Example:
5
+ # begin
6
+ # some http call
7
+ # rescue *HTTP_ERRORS => error
8
+ # notify_hoptoad error
9
+ # end
10
+
11
+ HTTP_ERRORS = [
12
+ EOFError,
13
+ Errno::ECONNRESET,
14
+ Errno::EINVAL,
15
+ Net::HTTPBadResponse,
16
+ Net::HTTPHeaderSyntaxError,
17
+ Net::ProtocolError,
18
+ Timeout::Error
19
+ ]
20
+
21
+ SMTP_SERVER_ERRORS = [
22
+ IOError,
23
+ Net::SMTPAuthenticationError,
24
+ Net::SMTPServerBusy,
25
+ Net::SMTPUnknownError,
26
+ TimeoutError
27
+ ]
28
+
29
+ SMTP_CLIENT_ERRORS = [
30
+ Net::SMTPFatalError,
31
+ Net::SMTPSyntaxError
32
+ ]
33
+
34
+ SMTP_ERRORS = SMTP_SERVER_ERRORS + SMTP_CLIENT_ERRORS
@@ -0,0 +1 @@
1
+ ActiveSupport::JSON::Encoding.time_precision = 0
@@ -0,0 +1,3 @@
1
+ Mail.register_interceptor(
2
+ RecipientInterceptor.new(ENV["ALLOWED_EMAIL_RECIPIENTS"])
3
+ ) if ENV.key?("ALLOWED_EMAIL_RECIPIENTS")
@@ -0,0 +1 @@
1
+ Rack::Timeout.timeout = (ENV["RACK_TIMEOUT"] || 10).to_i
@@ -0,0 +1,19 @@
1
+ en:
2
+ date:
3
+ formats:
4
+ default:
5
+ "%m/%d/%Y"
6
+ with_weekday:
7
+ "%a %m/%d/%y"
8
+
9
+ time:
10
+ formats:
11
+ default:
12
+ "%a, %b %-d, %Y at %r"
13
+ date:
14
+ "%b %-d, %Y"
15
+ short:
16
+ "%B %d"
17
+
18
+ titles:
19
+ application: <%= app_name.humanize %>
@@ -0,0 +1,30 @@
1
+ common: &default_settings
2
+ app_name: "<%%= ENV.fetch("APP_NAME", <%= app_name %>) %>"
3
+ audit_log:
4
+ enabled: false
5
+ browser_monitoring:
6
+ auto_instrument: true
7
+ capture_params: false
8
+ developer_mode: false
9
+ error_collector:
10
+ capture_source: true
11
+ enabled: true
12
+ ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
13
+ license_key: "<%%= ENV["NEW_RELIC_LICENSE_KEY"] %>"
14
+ log_level: info
15
+ monitor_mode: true
16
+ transaction_tracer:
17
+ enabled: true
18
+ record_sql: obfuscated
19
+ stack_trace_threshold: 0.500
20
+ transaction_threshold: apdex_f
21
+ development:
22
+ <<: *default_settings
23
+ monitor_mode: false
24
+ developer_mode: true
25
+ test:
26
+ <<: *default_settings
27
+ monitor_mode: false
28
+ production:
29
+ <<: *default_settings
30
+ monitor_mode: true
@@ -0,0 +1,12 @@
1
+ development: &default
2
+ adapter: postgresql
3
+ database: <%= app_name %>_development
4
+ encoding: utf8
5
+ host: localhost
6
+ min_messages: warning
7
+ pool: 2
8
+ timeout: 5000
9
+
10
+ test:
11
+ <<: *default
12
+ database: <%= app_name %>_test
@@ -0,0 +1,11 @@
1
+ default: &default
2
+ secret_key_base: <%%= ENV["SECRET_KEY_BASE"] %>
3
+
4
+ development:
5
+ <<: *default
6
+
7
+ test:
8
+ <<: *default
9
+
10
+ production:
11
+ <<: *default
@@ -0,0 +1,9 @@
1
+ SMTP_SETTINGS = {
2
+ address: ENV.fetch("SMTP_ADDRESS"), # example: "smtp.sendgrid.net"
3
+ authentication: :plain,
4
+ domain: ENV.fetch("SMTP_DOMAIN"), # example: "heroku.com"
5
+ enable_starttls_auto: true,
6
+ password: ENV.fetch("SMTP_PASSWORD"),
7
+ port: "587",
8
+ user_name: ENV.fetch("SMTP_USERNAME")
9
+ }
@@ -0,0 +1,15 @@
1
+ !.keep
2
+ *.DS_Store
3
+ *.swo
4
+ *.swp
5
+ /.bundle
6
+ /.env
7
+ /.foreman
8
+ /coverage/*
9
+ /db/*.sqlite3
10
+ /log/*
11
+ /public/system
12
+ /public/assets
13
+ /tags
14
+ /tmp/*
15
+ /config/application.yml
@@ -0,0 +1,23 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ require File.expand_path("../../config/environment", __FILE__)
4
+
5
+ require "rspec/rails"
6
+ require "shoulda/matchers"
7
+
8
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |file| require file }
9
+
10
+ module Features
11
+ # Extend this module in spec/support/features/*.rb
12
+ include Formulaic::Dsl
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ config.include Features, type: :feature
17
+ config.infer_base_class_for_anonymous_controllers = false
18
+ config.infer_spec_type_from_file_location!
19
+ config.use_transactional_fixtures = false
20
+ end
21
+
22
+ ActiveRecord::Migration.maintain_test_schema!
23
+ Capybara.javascript_driver = :webkit
@@ -0,0 +1,17 @@
1
+ require "webmock/rspec"
2
+
3
+ # http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
4
+ RSpec.configure do |config|
5
+ config.expect_with :rspec do |expectations|
6
+ expectations.syntax = :expect
7
+ end
8
+
9
+ config.mock_with :rspec do |mocks|
10
+ mocks.syntax = :expect
11
+ mocks.verify_partial_doubles = true
12
+ end
13
+
14
+ config.order = :random
15
+ end
16
+
17
+ WebMock.disable_net_connect!(allow_localhost: true)
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.before(:each) do
3
+ ActionMailer::Base.deliveries.clear
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ RSpec.configure do |config|
2
+ config.before(:suite) do
3
+ DatabaseCleaner.clean_with(:deletion)
4
+ end
5
+
6
+ config.before(:each) do
7
+ DatabaseCleaner.strategy = :transaction
8
+ end
9
+
10
+ config.before(:each, js: true) do
11
+ DatabaseCleaner.strategy = :deletion
12
+ end
13
+
14
+ config.before(:each) do
15
+ DatabaseCleaner.start
16
+ end
17
+
18
+ config.after(:each) do
19
+ DatabaseCleaner.clean
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include AbstractController::Translation
3
+ end
@@ -0,0 +1,12 @@
1
+ if Rails.env.development? || Rails.env.test?
2
+ require "bundler/audit/cli"
3
+
4
+ namespace :bundler do
5
+ desc "Updates the ruby-advisory-db and runs audit"
6
+ task :audit do
7
+ %w(update check).each do |command|
8
+ Bundler::Audit::CLI.start [command]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ if Rails.env.development? || Rails.env.test?
2
+ require "factory_girl"
3
+
4
+ namespace :dev do
5
+ desc "Seed data for development environment"
6
+ task prime: "db:setup" do
7
+ include FactoryGirl::Syntax::Methods
8
+
9
+ # create(:user, email: "user@example.com", password: "password")
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ <% if ENV.key?("SEGMENT_KEY") %>
2
+ <script type="text/javascript">
3
+ window.analytics=window.analytics||[],window.analytics.methods=["identify","group","track","page","pageview","alias","ready","on","once","off","trackLink","trackForm","trackClick","trackSubmit"],window.analytics.factory=function(t){return function(){var a=Array.prototype.slice.call(arguments);return a.unshift(t),window.analytics.push(a),window.analytics}};for(var i=0;i<window.analytics.methods.length;i++){var key=window.analytics.methods[i];window.analytics[key]=window.analytics.factory(key)}window.analytics.load=function(t){if(!document.getElementById("analytics-js")){var a=document.createElement("script");a.type="text/javascript",a.id="analytics-js",a.async=!0,a.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n)}},window.analytics.SNIPPET_VERSION="2.0.9",
4
+ window.analytics.load("<%= ENV["SEGMENT_KEY"] %>");
5
+ window.analytics.page();
6
+ </script>
7
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <% flash.each do |name, msg| %>
2
+ <div class="alert alert-<%= name == "notice" ? "success" : "danger" %>">
3
+ <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
4
+ <%= content_tag :div, msg, :id => "flash_#{name}" %>
5
+ </div>
6
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <div id="footer">
2
+ <div class="container">
3
+
4
+ <div class="row footer-first-row">
5
+
6
+ <div class="col-xs-12 text-center">
7
+ <p><small>
8
+ &copy; <%= Time.now.year %> - Yourself!
9
+ <br/>
10
+ Assembled with <%= link_to "Yupi", "https://github.com/Anadea/yupi" %>
11
+ </small></p>
12
+ </div>
13
+
14
+ </div>
15
+
16
+ </div>
17
+ </div>
@@ -0,0 +1,12 @@
1
+ <%= javascript_include_tag :application %>
2
+
3
+ <%= yield :javascript %>
4
+
5
+ <%= render "analytics" %>
6
+
7
+ <% if Rails.env.test? %>
8
+ <%= javascript_tag do %>
9
+ $.fx.off = true;
10
+ $.ajaxSetup({ async: false });
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <nav class="navbar navbar-default">
2
+ <div class="container">
3
+ <div class="navbar-header">
4
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
5
+ <span class="sr-only">Toggle navigation</span>
6
+ <span class="icon-bar"></span>
7
+ <span class="icon-bar"></span>
8
+ <span class="icon-bar"></span>
9
+ </button>
10
+ <%= link_to 'Home', root_path, class: 'navbar-brand' %>
11
+ </div>
12
+ <div class="collapse navbar-collapse">
13
+ <ul class="nav navbar-nav">
14
+ <%= render 'navigation_links' %>
15
+ </ul>
16
+ </div>
17
+ </div>
18
+ </nav>
@@ -0,0 +1,2 @@
1
+ <li><%= link_to "Link 1", "#" %></li>
2
+ <li><%= link_to "Link 2", "#" %></li>
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="ROBOTS" content="NOODP" />
6
+ <meta name="viewport" content="initial-scale=1" />
7
+ <%%#
8
+ Configure default and controller-, and view-specific titles in
9
+ config/locales/en.yml. For more see:
10
+ https://github.com/calebthompson/title#usage
11
+ %>
12
+ <title><%%= title %></title>
13
+ <%%= stylesheet_link_tag :application, media: "all" %>
14
+ <%%= csrf_meta_tags %>
15
+ </head>
16
+
17
+ <body>
18
+ <div id="wrap">
19
+ <header>
20
+ <%%= render 'navigation' %>
21
+ </header>
22
+
23
+ <div class="container">
24
+
25
+ <div class="row">
26
+ <div class="col-sm-6 col-sm-offset-3 text-center">
27
+ <%%= render 'flashes' %>
28
+ </div>
29
+ </div>
30
+
31
+ <div class="row">
32
+ <div class="col-sm-12">
33
+ <%%= yield %>
34
+ </div>
35
+ </div>
36
+
37
+ </div>
38
+ </div>
39
+
40
+ <%%= render 'footer' %>
41
+ <%%= render 'javascript' %>
42
+ </body>
43
+ </html>