Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Rename env_version to source
Browse files Browse the repository at this point in the history
This is usually provided as an `ENV` variable but that's completely
transparent to this class. Also, this is not always a version number. I
think something like "source" is a better fit.
  • Loading branch information
deivid-rodriguez committed Dec 1, 2019
1 parent 2d44bc0 commit 45761fa
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions spec/support/rubygems_version_manager.rb
Expand Up @@ -8,8 +8,8 @@ class RubygemsVersionManager
include Spec::Helpers
include Spec::Path

def initialize(env_version)
@env_version = env_version
def initialize(source)
@source = source
end

def switch
Expand All @@ -23,7 +23,7 @@ def switch
private

def use_system?
@env_version.nil?
@source.nil?
end

def unrequire_rubygems_if_needed
Expand Down Expand Up @@ -57,7 +57,7 @@ def rubygems_unrequire_needed?
end

def local_copy_switch_needed?
!env_version_is_path? && target_tag != local_copy_tag
!source_is_path? && target_tag != local_copy_tag
end

def target_tag
Expand All @@ -75,7 +75,7 @@ def local_copy_path
end

def resolve_local_copy_path
return expanded_env_version if env_version_is_path?
return expanded_source if source_is_path?

rubygems_path = root.join("tmp/rubygems")

Expand All @@ -87,17 +87,17 @@ def resolve_local_copy_path
rubygems_path
end

def env_version_is_path?
expanded_env_version.directory?
def source_is_path?
expanded_source.directory?
end

def expanded_env_version
@expanded_env_version ||= Pathname.new(@env_version).expand_path(root)
def expanded_source
@expanded_source ||= Pathname.new(@source).expand_path(root)
end

def resolve_target_tag
return "v#{@env_version}" if @env_version.match(/^\d/)
return "v#{@source}" if @source.match(/^\d/)

@env_version
@source
end
end

0 comments on commit 45761fa

Please sign in to comment.