Sha256: 83c8a4041992f32bf7ec28a64a6ed3c84ea440a7f4233bf35be119acfc8681fb
Contents?: true
Size: 1.27 KB
Versions: 24
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true require "bundler/ui/shell" require "fileutils" module Gemsmith module Rake # Provides gem build functionality. Meant to be wrapped in Rake tasks. class Builder def initialize shell: Bundler::UI::Shell.new, kernel: Kernel @shell = shell @kernel = kernel end def clean FileUtils.rm_rf "pkg" shell.confirm "Cleaned gem artifacts." end def validate return if `git status --porcelain`.empty? shell.error "Build failed: Gem has uncommitted changes." kernel.exit 1 end def build gem_spec path = gem_spec.package_path if kernel.system "gem build #{gem_spec.name}.gemspec" FileUtils.mkdir_p "pkg" FileUtils.mv gem_spec.package_file_name, path shell.confirm "Built: #{path}." else shell.error "Unable to build: #{path}." end end def install gem_spec gem_name = "#{gem_spec.name} #{gem_spec.version}" if kernel.system "gem install #{gem_spec.package_path}" shell.confirm "Installed: #{gem_name}." else shell.error "Unable to install: #{gem_name}." end end private attr_reader :shell, :kernel end end end
Version data entries
24 entries across 24 versions & 1 rubygems