Skip to content

Commit

Permalink
discards no constrains constrains
Browse files Browse the repository at this point in the history
  • Loading branch information
colinsurprenant committed Apr 29, 2016
1 parent 6ab7bc9 commit c4dd96a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/pluginmanager/gemfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def add_gem(_gem)
# update existing or add new
def update_gem(_gem)
if old = find_gem(_gem.name)
# always overwrite requirements
old.requirements = _gem.requirements
# always overwrite requirements if specified
old.requirements = _gem.requirements unless no_constrains?(_gem.requirements)
# but merge options
old.options = old.options.merge(_gem.options)
else
Expand Down Expand Up @@ -139,8 +139,19 @@ def remove_gem(name)
def copy
Marshal.load(Marshal.dump(self))
end

private

def no_constrains?(requirements)
return true if requirements.nil? || requirements.empty?

# check for the dummy ">= 0" version constrain or any variations thereof
# which is in fact a "no constrain" constrain which we should discard
return true if requirements.size == 1 && requirements.first.to_s.gsub(/\s+/, "") == ">=0"

false
end

def sources_to_s
return "" if @sources.empty?
@sources.map{|source| "source #{source.inspect}"}.join("\n")
Expand Down

0 comments on commit c4dd96a

Please sign in to comment.