bundler-alive 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "faraday"
4
- require "json"
5
-
6
- module Bundler
7
- module Alive
8
- module Client
9
- #
10
- # API Client for RubyGems.org API
11
- #
12
- # @see https://guides.rubygems.org/rubygems-org-api/
13
- #
14
- class GemsApi
15
- #
16
- # Not found in rubygems.org error
17
- #
18
- class NotFound < StandardError
19
- end
20
-
21
- #
22
- # Returns repository url
23
- #
24
- # @param [String] gem_name
25
- #
26
- # @return [SourceCodeRepositoryUrl]
27
- #
28
- def get_repository_url(gem_name)
29
- url = api_url(gem_name)
30
- response = connection.get(url)
31
-
32
- raise NotFound, "#{gem_name} is not found in gems.org." if response.status == 404
33
-
34
- body = JSON.parse(response.body)
35
- raw_url = body["source_code_uri"] || body["homepage_uri"]
36
- SourceCodeRepositoryUrl.new(raw_url)
37
- end
38
-
39
- private
40
-
41
- def api_url(gem_name)
42
- "https://rubygems.org/api/v1/gems/#{gem_name}.json"
43
- end
44
-
45
- def connection
46
- return @connection if instance_variable_defined?(:@connection)
47
-
48
- @connection = Faraday.new do |connection|
49
- connection.adapter :net_http
50
- end
51
- end
52
- end
53
- end
54
- end
55
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "forwardable"
4
-
5
- module Bundler
6
- module Alive
7
- # Collection of GemStatus
8
- class GemStatusCollection
9
- extend Forwardable
10
- delegate each: :gems
11
-
12
- def initialize(gems = {})
13
- @gems = gems
14
- freeze
15
- end
16
-
17
- def add(name, gem_status)
18
- gems[name] = gem_status
19
-
20
- self.class.new(gems)
21
- end
22
-
23
- def get_unchecked(name)
24
- return nil unless gems.key?(name)
25
-
26
- gem_status = gems[name]
27
- return nil if gem_status.unknown?
28
-
29
- gem_status
30
- end
31
-
32
- def to_h
33
- hash = {}
34
- gems.each do |k, v|
35
- hash[k] = v.to_h
36
- end
37
- hash
38
- end
39
-
40
- def need_to_report_gems
41
- gems.find_all { |_name, gem| !!!gem.alive }
42
- end
43
-
44
- private
45
-
46
- attr_reader :gems
47
- end
48
- end
49
- end