Commit 2b34bb97d353cbf07217c3404c2b0252c26b10bc
1 parent
1c7cb82a
Exists in
master
and in
1 other branch
Rubocop: consistent access modifier indentation
This is a tough call, both the Rails style (with private/protected) methods indented one level under the keyword, and other places using the standard ruby don't modify identation for access level. I think this strikes a good balance while still being readable. s
Showing
31 changed files
with
112 additions
and
123 deletions
Show diff stats
.rubocop.yml
| @@ -14,3 +14,14 @@ Style/EmptyLineBetweenDefs: | @@ -14,3 +14,14 @@ Style/EmptyLineBetweenDefs: | ||
| 14 | 14 | ||
| 15 | Style/ExtraSpacing: | 15 | Style/ExtraSpacing: |
| 16 | AllowForAlignment: true | 16 | AllowForAlignment: true |
| 17 | + | ||
| 18 | +Style/IndentationConsistency: | ||
| 19 | + # `rails` style: | ||
| 20 | + # prescribes that in classes and modules the `protected` and `private` | ||
| 21 | + # modifier keywords shall be indented the same as public methods and that | ||
| 22 | + # protected and private members shall be indented one step more than the | ||
| 23 | + # modifiers. | ||
| 24 | + EnforcedStyle: rails | ||
| 25 | + | ||
| 26 | +Style/AccessModifierIndentation: | ||
| 27 | + EnforcedStyle: outdent |
app/controllers/api/v1/stats_controller.rb
| @@ -23,9 +23,7 @@ class Api::V1::StatsController < ApplicationController | @@ -23,9 +23,7 @@ class Api::V1::StatsController < ApplicationController | ||
| 23 | end | 23 | end |
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | - protected | ||
| 27 | - | ||
| 28 | - def require_api_key_or_authenticate_user! | 26 | + protected def require_api_key_or_authenticate_user! |
| 29 | if params[:api_key].present? | 27 | if params[:api_key].present? |
| 30 | if (@app = App.where(:api_key => params[:api_key]).first) | 28 | if (@app = App.where(:api_key => params[:api_key]).first) |
| 31 | return true | 29 | return true |
app/controllers/application_controller.rb
| @@ -17,7 +17,7 @@ class ApplicationController < ActionController::Base | @@ -17,7 +17,7 @@ class ApplicationController < ActionController::Base | ||
| 17 | strategy StrongParametersWithEagerAttributesStrategy | 17 | strategy StrongParametersWithEagerAttributesStrategy |
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | - protected | 20 | +protected |
| 21 | 21 | ||
| 22 | ## | 22 | ## |
| 23 | # Check if the current_user is admin or not and redirect to root url if not | 23 | # Check if the current_user is admin or not and redirect to root url if not |
app/controllers/apps_controller.rb
| @@ -90,18 +90,18 @@ class AppsController < ApplicationController | @@ -90,18 +90,18 @@ class AppsController < ApplicationController | ||
| 90 | redirect_to edit_app_path(app) | 90 | redirect_to edit_app_path(app) |
| 91 | end | 91 | end |
| 92 | 92 | ||
| 93 | - protected | ||
| 94 | - | ||
| 95 | - def initialize_subclassed_notification_service | ||
| 96 | - # set the app's notification service | ||
| 97 | - if params[:app][:notification_service_attributes] && (notification_type = params[:app][:notification_service_attributes][:type]) | ||
| 98 | - available_notification_classes = [NotificationService] + NotificationService.subclasses | ||
| 99 | - notification_class = available_notification_classes.detect{|c| c.name == notification_type} | ||
| 100 | - if notification_class.present? | ||
| 101 | - app.notification_service = notification_class.new(params[:app][:notification_service_attributes]) | ||
| 102 | - end | 93 | +protected |
| 94 | + | ||
| 95 | + def initialize_subclassed_notification_service | ||
| 96 | + # set the app's notification service | ||
| 97 | + if params[:app][:notification_service_attributes] && (notification_type = params[:app][:notification_service_attributes][:type]) | ||
| 98 | + available_notification_classes = [NotificationService] + NotificationService.subclasses | ||
| 99 | + notification_class = available_notification_classes.detect{|c| c.name == notification_type} | ||
| 100 | + if notification_class.present? | ||
| 101 | + app.notification_service = notification_class.new(params[:app][:notification_service_attributes]) | ||
| 103 | end | 102 | end |
| 104 | end | 103 | end |
| 104 | + end | ||
| 105 | 105 | ||
| 106 | def plug_params(app) | 106 | def plug_params(app) |
| 107 | app.watchers.build if app.watchers.none? | 107 | app.watchers.build if app.watchers.none? |
| @@ -141,9 +141,7 @@ class AppsController < ApplicationController | @@ -141,9 +141,7 @@ class AppsController < ApplicationController | ||
| 141 | end | 141 | end |
| 142 | end | 142 | end |
| 143 | 143 | ||
| 144 | - private | ||
| 145 | - | ||
| 146 | - def app_params | ||
| 147 | - params.require(:app).permit! | ||
| 148 | - end | 144 | + private def app_params |
| 145 | + params.require(:app).permit! | ||
| 146 | + end | ||
| 149 | end | 147 | end |
app/controllers/comments_controller.rb
| @@ -24,11 +24,11 @@ class CommentsController < ApplicationController | @@ -24,11 +24,11 @@ class CommentsController < ApplicationController | ||
| 24 | redirect_to app_problem_path(@app, @problem) | 24 | redirect_to app_problem_path(@app, @problem) |
| 25 | end | 25 | end |
| 26 | 26 | ||
| 27 | - protected | 27 | +protected |
| 28 | 28 | ||
| 29 | - def find_app | ||
| 30 | - @app = App.find(params[:app_id]) | ||
| 31 | - end | 29 | + def find_app |
| 30 | + @app = App.find(params[:app_id]) | ||
| 31 | + end | ||
| 32 | 32 | ||
| 33 | def find_problem | 33 | def find_problem |
| 34 | @problem = @app.problems.find(params[:problem_id]) | 34 | @problem = @app.problems.find(params[:problem_id]) |
app/controllers/deploys_controller.rb
| @@ -16,19 +16,19 @@ class DeploysController < ApplicationController | @@ -16,19 +16,19 @@ class DeploysController < ApplicationController | ||
| 16 | page(params[:page]).per(10) | 16 | page(params[:page]).per(10) |
| 17 | end | 17 | end |
| 18 | 18 | ||
| 19 | - private | 19 | +private |
| 20 | 20 | ||
| 21 | - def default_deploy | ||
| 22 | - if params[:deploy] | ||
| 23 | - { | ||
| 24 | - :username => params[:deploy][:local_username], | ||
| 25 | - :environment => params[:deploy][:rails_env], | ||
| 26 | - :repository => params[:deploy][:scm_repository], | ||
| 27 | - :revision => params[:deploy][:scm_revision], | ||
| 28 | - :message => params[:deploy][:message] | ||
| 29 | - } | ||
| 30 | - end | 21 | + def default_deploy |
| 22 | + if params[:deploy] | ||
| 23 | + { | ||
| 24 | + :username => params[:deploy][:local_username], | ||
| 25 | + :environment => params[:deploy][:rails_env], | ||
| 26 | + :repository => params[:deploy][:scm_repository], | ||
| 27 | + :revision => params[:deploy][:scm_revision], | ||
| 28 | + :message => params[:deploy][:message] | ||
| 29 | + } | ||
| 31 | end | 30 | end |
| 31 | + end | ||
| 32 | 32 | ||
| 33 | # handle Heroku's HTTP post deployhook format | 33 | # handle Heroku's HTTP post deployhook format |
| 34 | def heroku_deploy | 34 | def heroku_deploy |
app/controllers/notices_controller.rb
| @@ -33,7 +33,7 @@ class NoticesController < ApplicationController | @@ -33,7 +33,7 @@ class NoticesController < ApplicationController | ||
| 33 | redirect_to app_problem_path(problem.app, problem) | 33 | redirect_to app_problem_path(problem.app, problem) |
| 34 | end | 34 | end |
| 35 | 35 | ||
| 36 | - private | 36 | +private |
| 37 | 37 | ||
| 38 | def notice_params | 38 | def notice_params |
| 39 | return @notice_params if @notice_params | 39 | return @notice_params if @notice_params |
app/controllers/problems_controller.rb
| @@ -134,12 +134,10 @@ class ProblemsController < ApplicationController | @@ -134,12 +134,10 @@ class ProblemsController < ApplicationController | ||
| 134 | end | 134 | end |
| 135 | end | 135 | end |
| 136 | 136 | ||
| 137 | - protected | ||
| 138 | - | ||
| 139 | ## | 137 | ## |
| 140 | # Redirect :back if no errors selected | 138 | # Redirect :back if no errors selected |
| 141 | # | 139 | # |
| 142 | - def need_selected_problem | 140 | + protected def need_selected_problem |
| 143 | if err_ids.empty? | 141 | if err_ids.empty? |
| 144 | flash[:notice] = I18n.t('controllers.problems.flash.no_select_problem') | 142 | flash[:notice] = I18n.t('controllers.problems.flash.no_select_problem') |
| 145 | redirect_to :back | 143 | redirect_to :back |
app/controllers/users/omniauth_callbacks_controller.rb
| @@ -39,9 +39,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | @@ -39,9 +39,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | ||
| 39 | end | 39 | end |
| 40 | end | 40 | end |
| 41 | 41 | ||
| 42 | - private | ||
| 43 | - | ||
| 44 | - def update_user_with_github_attributes(user, login, token) | 42 | + private def update_user_with_github_attributes(user, login, token) |
| 45 | user.update_attributes( | 43 | user.update_attributes( |
| 46 | :github_login => login, | 44 | :github_login => login, |
| 47 | :github_oauth_token => token | 45 | :github_oauth_token => token |
app/controllers/users_controller.rb
| @@ -51,12 +51,12 @@ class UsersController < ApplicationController | @@ -51,12 +51,12 @@ class UsersController < ApplicationController | ||
| 51 | redirect_to user_path(user) | 51 | redirect_to user_path(user) |
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | - protected | 54 | +protected |
| 55 | 55 | ||
| 56 | - def require_user_edit_priviledges | ||
| 57 | - can_edit = current_user == user || current_user.admin? | ||
| 58 | - redirect_to(root_path) unless can_edit | ||
| 59 | - end | 56 | + def require_user_edit_priviledges |
| 57 | + can_edit = current_user == user || current_user.admin? | ||
| 58 | + redirect_to(root_path) unless can_edit | ||
| 59 | + end | ||
| 60 | 60 | ||
| 61 | def user_params | 61 | def user_params |
| 62 | @user_params ||= params[:user] ? params.require(:user).permit(*user_permit_params) : {} | 62 | @user_params ||= params[:user] ? params.require(:user).permit(*user_permit_params) : {} |
app/decorators/backtrace_line_decorator.rb
| @@ -49,7 +49,7 @@ class BacktraceLineDecorator < Draper::Decorator | @@ -49,7 +49,7 @@ class BacktraceLineDecorator < Draper::Decorator | ||
| 49 | .sub(Backtrace::GEMS_PATH, "<strong>\\1</strong>") | 49 | .sub(Backtrace::GEMS_PATH, "<strong>\\1</strong>") |
| 50 | end | 50 | end |
| 51 | 51 | ||
| 52 | - private | 52 | +private |
| 53 | 53 | ||
| 54 | def link_to_in_app_source_file(app, text) | 54 | def link_to_in_app_source_file(app, text) |
| 55 | return unless in_app? | 55 | return unless in_app? |
app/decorators/issue_tracker_field_decorator.rb
| @@ -17,9 +17,7 @@ class IssueTrackerFieldDecorator < Draper::Decorator | @@ -17,9 +17,7 @@ class IssueTrackerFieldDecorator < Draper::Decorator | ||
| 17 | :value => issue_tracker.options[key.to_s]) | 17 | :value => issue_tracker.options[key.to_s]) |
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | - private | ||
| 21 | - | ||
| 22 | - def input_field | 20 | + private def input_field |
| 23 | object == :password ? :password_field : :text_field | 21 | object == :password ? :password_field : :text_field |
| 24 | end | 22 | end |
| 25 | end | 23 | end |
app/helpers/application_helper.rb
| @@ -75,11 +75,11 @@ module ApplicationHelper | @@ -75,11 +75,11 @@ module ApplicationHelper | ||
| 75 | end | 75 | end |
| 76 | end | 76 | end |
| 77 | 77 | ||
| 78 | - private | 78 | +private |
| 79 | 79 | ||
| 80 | - def total_from_tallies(tallies) | ||
| 81 | - tallies.values.inject(0) {|sum, n| sum + n} | ||
| 82 | - end | 80 | + def total_from_tallies(tallies) |
| 81 | + tallies.values.inject(0) {|sum, n| sum + n} | ||
| 82 | + end | ||
| 83 | 83 | ||
| 84 | def head_size | 84 | def head_size |
| 85 | 4 | 85 | 4 |
app/helpers/apps_helper.rb
| @@ -36,9 +36,7 @@ module AppsHelper | @@ -36,9 +36,7 @@ module AppsHelper | ||
| 36 | @any_deploys | 36 | @any_deploys |
| 37 | end | 37 | end |
| 38 | 38 | ||
| 39 | - private | ||
| 40 | - | ||
| 41 | - def detect_any_apps_with_attributes | 39 | + private def detect_any_apps_with_attributes |
| 42 | @any_github_repos = @any_issue_trackers = @any_deploys = @any_bitbucket_repos = @any_notification_services = false | 40 | @any_github_repos = @any_issue_trackers = @any_deploys = @any_bitbucket_repos = @any_notification_services = false |
| 43 | 41 | ||
| 44 | apps.each do |app| | 42 | apps.each do |app| |
app/interactors/problem_destroy.rb
app/interactors/resolved_problem_clearer.rb
app/mailers/mailer.rb
| @@ -58,9 +58,7 @@ class Mailer < ActionMailer::Base | @@ -58,9 +58,7 @@ class Mailer < ActionMailer::Base | ||
| 58 | :subject => "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" | 58 | :subject => "#{@user.name} commented on [#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" |
| 59 | end | 59 | end |
| 60 | 60 | ||
| 61 | - private | ||
| 62 | - | ||
| 63 | - def errbit_headers(header) | 61 | + private def errbit_headers(header) |
| 64 | header.each { |key,value| headers["X-Errbit-#{key}"] = value.to_s } | 62 | header.each { |key,value| headers["X-Errbit-#{key}"] = value.to_s } |
| 65 | end | 63 | end |
| 66 | end | 64 | end |
app/models/app.rb
| @@ -188,13 +188,13 @@ class App | @@ -188,13 +188,13 @@ class App | ||
| 188 | update_attribute(:api_key, SecureRandom.hex) | 188 | update_attribute(:api_key, SecureRandom.hex) |
| 189 | end | 189 | end |
| 190 | 190 | ||
| 191 | - protected | 191 | +protected |
| 192 | 192 | ||
| 193 | - def store_cached_attributes_on_problems | ||
| 194 | - Problem.where(:app_id => id).update_all( | ||
| 195 | - app_name: name | ||
| 196 | - ) | ||
| 197 | - end | 193 | + def store_cached_attributes_on_problems |
| 194 | + Problem.where(:app_id => id).update_all( | ||
| 195 | + app_name: name | ||
| 196 | + ) | ||
| 197 | + end | ||
| 198 | 198 | ||
| 199 | def generate_api_key | 199 | def generate_api_key |
| 200 | self.api_key ||= SecureRandom.hex | 200 | self.api_key ||= SecureRandom.hex |
app/models/backtrace.rb
| @@ -22,9 +22,7 @@ class Backtrace | @@ -22,9 +22,7 @@ class Backtrace | ||
| 22 | Digest::SHA1.hexdigest(lines.map(&:to_s).join) | 22 | Digest::SHA1.hexdigest(lines.map(&:to_s).join) |
| 23 | end | 23 | end |
| 24 | 24 | ||
| 25 | - private | ||
| 26 | - | ||
| 27 | - def generate_fingerprint | 25 | + private def generate_fingerprint |
| 28 | self.fingerprint = self.class.generate_fingerprint(lines) | 26 | self.fingerprint = self.class.generate_fingerprint(lines) |
| 29 | end | 27 | end |
| 30 | end | 28 | end |
app/models/comment.rb
| @@ -28,11 +28,11 @@ class Comment | @@ -28,11 +28,11 @@ class Comment | ||
| 28 | app.emailable? && notification_recipients.any? | 28 | app.emailable? && notification_recipients.any? |
| 29 | end | 29 | end |
| 30 | 30 | ||
| 31 | - protected | 31 | +protected |
| 32 | 32 | ||
| 33 | - def increase_counter_cache | ||
| 34 | - err.inc(comments_count: 1) | ||
| 35 | - end | 33 | + def increase_counter_cache |
| 34 | + err.inc(comments_count: 1) | ||
| 35 | + end | ||
| 36 | 36 | ||
| 37 | def decrease_counter_cache | 37 | def decrease_counter_cache |
| 38 | err.inc(comments_count: -1) if err | 38 | err.inc(comments_count: -1) if err |
app/models/deploy.rb
| @@ -26,11 +26,11 @@ class Deploy | @@ -26,11 +26,11 @@ class Deploy | ||
| 26 | revision.to_s[0,7] | 26 | revision.to_s[0,7] |
| 27 | end | 27 | end |
| 28 | 28 | ||
| 29 | - protected | 29 | +protected |
| 30 | 30 | ||
| 31 | - def should_resolve_app_errs? | ||
| 32 | - app.resolve_errs_on_deploy? | ||
| 33 | - end | 31 | + def should_resolve_app_errs? |
| 32 | + app.resolve_errs_on_deploy? | ||
| 33 | + end | ||
| 34 | 34 | ||
| 35 | def store_cached_attributes_on_problems | 35 | def store_cached_attributes_on_problems |
| 36 | Problem.where(:app_id => app.id).update_all( | 36 | Problem.where(:app_id => app.id).update_all( |
app/models/notice.rb
| @@ -124,7 +124,7 @@ class Notice | @@ -124,7 +124,7 @@ class Notice | ||
| 124 | message.gsub(/(#<.+?):[0-9a-f]x[0-9a-f]+(>)/, '\1\2') | 124 | message.gsub(/(#<.+?):[0-9a-f]x[0-9a-f]+(>)/, '\1\2') |
| 125 | end | 125 | end |
| 126 | 126 | ||
| 127 | - protected | 127 | +protected |
| 128 | 128 | ||
| 129 | def problem_recache | 129 | def problem_recache |
| 130 | problem.uncache_notice(self) | 130 | problem.uncache_notice(self) |
app/models/notification_services/flowdock_service.rb
| @@ -27,7 +27,7 @@ if defined? Flowdock | @@ -27,7 +27,7 @@ if defined? Flowdock | ||
| 27 | flow.push_to_team_inbox(:subject => subject, :content => content(problem, url), :project => project_name(problem), :link => url) | 27 | flow.push_to_team_inbox(:subject => subject, :content => content(problem, url), :project => project_name(problem), :link => url) |
| 28 | end | 28 | end |
| 29 | 29 | ||
| 30 | - private | 30 | + private |
| 31 | 31 | ||
| 32 | # can only contain alphanumeric characters and underscores | 32 | # can only contain alphanumeric characters and underscores |
| 33 | def project_name(problem) | 33 | def project_name(problem) |
app/models/notification_services/gtalk_service.rb
| @@ -57,7 +57,7 @@ class NotificationServices::GtalkService < NotificationService | @@ -57,7 +57,7 @@ class NotificationServices::GtalkService < NotificationService | ||
| 57 | client.close unless client.nil? | 57 | client.close unless client.nil? |
| 58 | end | 58 | end |
| 59 | 59 | ||
| 60 | - private | 60 | +private |
| 61 | 61 | ||
| 62 | def send_to_users(client, message) | 62 | def send_to_users(client, message) |
| 63 | user_id.tr(' ', ",").tr(';', ",").split(",").map(&:strip).reject(&:empty?).each do |user| | 63 | user_id.tr(' ', ",").tr(';', ",").split(",").map(&:strip).reject(&:empty?).each do |user| |
app/models/problem.rb
| @@ -244,18 +244,18 @@ class Problem | @@ -244,18 +244,18 @@ class Problem | ||
| 244 | Problem.where({'$text' => {'$search' => value}}) | 244 | Problem.where({'$text' => {'$search' => value}}) |
| 245 | end | 245 | end |
| 246 | 246 | ||
| 247 | - private | ||
| 248 | - | ||
| 249 | - def attribute_count_descrease(name, value) | ||
| 250 | - counter = send(name) | ||
| 251 | - index = attribute_index(value) | ||
| 252 | - if counter[index] && counter[index]['count'] > 1 | ||
| 253 | - counter[index]['count'] -= 1 | ||
| 254 | - else | ||
| 255 | - counter.delete(index) | ||
| 256 | - end | ||
| 257 | - counter | 247 | +private |
| 248 | + | ||
| 249 | + def attribute_count_descrease(name, value) | ||
| 250 | + counter = send(name) | ||
| 251 | + index = attribute_index(value) | ||
| 252 | + if counter[index] && counter[index]['count'] > 1 | ||
| 253 | + counter[index]['count'] -= 1 | ||
| 254 | + else | ||
| 255 | + counter.delete(index) | ||
| 258 | end | 256 | end |
| 257 | + counter | ||
| 258 | + end | ||
| 259 | 259 | ||
| 260 | def attribute_index(value) | 260 | def attribute_index(value) |
| 261 | Digest::MD5.hexdigest(value.to_s) | 261 | Digest::MD5.hexdigest(value.to_s) |
app/models/user.rb
| @@ -83,9 +83,7 @@ class User | @@ -83,9 +83,7 @@ class User | ||
| 83 | :auth_token | 83 | :auth_token |
| 84 | end | 84 | end |
| 85 | 85 | ||
| 86 | - private | ||
| 87 | - | ||
| 88 | - def generate_authentication_token | 86 | + private def generate_authentication_token |
| 89 | loop do | 87 | loop do |
| 90 | token = Devise.friendly_token | 88 | token = Devise.friendly_token |
| 91 | break token unless User.where(authentication_token: token).first | 89 | break token unless User.where(authentication_token: token).first |
app/models/watcher.rb
| @@ -25,11 +25,11 @@ class Watcher | @@ -25,11 +25,11 @@ class Watcher | ||
| 25 | user.try(:email) || email | 25 | user.try(:email) || email |
| 26 | end | 26 | end |
| 27 | 27 | ||
| 28 | - protected | 28 | +protected |
| 29 | 29 | ||
| 30 | - def ensure_user_or_email | ||
| 31 | - errors.add(:base, "You must specify either a user or an email address") unless user.present? || email.present? | ||
| 32 | - end | 30 | + def ensure_user_or_email |
| 31 | + errors.add(:base, "You must specify either a user or an email address") unless user.present? || email.present? | ||
| 32 | + end | ||
| 33 | 33 | ||
| 34 | def clear_unused_watcher_type | 34 | def clear_unused_watcher_type |
| 35 | case watcher_type | 35 | case watcher_type |
lib/airbrake_api/v3/notice_parser.rb
| @@ -24,7 +24,7 @@ module AirbrakeApi | @@ -24,7 +24,7 @@ module AirbrakeApi | ||
| 24 | ErrorReport.new(attributes) | 24 | ErrorReport.new(attributes) |
| 25 | end | 25 | end |
| 26 | 26 | ||
| 27 | - private | 27 | + private |
| 28 | 28 | ||
| 29 | def error | 29 | def error |
| 30 | raise AirbrakeApi::ParamsError unless params.key?('errors') && params['errors'].any? | 30 | raise AirbrakeApi::ParamsError unless params.key?('errors') && params['errors'].any? |
lib/hoptoad.rb
| @@ -13,13 +13,11 @@ module Hoptoad | @@ -13,13 +13,11 @@ module Hoptoad | ||
| 13 | processor.process_notice(parsed) | 13 | processor.process_notice(parsed) |
| 14 | end | 14 | end |
| 15 | 15 | ||
| 16 | - private | ||
| 17 | - | ||
| 18 | - def self.get_version_processor(version) | ||
| 19 | - case version | ||
| 20 | - when /2\.[01234]/ then Hoptoad::V2 | ||
| 21 | - else; raise ApiVersionError | ||
| 22 | - end | 16 | + private def self.get_version_processor(version) |
| 17 | + case version | ||
| 18 | + when /2\.[01234]/ then Hoptoad::V2 | ||
| 19 | + else; raise ApiVersionError | ||
| 23 | end | 20 | end |
| 21 | + end | ||
| 24 | end | 22 | end |
| 25 | 23 |
lib/hoptoad/v2.rb
lib/overrides/hoptoad_notifier/hoptoad_notifier.rb
| @@ -4,23 +4,21 @@ | @@ -4,23 +4,21 @@ | ||
| 4 | 4 | ||
| 5 | HoptoadNotifier.module_eval do | 5 | HoptoadNotifier.module_eval do |
| 6 | class << self | 6 | class << self |
| 7 | - private | 7 | + private def send_notice(notice) |
| 8 | + # Log the error internally if we are not in a development environment. | ||
| 9 | + if configuration.public? | ||
| 10 | + app = App.find_or_initialize_by(:name => "Self.Errbit") | ||
| 11 | + app.github_repo = "errbit/errbit" | ||
| 12 | + app.save! | ||
| 13 | + notice.send("api_key=", app.api_key) | ||
| 8 | 14 | ||
| 9 | - def send_notice(notice) | ||
| 10 | - # Log the error internally if we are not in a development environment. | ||
| 11 | - if configuration.public? | ||
| 12 | - app = App.find_or_initialize_by(:name => "Self.Errbit") | ||
| 13 | - app.github_repo = "errbit/errbit" | ||
| 14 | - app.save! | ||
| 15 | - notice.send("api_key=", app.api_key) | 15 | + # Create notice internally. |
| 16 | + report = ErrorReport.new(notice.to_xml) | ||
| 17 | + report.generate_notice! | ||
| 16 | 18 | ||
| 17 | - # Create notice internally. | ||
| 18 | - report = ErrorReport.new(notice.to_xml) | ||
| 19 | - report.generate_notice! | ||
| 20 | - | ||
| 21 | - logger.info "Internal error was logged to 'Self.Errbit' app." | ||
| 22 | - end | 19 | + logger.info "Internal error was logged to 'Self.Errbit' app." |
| 23 | end | 20 | end |
| 21 | + end | ||
| 24 | end | 22 | end |
| 25 | end | 23 | end |
| 26 | 24 |