Skip to content

Commit

Permalink
check RUBY_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
forelabs committed May 20, 2020
1 parent f108418 commit c3afcc5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/license_finder/decisions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,7 @@ def unname_project(txn = {})
def inherit_from(filepath)
decisions =
if filepath =~ %r{^https?://}
# ruby < 2.5.0 URI.open is private
# rubocop:disable Security/Open
open(filepath).read
# rubocop:enable Security/Open
open_uri(filepath).read
else
Pathname(filepath).read
end
Expand All @@ -216,6 +213,17 @@ def restore_inheritance(decisions)
self
end

def open_uri(uri)
# ruby < 2.5.0 URI.open is private
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.5.0')
# rubocop:disable Security/Open
open(uri)
# rubocop:enable Security/Open
else
URI.open(uri)
end
end

#########
# PERSIST
#########
Expand Down

0 comments on commit c3afcc5

Please sign in to comment.