Sha256: 41cbceab6878654eabe432be7d1f84bdbb1ac4056d162457d12037edb7249930
Contents?: true
Size: 922 Bytes
Versions: 4
Compression:
Stored size: 922 Bytes
Contents
require "lapidarius/gem" require "lapidarius/command" module Lapidarius class Cutter DEVELOPMENT = "development" class GemNotCreatedError < StandardError; end def initialize(gem:, cmd_klass: Command) @gem = gem @cmd = cmd_klass.new end def call(src = cmd, gem = nil) tokens = tokenize(src) 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(cmd(dep.name), dep) end gem end private def tokenize(src) src = src.split(/\n\n/).first src.split("\n").tap do |tokens| tokens.map!(&:strip) tokens.reject! { |token| token.match(/#{DEVELOPMENT}/) } end end private def cmd(gem = @gem) @cmd.call(gem) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
lapidarius-1.1.4 | lib/lapidarius/cutter.rb |
lapidarius-1.1.3 | lib/lapidarius/cutter.rb |
lapidarius-1.1.2 | lib/lapidarius/cutter.rb |
lapidarius-1.1.1 | lib/lapidarius/cutter.rb |