anadea-spark 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +11 -0
  5. data/CONTRIBUTING.md +32 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +21 -0
  8. data/NEWS.md +8 -0
  9. data/README.md +154 -0
  10. data/Rakefile +11 -0
  11. data/anadea-spark.gemspec +35 -0
  12. data/bin/rake +16 -0
  13. data/bin/rspec +16 -0
  14. data/bin/setup +9 -0
  15. data/bin/spark +13 -0
  16. data/lib/spark.rb +4 -0
  17. data/lib/spark/actions.rb +33 -0
  18. data/lib/spark/app_builder.rb +373 -0
  19. data/lib/spark/generators/app_generator.rb +204 -0
  20. data/lib/spark/version.rb +5 -0
  21. data/spec/features/new_project_spec.rb +136 -0
  22. data/spec/spec_helper.rb +34 -0
  23. data/spec/support/spark.rb +51 -0
  24. data/templates/Gemfile.erb +53 -0
  25. data/templates/Procfile +2 -0
  26. data/templates/README.md.erb +14 -0
  27. data/templates/assets/application.css.scss +4 -0
  28. data/templates/assets/application.js +3 -0
  29. data/templates/bin/setup.erb +30 -0
  30. data/templates/config/application.yml.sample +3 -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/exception_notification.rb.erb +8 -0
  35. data/templates/config/initializers/json_encoding.rb +1 -0
  36. data/templates/config/initializers/mail_interceptor.rb +4 -0
  37. data/templates/config/initializers/rack_timeout.rb +1 -0
  38. data/templates/config/locales_en.yml.erb +19 -0
  39. data/templates/config/newrelic.yml.erb +30 -0
  40. data/templates/config/postgresql_database.yml.erb +12 -0
  41. data/templates/config/rails_secrets.yml +11 -0
  42. data/templates/dot_gitignore +15 -0
  43. data/templates/spec/rails_helper.rb +23 -0
  44. data/templates/spec/spec_helper.rb +32 -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.haml +11 -0
  52. data/templates/views/application/_flashes.html.haml +4 -0
  53. data/templates/views/application/_footer.html.haml +9 -0
  54. data/templates/views/application/_javascript.html.haml +8 -0
  55. data/templates/views/application/_navigation.html.haml +12 -0
  56. data/templates/views/application/_navigation_links.html.haml +2 -0
  57. data/templates/views/layouts/application.html.haml +23 -0
  58. data/templates/views/pages/home.html.haml +4 -0
  59. metadata +178 -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,14 @@
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.
11
+
12
+ After setting up, you can run the application using foreman or via regular:
13
+
14
+ % bin/rails s
@@ -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,30 @@
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
+ # Get mailcatcher up and running
22
+ gem list -i mailcatcher || gem install mailcatcher --no-ri --no-rdoc
23
+ nc -z localhost 1025 || mailcatcher
24
+
25
+ # Install foreman
26
+ gem list -i foreman || gem install foreman --no-ri --no-rdoc
27
+
28
+ # Only if this isn't CI
29
+ # if [ -z "$CI" ]; then
30
+ # fi
@@ -0,0 +1,3 @@
1
+ ASSET_HOST: "localhost:3000"
2
+ HOST: "localhost:3000"
3
+ 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,8 @@
1
+ if ENV.key?("MAIL_ERRORS_TO")
2
+ Whatever::Application.config.middleware.use ExceptionNotification::Rack,
3
+ email: {
4
+ email_prefix: "[<%= app_name %> Error] ",
5
+ sender_address: ENV["MAIL_FROM"],
6
+ exception_recipients: ENV["MAIL_ERRORS_TO"].to_s.split(",")
7
+ }
8
+ end
@@ -0,0 +1 @@
1
+ ActiveSupport::JSON::Encoding.time_precision = 0
@@ -0,0 +1,4 @@
1
+ # https://github.com/croaky/recipient_interceptor
2
+ Mail.register_interceptor(
3
+ RecipientInterceptor.new(ENV["EMAIL_RECIPIENTS"])
4
+ ) if ENV.key?("EMAIL_RECIPIENTS")
@@ -0,0 +1 @@
1
+ Rack::Timeout.timeout = ENV["RACK_TIMEOUT"].to_i if ENV.key?("RACK_TIMEOUT")
@@ -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,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 = :poltergeist
@@ -0,0 +1,32 @@
1
+ if ENV.fetch("COVERAGE", false)
2
+ require "simplecov"
3
+ SimpleCov.start "rails"
4
+ end
5
+
6
+ require "webmock/rspec"
7
+
8
+ # http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
9
+ RSpec.configure do |config|
10
+ config.expect_with :rspec do |expectations|
11
+ expectations.syntax = :expect
12
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
13
+ end
14
+
15
+ config.mock_with :rspec do |mocks|
16
+ mocks.syntax = :expect
17
+ mocks.verify_partial_doubles = true
18
+ end
19
+
20
+ config.filter_run :focus
21
+ config.run_all_when_everything_filtered = true
22
+
23
+ if config.files_to_run.one?
24
+ config.default_formatter = 'doc'
25
+ end
26
+
27
+ config.order = :random
28
+
29
+ Kernel.srand config.seed
30
+ end
31
+
32
+ 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,11 @@
1
+ - if ENV.key?("GOOGLE_ANALYTICS_KEY")
2
+ :javascript
3
+ var _gaq = _gaq || [];
4
+ _gaq.push(['_setAccount', '#{ENV["GOOGLE_ANALYTICS_KEY"]}']);
5
+ _gaq.push(['_trackPageview']);
6
+
7
+ (function() {
8
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
9
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
10
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
11
+ })();
@@ -0,0 +1,4 @@
1
+ - flash.each do |name, msg|
2
+ %div{:class => "alert alert-#{name == "notice" ? "success" : "danger"}"}
3
+ %button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"} ×
4
+ = content_tag :div, msg, :id => "flash_#{name}"
@@ -0,0 +1,9 @@
1
+ #footer
2
+ .container
3
+ .row.footer-first-row
4
+ .col-xs-12.text-center
5
+ %p
6
+ %small
7
+ © #{Time.now.year} - Yourself!
8
+ %br/
9
+ Assembled with #{link_to "Spark", "https://github.com/Anadea/spark"}
@@ -0,0 +1,8 @@
1
+ = javascript_include_tag :application
2
+ = yield :javascript
3
+ = render "analytics"
4
+
5
+ - if Rails.env.test?
6
+ = javascript_tag do
7
+ $.fx.off = true;
8
+ $.ajaxSetup({ async: false });
@@ -0,0 +1,12 @@
1
+ %nav.navbar.navbar-default
2
+ .container
3
+ .navbar-header
4
+ %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", :type => "button"}
5
+ %span.sr-only Toggle navigation
6
+ %span.icon-bar
7
+ %span.icon-bar
8
+ %span.icon-bar
9
+ = link_to 'Home', root_path, class: 'navbar-brand'
10
+ .collapse.navbar-collapse
11
+ %ul.nav.navbar-nav
12
+ = render 'navigation_links'
@@ -0,0 +1,2 @@
1
+ %li= link_to "Link 1", "#"
2
+ %li= link_to "Link 2", "#"
@@ -0,0 +1,23 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
5
+ %meta{:charset => "utf-8"}/
6
+ %meta{:content => "NOODP", :name => "ROBOTS"}/
7
+ %meta{:content => "initial-scale=1", :name => "viewport"}/
8
+ %title= title
9
+ = stylesheet_link_tag :application, media: "all"
10
+ = csrf_meta_tags
11
+ %body
12
+ #wrap
13
+ %header
14
+ = render 'navigation'
15
+ .container
16
+ .row
17
+ .col-sm-6.col-sm-offset-3.text-center
18
+ = render 'flashes'
19
+ .row
20
+ .col-sm-12
21
+ = yield
22
+ = render 'footer'
23
+ = render 'javascript'