Sha256: f9a762d31b5beba5fecb0ff6f673aeec258a100877573a09cdc6f49440eed3b4
Contents?: true
Size: 1.37 KB
Versions: 5
Compression:
Stored size: 1.37 KB
Contents
module GemVersionCheck class LockfileFetcher class NotFoundError < StandardError; end def initialize(project) @project = project end def content uri = URI.parse(repository) body = request(uri) raise NotFoundError.new(repository) if body.nil? body end def repository @repository ||= begin if @project =~ /^http(s)?:\/\// @project else gemfile_lock_url end end end # github.com redirects github.com/user/project/raw/master/Gemfile.lock to raw.github.com/user/project/master/Gemfile.lock # github enterprise does not redirect # TODO: change if github enterprise redirects too def gemfile_lock_url if GemVersionCheck.configuration.github_host == "github.com" "https://raw.#{GemVersionCheck.configuration.github_host}/#{@project}/master/Gemfile.lock" else "https://#{GemVersionCheck.configuration.github_host}/raw/#{@project}/master/Gemfile.lock" end end def request(uri) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.scheme == 'https' request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) if response.code == "200" response.body else puts "Error retrieving Gemfile.lock: #{response.inspect}" nil end end end end
Version data entries
5 entries across 5 versions & 1 rubygems