Sha256: 61705fc89d01b51fa6fb88e5d7132463a11b081bee25943dc72fcd5f8504bb84
Contents?: true
Size: 729 Bytes
Versions: 1
Compression:
Stored size: 729 Bytes
Contents
class Parser def initialize(gemfile_path) @gemfile_path = gemfile_path end def unfrozen_gems_hash return {} unless gemfile? hash = {} gems = unfrozen_gems regex = /(\w+(\-\w+)*)\s+\((\d+\.\d+\.\d+(\.\d+)*)\)/m gems_info = Dir.chdir(File.dirname(@gemfile_path)) do `bundle exec gem list`.scan(regex) end gems_info.each do |info| info.compact! name, version = info.first, info.last hash[name] = version if gems.include?(name) end hash end def unfrozen_gems return [] unless gemfile? regex = /^\s*gem ['"]([-\w]+)['"](,.*)?/ gems = File.read(@gemfile_path).scan(regex).map do |g| g.first if g.last.nil? end gems.compact end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
frozen_gems-0.0.2 | lib/frozen_gems/parser.rb |