Skip to content

Commit

Permalink
rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Navya N authored and Navya N committed Oct 4, 2024
1 parent 8d50407 commit 6a90855
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 24 deletions.
2 changes: 2 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

# UsersController handles displaying user-related data.
# The show action retrieves and displays the current user based on the ID provided in the parameters.
class UsersController < ApplicationController
def show
@current_user = User.find(params[:id])
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

# WelcomeController handles displaying the public welcome page.
# It skips the login requirement for the index action and redirects logged-in users
# to their user page with a personalized welcome message.
class WelcomeController < ApplicationController
# Don't require login for the public welcome page
skip_before_action :require_login, only: [:index]
Expand Down
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# ApplicationHelper is used to store helper methods that can be used across views.
module ApplicationHelper
end
1 change: 1 addition & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

# ApplicationRecord serves as the base class for all models in the application.
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

# The User model represents users in the application.
class User < ApplicationRecord
validates :email, presence: true
end
54 changes: 30 additions & 24 deletions bin/bundle
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,39 @@ m = Module.new do
end

def cli_arg_version
return unless invoked_as_script? # don't want to hijack other binstubs
return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update`
return unless invoked_as_script? && 'update'.start_with?(ARGV.first || ' ')

extract_bundler_version
end

def extract_bundler_version
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
bundler_version = a if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/

bundler_version = Regexp.last_match(1)
update_index = i
ARGV.each_with_index do |arg, index|
if update_index && update_index.succ == index && arg.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
bundler_version = arg
end

if arg =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
bundler_version = Regexp.last_match(1)
update_index = index
end
end

bundler_version
end

def gemfile
gemfile = ENV['BUNDLE_GEMFILE']
return gemfile if gemfile && !gemfile.empty?

File.expand_path('../Gemfile', __dir__)
gemfile && !gemfile.empty? ? gemfile : File.expand_path('../Gemfile', __dir__)
end

def lockfile
lockfile =
case File.basename(gemfile)
when 'gems.rb' then gemfile.sub(/\.rb$/, '.locked')
else "#{gemfile}.lock"
end
lockfile = case File.basename(gemfile)
when 'gems.rb' then gemfile.sub(/\.rb$/, '.locked')
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
end

Expand All @@ -73,33 +78,34 @@ m = Module.new do
return "#{Gem::Requirement.default}.a" unless version

bundler_gem_version = Gem::Version.new(version)

bundler_gem_version.approximate_recommendation
end

def load_bundler!
ENV['BUNDLE_GEMFILE'] ||= gemfile

activate_bundler
end

def activate_bundler
gem_error = activation_error_handling do
gem 'bundler', bundler_requirement
end
gem_error = activation_error_handling { gem 'bundler', bundler_requirement }
return if gem_error.nil?

require_error = activation_error_handling do
require 'bundler/version'
end
require_error = activation_error_handling { require 'bundler/version' }
if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
return
end

warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
warn_bundler_activation_error(gem_error)
exit 42
end

def warn_bundler_activation_error(gem_error)
warn "Activating bundler (#{bundler_requirement}) failed:\n" \
"#{gem_error.message}\n\n" \
'To install the version of bundler this project requires, run ' \
"`gem install bundler -v '#{bundler_requirement}'`"
end

def activation_error_handling
yield
nil
Expand Down

0 comments on commit 6a90855

Please sign in to comment.