Class: GemCompatScan::Checker
- Inherits:
-
Object
- Object
- GemCompatScan::Checker
- Defined in:
- lib/gem_compat_scan/checker.rb
Class Method Summary collapse
- .check_updates ⇒ Object
- .extract_github_url(repo_url) ⇒ Object
- .fetch_github_url(gem_name) ⇒ Object
- .fetch_latest_version(gem_name) ⇒ Object
Class Method Details
.check_updates ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gem_compat_scan/checker.rb', line 6 def self.check_updates Bundler.setup # Load Gemfile.lock updates = [] Bundler.locked_gems.specs.each do |spec| gem_name = spec.name current_version = spec.version.to_s latest_version = fetch_latest_version(gem_name) if latest_version && latest_version > current_version github_url = fetch_github_url(gem_name) updates << { gem: gem_name, current_version: current_version, latest_version: latest_version, github_url: github_url } end end updates end |
.extract_github_url(repo_url) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/gem_compat_scan/checker.rb', line 43 def self.extract_github_url(repo_url) if repo_url =~ %r{github\.com/([^/]+)/([^/]+)} repo_owner = Regexp.last_match(1) repo_name = Regexp.last_match(2) "https://github.com/#{repo_owner}/#{repo_name}" else nil # Return nil if the repository URL format is not recognized end end |
.fetch_github_url(gem_name) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/gem_compat_scan/checker.rb', line 35 def self.fetch_github_url(gem_name) gem_info = Gems.info(gem_name) repo_url = gem_info['source_code_uri'] extract_github_url(repo_url) rescue Gems::NotFound nil # Return nil if gem is not found end |
.fetch_latest_version(gem_name) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/gem_compat_scan/checker.rb', line 28 def self.fetch_latest_version(gem_name) gem_info = Gems.info(gem_name) gem_info['version'] rescue Gems::NotFound nil # Return nil if gem is not found end |