Sha256: c17c037b3705c29dd107e9db7085e5d7246f5a70a05269f73f600190392b9710
Contents?: true
Size: 907 Bytes
Versions: 6
Compression:
Stored size: 907 Bytes
Contents
require "lapidarius/gem" require "lapidarius/command" module Lapidarius class Cutter DEVELOPMENT = "development" class GemNotCreatedError < StandardError; end def initialize(name, cmd_klass = Command) @name = name @cmd = cmd_klass.new end def call(name = @name, gem = nil) tokens = tokenize(name) token = tokens.shift gem ||= Gem.factory(token) fail GemNotCreatedError, "unable to create a gem from #{token}" unless gem tokens.each do |t| dep = Gem.factory(t) next unless dep gem << dep call(dep.name, dep) end gem end private def tokenize(name) src = @cmd.call(name) data = src.split(/\n\n/).map!(&:strip) data.first.split("\n").tap do |tokens| tokens.map!(&:strip) tokens.reject! { |token| token.match(/#{DEVELOPMENT}/) } end end end end
Version data entries
6 entries across 6 versions & 1 rubygems