diff --git a/Gemfile b/Gemfile index 17f3cc8..a7b903b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' ruby '2.3.7' @@ -5,52 +7,37 @@ gem 'rails', '4.2.10' gem 'pg', '= 0.20' -gem 'sass-rails', '~> 5.0.0' - -gem 'uglifier', '>= 1.3.0' - +gem 'autoprefixer-rails' gem 'coffee-rails', '~> 4.0.0' - +gem 'font-awesome-rails' gem 'jquery-rails' +gem 'sass-rails', '~> 5.0.0' +gem 'uglifier', '>= 1.3.0' -gem 'jbuilder', '~> 1.2' - -gem 'responders', '~> 2.0' - -gem 'rails_admin' - -gem 'rack-attack' - -gem 'redis-rails' - +gem 'airbrake', '~> 7.3' +gem 'clockwork' +gem 'foundation-rails', '~> 5' +gem 'haml-rails' +gem 'newrelic_rpm' +gem 'oj' gem 'rabl' - +gem 'rack-attack' +gem 'rack-cors', require: 'rack/cors' gem 'rails_autoscale_agent' - +gem 'redis-rails' +gem 'responders', '~> 2.0' +gem 'unicorn' gem 'watir' -gem 'chromedriver-helper' - -gem 'oj' - -gem 'clockwork' - -gem 'haml-rails' - -gem 'foundation-rails', "~> 5" - -gem 'autoprefixer-rails' - -gem 'font-awesome-rails' - group :production do gem 'rails_12factor' end group :development, :test do - gem 'pry-rails' + gem 'chromedriver-helper' gem 'better_errors' gem 'binding_of_caller' + gem 'pry-rails' gem 'rubocop' end @@ -58,9 +45,3 @@ group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false end - -gem 'unicorn' - -gem 'newrelic_rpm' - -gem 'rack-cors', require: 'rack/cors' diff --git a/Gemfile.lock b/Gemfile.lock index 7939be2..414a4c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -35,6 +35,9 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + airbrake (7.3.4) + airbrake-ruby (~> 2.10) + airbrake-ruby (2.10.0) archive-zip (0.11.0) io-like (~> 0.3.0) arel (6.0.4) @@ -95,27 +98,10 @@ GEM concurrent-ruby (~> 1.0) io-like (0.3.0) jaro_winkler (1.5.1) - jbuilder (1.5.3) - activesupport (>= 3.0.0) - multi_json (>= 1.2.0) jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (5.0.5) - railties (>= 3.2.16) - kaminari (1.1.1) - activesupport (>= 4.1.0) - kaminari-actionview (= 1.1.1) - kaminari-activerecord (= 1.1.1) - kaminari-core (= 1.1.1) - kaminari-actionview (1.1.1) - actionview - kaminari-core (= 1.1.1) - kaminari-activerecord (1.1.1) - activerecord - kaminari-core (= 1.1.1) - kaminari-core (1.1.1) kgio (2.11.2) loofah (2.2.2) crass (~> 1.0.2) @@ -126,8 +112,6 @@ GEM mini_mime (1.0.0) mini_portile2 (2.3.0) minitest (5.11.3) - multi_json (1.13.1) - nested_form (0.3.2) newrelic_rpm (5.2.0.345) nokogiri (1.8.2) mini_portile2 (~> 2.3.0) @@ -148,9 +132,6 @@ GEM rack-attack (5.2.0) rack rack-cors (1.0.2) - rack-pjax (1.0.0) - nokogiri (~> 1.5) - rack (>= 1.1) rack-test (0.6.3) rack (>= 1.0) rails (4.2.10) @@ -175,19 +156,6 @@ GEM rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging - rails_admin (1.3.0) - builder (~> 3.1) - coffee-rails (~> 4.0) - font-awesome-rails (>= 3.0, < 5) - haml (>= 4.0, < 6) - jquery-rails (>= 3.0, < 5) - jquery-ui-rails (~> 5.0) - kaminari (>= 0.14, < 2.0) - nested_form (~> 0.3) - rack-pjax (>= 0.7) - rails (>= 4.0, < 6) - remotipart (~> 1.3) - sass-rails (>= 4.0, < 6) rails_autoscale_agent (0.3.1) activesupport (>= 3.2) rails_serve_static_assets (0.0.5) @@ -218,7 +186,6 @@ GEM redis-store (>= 1.2, < 2) redis-store (1.5.0) redis (>= 2.2, < 5) - remotipart (1.4.2) responders (2.4.0) actionpack (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3) @@ -273,6 +240,7 @@ PLATFORMS ruby DEPENDENCIES + airbrake (~> 7.3) autoprefixer-rails better_errors binding_of_caller @@ -282,7 +250,6 @@ DEPENDENCIES font-awesome-rails foundation-rails (~> 5) haml-rails - jbuilder (~> 1.2) jquery-rails newrelic_rpm oj @@ -293,7 +260,6 @@ DEPENDENCIES rack-cors rails (= 4.2.10) rails_12factor - rails_admin rails_autoscale_agent redis-rails responders (~> 2.0) diff --git a/config/initializers/airbrake.rb b/config/initializers/airbrake.rb new file mode 100644 index 0000000..b5e9f18 --- /dev/null +++ b/config/initializers/airbrake.rb @@ -0,0 +1,70 @@ +# Airbrake is an online tool that provides robust exception tracking in your Rails +# applications. In doing so, it allows you to easily review errors, tie an error +# to an individual piece of code, and trace the cause back to recent +# changes. Airbrake enables for easy categorization, searching, and prioritization +# of exceptions so that when errors occur, your team can quickly determine the +# root cause. +# +# Configuration details: +# https://github.com/airbrake/airbrake-ruby#configuration +Airbrake.configure do |c| + # You must set both project_id & project_key. To find your project_id and + # project_key navigate to your project's General Settings and copy the values + # from the right sidebar. + # https://github.com/airbrake/airbrake-ruby#project_id--project_key + c.project_id = 187866 + c.project_key = '9d82fdce33a5edc3118ae68384b0fd8c' + + # Configures the root directory of your project. Expects a String or a + # Pathname, which represents the path to your project. Providing this option + # helps us to filter out repetitive data from backtrace frames and link to + # GitHub files from our dashboard. + # https://github.com/airbrake/airbrake-ruby#root_directory + c.root_directory = Rails.root + + # By default, Airbrake Ruby outputs to STDOUT. In Rails apps it makes sense to + # use the Rails' logger. + # https://github.com/airbrake/airbrake-ruby#logger + c.logger = Rails.logger + + # Configures the environment the application is running in. Helps the Airbrake + # dashboard to distinguish between exceptions occurring in different + # environments. + # NOTE: This option must be set in order to make the 'ignore_environments' + # option work. + # https://github.com/airbrake/airbrake-ruby#environment + c.environment = Rails.env + + # Setting this option allows Airbrake to filter exceptions occurring in + # unwanted environments such as :test. + # NOTE: This option *does not* work if you don't set the 'environment' option. + # https://github.com/airbrake/airbrake-ruby#ignore_environments + c.ignore_environments = %w(test) + + # A list of parameters that should be filtered out of what is sent to + # Airbrake. By default, all "password" attributes will have their contents + # replaced. + # https://github.com/airbrake/airbrake-ruby#blacklist_keys + c.blacklist_keys = [/password/i, /authorization/i] + + # Alternatively, you can integrate with Rails' filter_parameters. + # Read more: https://goo.gl/gqQ1xS + # c.blacklist_keys = Rails.application.config.filter_parameters +end + +# A filter that collects request body information. Enable it if you are sure you +# don't send sensitive information to Airbrake in your body (such as passwords). +# https://github.com/airbrake/airbrake#requestbodyfilter +# Airbrake.add_filter(Airbrake::Rack::RequestBodyFilter.new) + +# Attaches thread & fiber local variables along with general thread information. +# Airbrake.add_filter(Airbrake::Filters::ThreadFilter.new) + +# Attaches loaded dependencies to the notice object +# (under context/versions/dependencies). +# Airbrake.add_filter(Airbrake::Filters::DependencyFilter.new) + +# If you want to convert your log messages to Airbrake errors, we offer an +# integration with the Logger class from stdlib. +# https://github.com/airbrake/airbrake#logger +# Rails.logger = Airbrake::AirbrakeLogger.new(Rails.logger) diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb index 3a0007b..4330f9c 100644 --- a/config/initializers/rack_attack.rb +++ b/config/initializers/rack_attack.rb @@ -4,10 +4,11 @@ now = Time.now match_data = env['rack.attack.match_data'] + reset = (now + (match_data[:period] - now.to_i % match_data[:period])).to_s headers = { 'X-RateLimit-Limit' => match_data[:limit].to_s, 'X-RateLimit-Remaining' => '0', - 'X-RateLimit-Reset' => (now + (match_data[:period] - now.to_i % match_data[:period])).to_s + 'X-RateLimit-Reset' => reset } [429, headers, ["Throttled\n"]] diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb deleted file mode 100644 index 9d8c5a5..0000000 --- a/config/initializers/rails_admin.rb +++ /dev/null @@ -1,36 +0,0 @@ -RailsAdmin.config do |config| - - ### Popular gems integration - - ## == Devise == - # config.authenticate_with do - # warden.authenticate! scope: :user - # end - # config.current_user_method(&:current_user) - - ## == Cancan == - # config.authorize_with :cancan - - ## == PaperTrail == - # config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0 - - ### More at https://github.com/sferik/rails_admin/wiki/Base-configuration - - config.actions do - dashboard # mandatory - index # mandatory - new - export - bulk_delete - show - edit - delete - show_in_app - - config.authorize_with do - authenticate_or_request_with_http_basic('Gotta know the codes') do |username, password| - username == ENV["ADMIN_LOGIN"] && password == ENV["ADMIN_PASS"] - end - end - end -end diff --git a/config/routes.rb b/config/routes.rb index dc1c46b..ac20416 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,4 @@ WorldCupJson::Application.routes.draw do - mount RailsAdmin::Engine => '/admin', as: 'rails_admin' # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". get '/teams', to: 'teams#index', defaults: { format: 'json' } @@ -16,53 +15,4 @@ # You can have the root of your site routed with "root" root 'static#index' - - # Example of regular route: - # get 'products/:id' => 'catalog#view' - - # Example of named route that can be invoked with purchase_url(id: product.id) - # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase - - # Example resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Example resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Example resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Example resource route with more complex sub-resources: - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', on: :collection - # end - # end - - # Example resource route with concerns: - # concern :toggleable do - # post 'toggle' - # end - # resources :posts, concerns: :toggleable - # resources :photos, concerns: :toggleable - - # Example resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end end