Skip to content

Commit

Permalink
fixing style
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdulwahaab710 committed May 14, 2018
1 parent 0508eb3 commit ad2a7be
Show file tree
Hide file tree
Showing 103 changed files with 389 additions and 189 deletions.
10 changes: 6 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

Expand Down Expand Up @@ -31,7 +33,7 @@ gem 'rails-controller-testing'
gem 'bootstrap-sass', '3.3.7'
gem 'font-awesome-rails'

gem "bootsnap", ">= 1.1.0", require: false
gem 'bootsnap', '>= 1.1.0', require: false

gem 'better_html'

Expand All @@ -42,9 +44,9 @@ group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
gem 'rspec-rails'
gem 'guard-rspec', require: false
gem 'rspec-rails'
gem 'sqlite3'
end

group :development do
Expand All @@ -61,4 +63,4 @@ group :production do
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
10 changes: 6 additions & 4 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# A sample Guardfile
# More info at https://github.com/guard/guard#readme

Expand All @@ -24,8 +26,8 @@
# * zeus: 'zeus rspec' (requires the server to be started separately)
# * 'just' rspec: 'rspec'

guard :rspec, cmd: "bundle exec rspec" do
require "guard/rspec/dsl"
guard :rspec, cmd: 'bundle exec rspec' do
require 'guard/rspec/dsl'
dsl = Guard::RSpec::Dsl.new(self)

# Feel free to open issues for suggestions and improvements
Expand All @@ -41,7 +43,7 @@ guard :rspec, cmd: "bundle exec rspec" do
dsl.watch_spec_files_for(ruby.lib_files)

# Rails files
rails = dsl.rails(view_extensions: %w(erb haml slim))
rails = dsl.rails(view_extensions: %w[erb haml slim])
dsl.watch_spec_files_for(rails.app_files)
dsl.watch_spec_files_for(rails.views)

Expand All @@ -65,6 +67,6 @@ guard :rspec, cmd: "bundle exec rspec" do
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
end
end
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
include Sessions

private

def user_logged_in?
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/capture_the_flag_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CaptureTheFlagController < ApplicationController
before_action :user_logged_in?
def index
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CategoriesController < ApplicationController
before_action :user_logged_in?, except: %i[show]
before_action :user_has_permission?, except: %i[index show]
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/challenges_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ChallengesController < ApplicationController
before_action :user_logged_in?, except: %i[index]
before_action :user_has_permission?, except: %i[index show]
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/concerns/ctf_settings.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module CtfSettings
def ctf_name
CtfSetting.find_by(key: 'ctf_name')&.value
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/concerns/sessions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Sessions
extend ActiveSupport::Concern

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/concerns/users.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Users
extend ActiveSupport::Concern

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/ctf_settings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CtfSettingsController < ApplicationController
before_action :user_logged_in?
before_action :user_has_permission?
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/scores_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class ScoresController < ApplicationController
def index
end
def index; end
end
4 changes: 3 additions & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Session controller
class SessionsController < ApplicationController
include Sessions
Expand All @@ -10,7 +12,7 @@ def new
def create
# TODO: ALLOW USERS TO LOGIN VIA USERNAME OR EMAIL
user = User.find_by(email: params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
if user&.authenticate(params[:session][:password])
log_in user
redirect_back_or user
else
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Teams controller
class TeamsController < ApplicationController
before_action :user_logged_in?
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# User controller
class UsersController < ApplicationController
# before_action :user_logged_in?, except: %i[new create show]
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationHelper
def current_class?(path)
return 'active' if request.path == path
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/capture_the_flag_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module CaptureTheFlagHelper
end
2 changes: 2 additions & 0 deletions app/helpers/category_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module CategoryHelper
end
9 changes: 5 additions & 4 deletions app/helpers/challenges_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ChallengesHelper
def challenge_status_button_tag(challenge)
return activate_challenge_button(challenge) unless challenge.active?
Expand All @@ -14,7 +16,6 @@ def deactivate_challenge_button(challenge)
)
end


def activate_challenge_button(challenge)
challenge_status_button(
'Activate challenge',
Expand All @@ -25,8 +26,8 @@ def activate_challenge_button(challenge)

def challenge_status_button(btn_name, btn_color, path)
link_to btn_name,
path,
class: "btn #{btn_color}",
method: :patch
path,
class: "btn #{btn_color}",
method: :patch
end
end
2 changes: 2 additions & 0 deletions app/helpers/ctf_settings_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module CtfSettingsHelper
def ctf_name
CtfSetting.find_by(key: 'ctf_name')&.value
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/scores_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module ScoresHelper
end
6 changes: 4 additions & 2 deletions app/helpers/sessions_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Session helper
module SessionsHelper
def log_in(user)
Expand All @@ -16,7 +18,7 @@ def redirect_back_or(default)
end

def is_logged_in_user?(user)
return !current_user.nil? && user.id == current_user.id
!current_user.nil? && user.id == current_user.id
end

def current_user
Expand All @@ -29,6 +31,6 @@ def logged_in?
end

def store_location
session[:forwarding_url] = request.original_url if request.get? && request.original_fullpath != '/login'
session[:forwarding_url] = request.original_url if request.get? && request.original_fullpath != '/login'
end
end
2 changes: 2 additions & 0 deletions app/helpers/teams_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module TeamsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# User helper
module UsersHelper
def gravatar_for(user, size: 40, margin: nil, gravatar_size: 400)
Expand Down
2 changes: 2 additions & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
end
2 changes: 2 additions & 0 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
Expand Down
2 changes: 2 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
2 changes: 2 additions & 0 deletions app/models/capture_the_flag.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CaptureTheFlag < ApplicationRecord
validates :name, presence: true, length: { maximum: 255 }
validates :info, presence: true
Expand Down
2 changes: 2 additions & 0 deletions app/models/category.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Category < ApplicationRecord
has_many :challenges

Expand Down
2 changes: 2 additions & 0 deletions app/models/challenge.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Challenge < ApplicationRecord
belongs_to :category

Expand Down
2 changes: 2 additions & 0 deletions app/models/concerns/tokenable.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Tokenable
extend ActiveSupport::Concern

Expand Down
2 changes: 2 additions & 0 deletions app/models/ctf_admin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CtfAdmin < ApplicationRecord
belongs_to :users
belongs_to :capture_the_flag
Expand Down
2 changes: 2 additions & 0 deletions app/models/ctf_point.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CtfPoint < ApplicationRecord
belongs_to :users
belongs_to :challenges
Expand Down
2 changes: 2 additions & 0 deletions app/models/ctf_setting.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CtfSetting < ApplicationRecord
validates :key, presence: true, uniqueness: true
end
2 changes: 2 additions & 0 deletions app/models/hint.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Hint < ApplicationRecord
belongs_to :challenges
end
2 changes: 2 additions & 0 deletions app/models/session.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Session < ApplicationRecord
belongs_to :user
end
4 changes: 3 additions & 1 deletion app/models/team.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

class Team < ApplicationRecord
has_many :users
validates :name, presence: true,
uniqueness: { case_sensitive: false }
uniqueness: { case_sensitive: false }
validates :invitation_token,
uniqueness: { case_sensitive: false }

Expand Down
2 changes: 2 additions & 0 deletions app/models/team_member.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class TeamMember < ApplicationRecord
belongs_to :team
belongs_to :user
Expand Down
4 changes: 3 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# User models
class User < ApplicationRecord
before_save { email.downcase! }
Expand Down Expand Up @@ -28,6 +30,6 @@ def organizer?
end

def to_param
"#{username}".parameterize
username.to_s.parameterize
end
end
2 changes: 2 additions & 0 deletions bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')
2 changes: 2 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
2 changes: 2 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative '../config/boot'
require 'rake'
Rake.application.run
2 changes: 2 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'fileutils'
include FileUtils

Expand Down
Loading

0 comments on commit ad2a7be

Please sign in to comment.