exceptionally 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +138 -0
  4. data/Rakefile +32 -0
  5. data/lib/exceptionally/controller.rb +50 -0
  6. data/lib/exceptionally/exceptions.rb +182 -0
  7. data/lib/exceptionally/handler.rb +30 -0
  8. data/lib/exceptionally/railtie.rb +9 -0
  9. data/lib/exceptionally/version.rb +3 -0
  10. data/lib/exceptionally.rb +7 -0
  11. data/lib/tasks/exceptionally_tasks.rake +4 -0
  12. data/test/dummy/README.rdoc +28 -0
  13. data/test/dummy/Rakefile +6 -0
  14. data/test/dummy/app/assets/javascripts/application.js +13 -0
  15. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  16. data/test/dummy/app/controllers/application_controller.rb +5 -0
  17. data/test/dummy/app/helpers/application_helper.rb +2 -0
  18. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  19. data/test/dummy/bin/bundle +3 -0
  20. data/test/dummy/bin/rails +4 -0
  21. data/test/dummy/bin/rake +4 -0
  22. data/test/dummy/config/application.rb +23 -0
  23. data/test/dummy/config/boot.rb +5 -0
  24. data/test/dummy/config/database.yml +25 -0
  25. data/test/dummy/config/environment.rb +5 -0
  26. data/test/dummy/config/environments/development.rb +29 -0
  27. data/test/dummy/config/environments/production.rb +80 -0
  28. data/test/dummy/config/environments/test.rb +36 -0
  29. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  30. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  31. data/test/dummy/config/initializers/inflections.rb +16 -0
  32. data/test/dummy/config/initializers/mime_types.rb +5 -0
  33. data/test/dummy/config/initializers/secret_token.rb +12 -0
  34. data/test/dummy/config/initializers/session_store.rb +3 -0
  35. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  36. data/test/dummy/config/locales/en.yml +23 -0
  37. data/test/dummy/config/routes.rb +56 -0
  38. data/test/dummy/config.ru +4 -0
  39. data/test/dummy/public/404.html +58 -0
  40. data/test/dummy/public/422.html +58 -0
  41. data/test/dummy/public/500.html +57 -0
  42. data/test/dummy/public/favicon.ico +0 -0
  43. data/test/exceptionally_test.rb +7 -0
  44. data/test/test_helper.rb +15 -0
  45. metadata +140 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 021bc161718c3f6759f35966d9d833adfcd9b700
4
+ data.tar.gz: c77c028c2e5aefaa9d424910b1898e141b350f63
5
+ SHA512:
6
+ metadata.gz: ab99856b766aecb5504bdbbb8fb033f868a40bfca10f751ea3f1d2f420206b68bf92b5bbe1b8a5538c41765f870cdc758d40d34748420e8cbeab42a83eddec31
7
+ data.tar.gz: d75cc2385e01a7280fa3602063c92101d174ea375d399df523f41f4394c72cfed30f6168257b0b0f3971ec439d9fee9b9195665c4ae5e7839b5745b9ce44dd5c
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 Neil Gupta
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # Exceptionally
2
+
3
+ [https://www.github.com/neilgupta/exceptionally](https://www.github.com/neilgupta/exceptionally)
4
+
5
+ Exceptionally abstracts your exception logic to make raising and returning meaningful errors in Ruby on Rails easier. It is primarily designed for API-only applications that need to return descriptive JSON error messages, rather than static HTML error pages.
6
+
7
+ Just raise the appropriate exception anywhere in your code and Exceptionally will handle the rest.
8
+
9
+ ```ruby
10
+ raise Exceptionally::Unauthorized.new("Incorrect token")
11
+ ```
12
+
13
+ will return the following JSON response to the client with a 401 status code:
14
+
15
+ ```javascript
16
+ {"error": "Incorrect token"}
17
+ ```
18
+
19
+ It's that easy!
20
+
21
+ ## Installation
22
+
23
+ To get started with Exceptionally, just add the following to your `Gemfile`:
24
+
25
+ ```ruby
26
+ gem 'exceptionally'
27
+ ```
28
+
29
+ Exceptionally has only been tested with Rails 4, but it should work with Rails 3+ in theory ;)
30
+
31
+ ## Features
32
+
33
+ In addition to seamlessly abstracting your exception logic and returning clean JSON responses to your users, Exceptionally also offers the following benefits.
34
+
35
+ ### Logging
36
+
37
+ If you raise a 500-level error, Exceptionally will log the error, stacktrace, and relevant parameters to Rails.logger. Additionally, Exceptionally supports [Airbrake](http://airbrake.io) and [New Relic](http://newrelic.com) by default, and will notify those services if you have their gems set up.
38
+
39
+ ### Customizable
40
+
41
+ #### Add a custom error handler
42
+
43
+ Need to run your own logging code or do something else with the errors before they're returned to the user? Just add the following to `config/initializers/exceptionally.rb`:
44
+
45
+ ```ruby
46
+ Exceptionally::Handler.before_render do |message, status, error, params|
47
+ # Place your custom code here
48
+ # message is a string description of what went wrong
49
+ # status is an integer of the HTTP status code
50
+ # error is a Ruby Exception object
51
+ # params is a hash of the parameters passed to your controller
52
+ end
53
+ ```
54
+
55
+ #### Override output formatting
56
+
57
+ You can also override the returned response by adding a `render_error` method to your controller. For example, if you want to include the HTTP status code in the returned JSON, you can do:
58
+
59
+ ```ruby
60
+ def render_error(message, status)
61
+ render json: {error_message: message, error_status: status}, status: status
62
+ end
63
+ ```
64
+
65
+ You could also return HTML, XML, or whatever other format is relevant to your application.
66
+
67
+ `render_error` must accept `message`, a string description of the error, and `status`, an integer HTTP status code.
68
+
69
+ #### Add custom errors
70
+
71
+ Exceptionally will handle the following errors by default:
72
+
73
+ * generic Exceptions
74
+ * ArgumentErrors
75
+ * ActiveRecord::RecordNotFound
76
+ * ActiveRecord::RecordInvalid
77
+ * Apipie::ParamMissing (if using [Apipie](https://github.com/Apipie/apipie-rails))
78
+ * Apipie::ParamInvalid (if using [Apipie](https://github.com/Apipie/apipie-rails))
79
+ * Exceptionally errors (see below for available errors)
80
+
81
+ If there are additional errors that you want to assign status codes to and pass to Exceptionally, you can add the following to the top of your `application_controller.rb`:
82
+
83
+ ```ruby
84
+ # Catch MyCustomModule::BadRequestException errors and pass them to Exceptionally
85
+ rescue_from MyCustomModule::BadRequestException, :with => :custom_400_error
86
+
87
+ # Tell Exceptionally you want this treated as a 400 error
88
+ def custom_400_error(error)
89
+ pass_to_error_handler(error, 400)
90
+ end
91
+ ```
92
+
93
+ `pass_to_error_handler` takes a Ruby Exception object and an optional status code. If no status code is provided, it will default to 500.
94
+
95
+ ## Available Errors
96
+
97
+ You can raise the following HTTP errors. All of them accept an optional string that is passed to the user instead of the generic message (eg. "Invalid token" instead of "Unauthorized"):
98
+
99
+ * Exceptionally::BadRequest
100
+ * Exceptionally::Unauthorized
101
+ * Exceptionally::PaymentRequired
102
+ * Exceptionally::Forbidden
103
+ * Exceptionally::NotFound
104
+ * Exceptionally::NotAllowed
105
+ * Exceptionally::NotAcceptable
106
+ * Exceptionally::ProxyAuthRequired
107
+ * Exceptionally::Timeout
108
+ * Exceptionally::Conflict
109
+ * Exceptionally::Gone
110
+ * Exceptionally::LengthRequired
111
+ * Exceptionally::PreconditionFailed
112
+ * Exceptionally::TooLarge
113
+ * Exceptionally::TooLong
114
+ * Exceptionally::UnsupportedMedia
115
+ * Exceptionally::RangeNotSatisfiable
116
+ * Exceptionally::ExpectationFailed
117
+ * Exceptionally::Error
118
+ * Exceptionally::NotImplemented
119
+ * Exceptionally::BadGateway
120
+ * Exceptionally::ServiceUnavailable
121
+ * Exceptionally::GatewayTimeout
122
+ * Exceptionally::HttpVersionNotSupported
123
+
124
+ You can also raise an error with just the HTTP status code by using `Exceptionally::Http404`. Status codes 400-417 and 500-505 are available.
125
+
126
+ **[See descriptions of all status codes](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)**
127
+
128
+ ## Why use Exceptionally instead of the built-in Rails `render`?
129
+
130
+ By abstracting all of the exception handling logic, Exceptionally DRY's up your code and makes it easier to read. If you later decide to change the format of your error responses, you just need to edit `render_error` in one place. Exceptionally also transparently handles ActiveRecord, Apipie, and other generic exceptions for you, so that your app is less likely to crash. Additionally, you get a bunch of logging and error reporting functionality for free.
131
+
132
+ ## Author
133
+
134
+ Neil Gupta [http://metamorphium.com](http://metamorphium.com)
135
+
136
+ ## License
137
+
138
+ The MIT License (MIT) Copyright (c) 2014 Neil Gupta. See [MIT-LICENSE](https://raw.github.com/neilgupta/exceptionally/master/MIT-LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Exceptionally'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -0,0 +1,50 @@
1
+ require "active_record/validations.rb"
2
+
3
+ module Exceptionally
4
+ module Controller
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ rescue_from Exception, :with => :exceptionally_handler
9
+ rescue_from ArgumentError, :with => :exceptionally_handler
10
+ rescue_from Exceptionally::Error, :with => :exceptionally_handler
11
+ rescue_from ActiveRecord::RecordNotFound, :with => :missing_record_handler
12
+ rescue_from ActiveRecord::RecordInvalid, :with => :record_invalid_handler
13
+ if defined?(Apipie)
14
+ rescue_from Apipie::ParamMissing, :with => :missing_param
15
+ rescue_from Apipie::ParamInvalid, :with => :missing_param
16
+ end
17
+ end
18
+
19
+ # Raise custom error
20
+ def exceptionally_handler(error)
21
+ pass_to_error_handler(error)
22
+ end
23
+
24
+ # Raise 400 error
25
+ def missing_param(error)
26
+ pass_to_error_handler(error, 400)
27
+ end
28
+
29
+ # Raise 404 error
30
+ def missing_record_handler(error)
31
+ pass_to_error_handler(error, 404)
32
+ end
33
+
34
+ # Raise 409 error
35
+ def record_invalid_handler(error)
36
+ pass_to_error_handler(error, 409)
37
+ end
38
+
39
+ def pass_to_error_handler(error, status = nil)
40
+ status ||= error.try(:status) || 500
41
+ Exceptionally::Handler.new(error.message, status, error, params)
42
+ render_error(error.message, status)
43
+ end
44
+
45
+ def render_error(message, status)
46
+ render json: {error: message}, status: status
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,182 @@
1
+ module Exceptionally
2
+ class Error < StandardError
3
+ attr_reader :status
4
+
5
+ def initialize(message = nil, status = nil, default = nil)
6
+ @message = message
7
+ @status = status || 500
8
+ @default = default || "Internal Server Error"
9
+ end
10
+
11
+ def message
12
+ @message || @default
13
+ end
14
+
15
+ def to_s
16
+ "#{@status} #{@default}#{@message ? ": #{@message}" : ''}"
17
+ end
18
+ end
19
+
20
+ class BadRequest < Error
21
+ def initialize(message = nil)
22
+ super(message, 400, "Bad Request")
23
+ end
24
+ end
25
+
26
+ class Unauthorized < Error
27
+ def initialize(message = nil)
28
+ super(message, 401, "Unauthorized")
29
+ end
30
+ end
31
+
32
+ class PaymentRequired < Error
33
+ def initialize(message = nil)
34
+ super(message, 402, "Payment Required")
35
+ end
36
+ end
37
+
38
+ class Forbidden < Error
39
+ def initialize(message = nil)
40
+ super(message, 403, "Forbidden")
41
+ end
42
+ end
43
+
44
+ class NotFound < Error
45
+ def initialize(message = nil)
46
+ super(message, 404, "Not Found")
47
+ end
48
+ end
49
+
50
+ class NotAllowed < Error
51
+ def initialize(message = nil)
52
+ super(message, 405, "Method Not Allowed")
53
+ end
54
+ end
55
+
56
+ class NotAcceptable < Error
57
+ def initialize(message = nil)
58
+ super(message, 406, "Not Acceptable")
59
+ end
60
+ end
61
+
62
+ class ProxyAuthRequired < Error
63
+ def initialize(message = nil)
64
+ super(message, 407, "Proxy Authentication Required")
65
+ end
66
+ end
67
+
68
+ class Timeout < Error
69
+ def initialize(message = nil)
70
+ super(message, 408, "Request Timeout")
71
+ end
72
+ end
73
+
74
+ class Conflict < Error
75
+ def initialize(message = nil)
76
+ super(message, 409, "Conflict")
77
+ end
78
+ end
79
+
80
+ class Gone < Error
81
+ def initialize(message = nil)
82
+ super(message, 410, "Gone")
83
+ end
84
+ end
85
+
86
+ class LengthRequired < Error
87
+ def initialize(message = nil)
88
+ super(message, 411, "Length Required")
89
+ end
90
+ end
91
+
92
+ class PreconditionFailed < Error
93
+ def initialize(message = nil)
94
+ super(message, 412, "Precondition Failed")
95
+ end
96
+ end
97
+
98
+ class TooLarge < Error
99
+ def initialize(message = nil)
100
+ super(message, 413, "Request Entity Too Large")
101
+ end
102
+ end
103
+
104
+ class TooLong < Error
105
+ def initialize(message = nil)
106
+ super(message, 414, "Request-URI Too Long")
107
+ end
108
+ end
109
+
110
+ class UnsupportedMedia < Error
111
+ def initialize(message = nil)
112
+ super(message, 415, "Unsupported Media Type")
113
+ end
114
+ end
115
+
116
+ class RangeNotSatisfiable < Error
117
+ def initialize(message = nil)
118
+ super(message, 416, "Requested Range Not Satisfiable")
119
+ end
120
+ end
121
+
122
+ class ExpectationFailed < Error
123
+ def initialize(message = nil)
124
+ super(message, 417, "Expectation Failed")
125
+ end
126
+ end
127
+
128
+ class NotImplemented < Error
129
+ def initialize(message = nil)
130
+ super(message, 501, "Not Implemented")
131
+ end
132
+ end
133
+
134
+ class BadGateway < Error
135
+ def initialize(message = nil)
136
+ super(message, 502, "Bad Gateway")
137
+ end
138
+ end
139
+
140
+ class ServiceUnavailable < Error
141
+ def initialize(message = nil)
142
+ super(message, 503, "Service Unavailable")
143
+ end
144
+ end
145
+
146
+ class GatewayTimeout < Error
147
+ def initialize(message = nil)
148
+ super(message, 504, "Gateway Timeout")
149
+ end
150
+ end
151
+
152
+ class HttpVersionNotSupported < Error
153
+ def initialize(message = nil)
154
+ super(message, 505, "HTTP Version Not Supported")
155
+ end
156
+ end
157
+
158
+ class Http400 < BadRequest; end
159
+ class Http401 < Unauthorized; end
160
+ class Http402 < PaymentRequired; end
161
+ class Http403 < Forbidden; end
162
+ class Http404 < NotFound; end
163
+ class Http405 < NotAllowed; end
164
+ class Http406 < NotAcceptable; end
165
+ class Http407 < ProxyAuthRequired; end
166
+ class Http408 < Timeout; end
167
+ class Http409 < Conflict; end
168
+ class Http410 < Gone; end
169
+ class Http411 < LengthRequired; end
170
+ class Http412 < PreconditionFailed; end
171
+ class Http413 < TooLarge; end
172
+ class Http414 < TooLong; end
173
+ class Http415 < UnsupportedMedia; end
174
+ class Http416 < RangeNotSatisfiable; end
175
+ class Http417 < ExpectationFailed; end
176
+ class Http500 < Error; end
177
+ class Http501 < NotImplemented; end
178
+ class Http502 < BadGateway; end
179
+ class Http503 < ServiceUnavailable; end
180
+ class Http504 < GatewayTimeout; end
181
+ class Http505 < HttpVersionNotSupported; end
182
+ end
@@ -0,0 +1,30 @@
1
+ module Exceptionally
2
+ class Handler
3
+ def initialize(message = nil, status = nil, e = nil, params = nil)
4
+ @message = message
5
+ @status = status || 500
6
+ @error = e
7
+ @params = params || {}
8
+
9
+ @@callback.call(@message, @status, @error, @params) if defined?(@@callback) && @@callback.respond_to?(:call)
10
+ log
11
+ end
12
+
13
+ def self.before_render(&block)
14
+ @@callback = Proc.new(&block)
15
+ end
16
+
17
+ def log
18
+ # Log 5xx errors
19
+ if @status >= 500 && @error
20
+ # Support Airbrake and New Relic out of box
21
+ Airbrake.notify(@error, :parameters => @params) if defined?(Airbrake) && Airbrake.respond_to?(:notify) && Rails.env.production?
22
+ NewRelic::Agent.notice_error(@error) if defined?(NewRelic) && defined?(NewRelic::Agent) && NewRelic::Agent.respond_to?(:notice_error) && Rails.env.production?
23
+
24
+ Rails.logger.error(@error.to_s)
25
+ Rails.logger.error("Parameters: #{@params.to_s}") unless @params.blank?
26
+ Rails.logger.error(@error.backtrace.join("\n")) unless @error.backtrace.blank?
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+ module Exceptionally
2
+ class Railtie < Rails::Railtie
3
+ initializer "exceptionally.action_controller" do
4
+ ActiveSupport.on_load(:action_controller) do
5
+ include Exceptionally::Controller
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Exceptionally
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,7 @@
1
+ require 'exceptionally/controller'
2
+ require 'exceptionally/exceptions'
3
+ require 'exceptionally/handler'
4
+ require 'exceptionally/railtie'
5
+
6
+ module Exceptionally
7
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :exceptionally do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "exceptionally"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+ end
22
+ end
23
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Dummy::Application.initialize!