Skip to content

Commit

Permalink
Rubocop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
onlynone committed Apr 24, 2024
1 parent 35d73c5 commit 0e7e8ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
14 changes: 6 additions & 8 deletions lib/pry/commands/whereami.rb
Expand Up @@ -63,9 +63,7 @@ def setup
#
# __FILE__: "spec/fixtures/example.erb"
# __dir__: "spec/fixtures"
if !dir.nil? && absolute_path?(dir)
file = File.join(dir, file)
end
file = File.join(dir, file) if !dir.nil? && absolute_path?(dir)
end

@file = expand_path(file)
Expand Down Expand Up @@ -215,7 +213,7 @@ def expand_path(filename)
# test/pathname/test_pathname.rb in the ruby source code (which looks to
# be under the 2-clause BSD license, not sure the best way to comply with
# the licensing terms for just 3 lines of code).
DOSISH = File::ALT_SEPARATOR != nil
DOSISH = !File::ALT_SEPARATOR.nil?
DOSISH_DRIVE_LETTER = File.dirname("A:") == "A:."
DOSISH_UNC = File.dirname("//") == "//"

Expand All @@ -224,18 +222,18 @@ def absolute_path?(path)
return File.absolute_path?(path) if File.respond_to?(:absolute_path?)

if DOSISH_DRIVE_LETTER
return true if path =~ /^[a-z]:[\/\\]/i
return true if path =~ %r{^[a-z]:[/\\]}i
end

if DOSISH_UNC
return true if path =~ /^[\/\\]{2}/i
return true if path =~ %r{^[/\\]{2}}i
end

if !DOSISH
unless DOSISH
return true if path[0] == '/'
end

return false
false
end

def window_size
Expand Down
1 change: 0 additions & 1 deletion spec/commands/whereami_spec.rb
Expand Up @@ -288,5 +288,4 @@ def blimey!
expect(status.success?).to be true
expect(output.strip).to eq File.join(script_dir, script)
end

end
6 changes: 3 additions & 3 deletions spec/fixtures/whereami_main_chdir.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true

if $PROGRAM_NAME != __FILE__
fail "#{__FILE__} should only be executed as a top level program"
raise "#{__FILE__} should only be executed as a top level program"
end

$LOAD_PATH.unshift File.expand_path(File.join(__dir__, '..', '..', 'lib'))

require 'pry'
require 'pry/testable'

include Pry::Testable::Evalable

class Cor
include Pry::Testable::Evalable

def blimey!
Dir.chdir '..' do
pry_eval(binding, 'whereami', '_file_')
Expand Down

0 comments on commit 0e7e8ec

Please sign in to comment.