Class: GemDigest::Analyzer
- Inherits:
-
Object
- Object
- GemDigest::Analyzer
- Defined in:
- lib/gem_digest/analyzer.rb
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(gemfile_lock_path = "Gemfile.lock") ⇒ Analyzer
constructor
A new instance of Analyzer.
Constructor Details
#initialize(gemfile_lock_path = "Gemfile.lock") ⇒ Analyzer
Returns a new instance of Analyzer.
10 11 12 13 |
# File 'lib/gem_digest/analyzer.rb', line 10 def initialize(gemfile_lock_path = "Gemfile.lock") @gemfile_lock_path = gemfile_lock_path raise Error, "Gemfile.lock not found at #{gemfile_lock_path}" unless File.exist?(gemfile_lock_path) end |
Instance Method Details
#analyze ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gem_digest/analyzer.rb', line 15 def analyze lockfile = Bundler::LockfileParser.new(File.read(@gemfile_lock_path)) gems_data = [] lockfile.specs.each do |spec| latest_version = fetch_latest_version(spec.name) next unless latest_version gems_data << { name: spec.name, current_version: spec.version.to_s, latest_version: latest_version, source: spec.source&.to_s || "rubygems" } end gems_data end |