Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #73 from professor/double_to_single_quote
Browse files Browse the repository at this point in the history
Double quote to single quote
  • Loading branch information
Pinwheeler committed Apr 9, 2015
2 parents 78281b9 + 56d7805 commit 444077b
Show file tree
Hide file tree
Showing 44 changed files with 153 additions and 163 deletions.
4 changes: 2 additions & 2 deletions app/controllers/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def google_oauth2
@user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user)
@user = User.find_for_google_oauth2(request.env['omniauth.auth'], current_user)

if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", kind: "Google"
sign_in_and_redirect @user, event: :authentication
else
session["devise.google_data"] = request.env["omniauth.auth"]
session['devise.google_data'] = request.env['omniauth.auth']
redirect_to edit_configuration_url
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SessionsController < Devise::SessionsController
def create
super
rescue BCrypt::Errors::InvalidHash
flash[:error] = "The system has been upgraded, your password needs to be reset before logging in."
flash[:error] = 'The system has been upgraded, your password needs to be reset before logging in.'
redirect_to new_user_password_path
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/status_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class StatusController < ApplicationController
def create
if project = Project.find_by_guid(params.delete(:project_id))
payload = project.webhook_payload
payload.remote_addr = request.env["REMOTE_ADDR"]
payload.remote_addr = request.env['REMOTE_ADDR']

params.merge!(parse_legacy_jenkins_notification) if is_legacy_jenkins_notification?(payload)

Expand All @@ -17,7 +17,7 @@ def create
end

log = PayloadProcessor.new(project_status_updater: StatusUpdater.new).process_payload(project: project, payload: payload)
log.update_method = "Webhooks"
log.update_method = 'Webhooks'
log.save!

project.save!
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def create
@user = User.new(user_params)
if @user.save
redirect_to(root_path)
flash[:notice] = "User created."
flash[:notice] = 'User created.'
else
render :new
end
Expand Down
1 change: 0 additions & 1 deletion app/decorators/aggregate_project_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ def status_in_words
def css_class
"project #{status_in_words} aggregate"
end

end
1 change: 0 additions & 1 deletion app/decorators/circle_ci_project_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ class CircleCiProjectDecorator < ProjectDecorator
def current_build_url
"https://circleci.com/api/v1/project/#{object.circleci_username}/#{object.ci_build_identifier}?circle-token=#{object.ci_auth_token}"
end

end
1 change: 0 additions & 1 deletion app/decorators/codeship_project_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ class CodeshipProjectDecorator < ProjectDecorator
def current_build_url
"https://www.codeship.io/projects/#{object.ci_build_identifier}"
end

end
1 change: 0 additions & 1 deletion app/decorators/concourse_project_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ class ConcourseProjectDecorator < ProjectDecorator
def current_build_url
"#{object.ci_base_url}/jobs/#{object.ci_build_identifier}"
end

end
1 change: 0 additions & 1 deletion app/decorators/jenkins_project_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ class JenkinsProjectDecorator < ProjectDecorator
def current_build_url
object.webhooks_enabled? ? object.parsed_url : object.ci_base_url
end

end
4 changes: 2 additions & 2 deletions app/decorators/project_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ def current_build_url
# To know more about this method, see:
# http://api.rubyonrails.org/classes/ActiveModel/Conversion.html#method-i-to_partial_path
def to_partial_path
"projects/project"
'projects/project'
end
end
end
1 change: 0 additions & 1 deletion app/decorators/tddium_project_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ class TddiumProjectDecorator < ProjectDecorator
def current_build_url
"#{object.ci_base_url}/dashboard?auth_token=#{object.ci_auth_token}"
end

end
1 change: 0 additions & 1 deletion app/decorators/team_city_project_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ def current_build_url
"#{object.ci_base_url}/viewType.html?buildTypeId=#{object.ci_build_identifier}"
end
end

end
1 change: 0 additions & 1 deletion app/decorators/team_city_rest_project_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ def current_build_url

object.url_with_scheme(url)
end

end
4 changes: 2 additions & 2 deletions app/decorators/travis_pro_project_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class TravisProProjectDecorator < TravisProjectDecorator
BASE_WEB_URL = "https://magnum.travis-ci.com"
end
BASE_WEB_URL = 'https://magnum.travis-ci.com'
end
3 changes: 1 addition & 2 deletions app/decorators/travis_project_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
class TravisProjectDecorator < ProjectDecorator
BASE_WEB_URL = "https://travis-ci.org"
BASE_WEB_URL = 'https://travis-ci.org'

def current_build_url
"#{self.class.const_get(:BASE_WEB_URL)}/#{object.slug}"
end

end
10 changes: 5 additions & 5 deletions app/helpers/project_monitor_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ module ProjectMonitorHelper
def static_status_messages_for(project)
messages = []
if project.online?
messages << (project.status.published_at.present? ? "Last built #{project.status.published_at}": "Last build date unknown")
messages << (project.status.published_at.present? ? "Last built #{project.status.published_at}": 'Last build date unknown')
if project.failure?
messages << (project.status.published_at.present? ? "Red since #{project.red_since} #{build_count_text_for(project)}" : "Red for some time")
messages << (project.status.published_at.present? ? "Red since #{project.red_since} #{build_count_text_for(project)}" : 'Red for some time')
end
else
messages << "Could not retrieve status"
messages << 'Could not retrieve status'
end
messages
end

private

def build_count_text_for(project)
return "" unless project.failure?
return '' unless project.failure?
count = project.red_build_count
"(#{count} #{count == 1 ? "build" : "builds"})"
"(#{count} #{count == 1 ? 'build' : 'builds'})"
end
end
15 changes: 7 additions & 8 deletions app/helpers/projects_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def project_types

def project_webhooks_url(project)
if project.guid.present?
"Your webhooks URL is " + project_status_url(project.guid).to_s
'Your webhooks URL is ' + project_status_url(project.guid).to_s
else
unless project.new_record?
project.generate_guid
project.save!
end
""
''
end
end

Expand All @@ -35,12 +35,12 @@ def project_latest_error(project)
def project_last_status_text(project)
if latest = project.payload_log_entries.latest
if project.enabled
latest.status || "Unknown Status"
latest.status || 'Unknown Status'
else
"disabled"
'disabled'
end
else
"none"
'none'
end.titleize
end

Expand All @@ -56,11 +56,11 @@ def project_last_status(project)
end
else
content_tag(:span, class: "last_status #{latest.status}") do
content_tag(:p, "Disabled")
content_tag(:p, 'Disabled')
end
end
else
"None"
'None'
end
end

Expand Down Expand Up @@ -90,5 +90,4 @@ def remove_header_for_markdown(markdown)
header_regex = (/(#+.*\n+)/)
markdown.sub(header_regex, '')
end

end
6 changes: 3 additions & 3 deletions app/models/aggregate_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AggregateProject < ActiveRecord::Base
scope :enabled, -> { where(enabled: true) }
scope :with_statuses, -> { joins(projects: :statuses).uniq }
scope :displayable, lambda { |tags = nil|
scope = enabled.joins(:projects).select("DISTINCT aggregate_projects.*").order('code ASC')
scope = enabled.joins(:projects).select('DISTINCT aggregate_projects.*').order('code ASC')
return scope.tagged_with(tags, any: true) if tags
scope
}
Expand Down Expand Up @@ -39,7 +39,7 @@ def tracker_project?
end

def code
super.presence || name.downcase.gsub(" ", '')[0..3]
super.presence || name.downcase.gsub(' ', '')[0..3]
end

def status
Expand Down Expand Up @@ -86,6 +86,6 @@ def breaking_build
def red_build_count
return 0 if breaking_build.nil? || !online?
red_project = projects.detect(&:failure?)
red_project.statuses.where("id >= ?", red_project.breaking_build.id).count
red_project.statuses.where('id >= ?', red_project.breaking_build.id).count
end
end
4 changes: 2 additions & 2 deletions app/models/circle_ci_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ def self.project_specific_attributes
end

def feed_url
"https://circleci.com/api/v1/project/#{circleci_username}/#{ci_build_identifier}/tree/#{build_branch.presence || "master"}?circle-token=#{ci_auth_token}"
"https://circleci.com/api/v1/project/#{circleci_username}/#{ci_build_identifier}/tree/#{build_branch.presence || 'master'}?circle-token=#{ci_auth_token}"
end

def fetch_payload
CircleCiPayload.new
end

def accept_mime_types
"application/json"
'application/json'
end

def requires_branch_name?
Expand Down
8 changes: 4 additions & 4 deletions app/models/external_dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def rubygems_status
doc = Nokogiri::HTML(UrlRetriever.new('http://status.rubygems.org/').retrieve_content)
page_status = doc.at_css("span[class^='status__subheading']")

if page_status["class"].include? "up"
output[:status] = "good"
elsif page_status["class"].include? "down"
output[:status] = "bad"
if page_status['class'].include? 'up'
output[:status] = 'good'
elsif page_status['class'].include? 'down'
output[:status] = 'bad'
else
output[:status] = 'page broken'
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/payload_log_entry.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class PayloadLogEntry < ActiveRecord::Base
belongs_to :project

default_scope { order("created_at DESC") }
scope :reverse_chronological, -> () { order("created_at DESC") }
default_scope { order('created_at DESC') }
scope :reverse_chronological, -> () { order('created_at DESC') }

def self.latest
reverse_chronological.limit(1).first
Expand Down
12 changes: 6 additions & 6 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Project < ActiveRecord::Base

has_many :payload_log_entries
belongs_to :aggregate_project
belongs_to :creator, class_name: "User"
belongs_to :creator, class_name: 'User'

serialize :last_ten_velocities, Array
serialize :iteration_story_state_counts, JSON
Expand Down Expand Up @@ -89,15 +89,15 @@ def red_since

def red_build_count
return 0 if breaking_build.nil? || !online?
statuses.red.where("id >= ?", breaking_build.id).count
statuses.red.where('id >= ?', breaking_build.id).count
end

def feed_url
raise NotImplementedError, "Must implement feed_url in subclasses"
raise NotImplementedError, 'Must implement feed_url in subclasses'
end

def build_status_url
raise NotImplementedError, "Must implement build_status_url in subclasses"
raise NotImplementedError, 'Must implement build_status_url in subclasses'
end

def tracker_project_url
Expand All @@ -124,7 +124,7 @@ def breaking_build
@breaking_build ||= if last_green.nil?
recent_statuses.red.last
else
recent_statuses.red.where("build_id > ?", last_green.build_id).first
recent_statuses.red.where('build_id > ?', last_green.build_id).first
end
end

Expand All @@ -138,7 +138,7 @@ def tracker_project?
alias tracker_configured? tracker_project?

def payload
raise NotImplementedError, "Must implement payload in subclasses"
raise NotImplementedError, 'Must implement payload in subclasses'
end

def has_status?(status)
Expand Down
18 changes: 9 additions & 9 deletions app/models/project/state.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class Project::State
def initialize(online: false, success: nil)
state_text = if !online
"offline"
'offline'
elsif success == false
"failure"
'failure'
elsif success
"success"
'success'
else
"indeterminate"
'indeterminate'
end
@state = ActiveSupport::StringInquirer.new(state_text)
end
Expand Down Expand Up @@ -36,10 +36,10 @@ def online?

def color
{
"offline" => "white",
"success" => "green",
"failure" => "red",
"indeterminate" => "yellow"
'offline' => 'white',
'success' => 'green',
'failure' => 'red',
'indeterminate' => 'yellow'
}[state.to_s]
end

Expand All @@ -55,4 +55,4 @@ def hash

attr_reader :state

end
end
4 changes: 2 additions & 2 deletions app/models/travis_pro_project.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class TravisProProject < TravisProject
BASE_API_URL = "https://api.travis-ci.com"
BASE_API_URL = 'https://api.travis-ci.com'

validates_presence_of :ci_auth_token, unless: ->(project) { project.webhooks_enabled }

Expand All @@ -20,4 +20,4 @@ def fetch_payload
end

alias_method :webhook_payload, :fetch_payload
end
end
2 changes: 1 addition & 1 deletion app/models/travis_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class TravisProject < Project

validates_presence_of :travis_github_account, :travis_repository, unless: ->(project) { project.webhooks_enabled }

BASE_API_URL = "https://api.travis-ci.org"
BASE_API_URL = 'https://api.travis-ci.org'

alias_attribute :build_status_url, :feed_url
alias_attribute :project_name, :travis_github_account
Expand Down
Loading

0 comments on commit 444077b

Please sign in to comment.