Sha256: f53ad416d4673ba2893c335f03b89bdd7c5d1dc544e7f794962f62617e448a52
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
require "lapidarius/gem" require "lapidarius/command" require "rubygems/requirement" module Lapidarius class Cutter DEVELOPMENT = "development" attr_reader :version, :remote def initialize(name:, cmd_klass: Command, version: nil, remote: nil) @name = name @cmd = cmd_klass.new @version = version @remote = remote @dev_deps = [] @cache = {} end def call recurse.tap do |gem| gem.dev_count = dev_count if gem end end private def recurse(name: @name, gem: nil, version: @version) tokens = tokenize(name, version, @remote) token = tokens.shift gem ||= Gem.factory(token) tokens.each do |t| next unless dep = Gem.factory(t) gem << @cache.fetch(t) do recurse(name: dep.name, gem: dep, version: dep.version) @cache[t] = dep end end gem end def dev_count @dev_deps.map { |e| e.split(" ").first }.uniq.count end private def tokenize(name, version, remote) src = @cmd.call(name, version, remote) data = normalize(src) dev, tokens = data.partition { |token| token.match(/#{DEVELOPMENT}/) } @dev_deps.concat(dev) tokens end private def normalize(src) src.split(/\n\n/).map!(&:strip).first.split("\n").map(&:strip) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lapidarius-4.4.3 | lib/lapidarius/cutter.rb |
lapidarius-4.4.2 | lib/lapidarius/cutter.rb |