Sha256: 5ddfda95d637be6f30e45803d49d473c1691266a2b9130228a036b23d27ef9c0

Contents?: true

Size: 869 Bytes

Versions: 8

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

require "bundler/ui/shell"
require "tocer"

module Gemsmith
  module Rake
    # Provides gem build functionality. Meant to be wrapped in Rake tasks.
    class Build
      def initialize tocer: Tocer::Writer, shell: Bundler::UI::Shell, kernel: Kernel
        @tocer = tocer
        @shell = shell.new
        @kernel = kernel
      end

      def doc
        readme = File.join Dir.pwd, "README.md"
        tocer.new(readme).write
        shell.confirm "Updated gem documentation."
      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

      private

      attr_reader :tocer, :shell, :kernel
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gemsmith-7.7.0 lib/gemsmith/rake/build.rb
gemsmith-7.6.0 lib/gemsmith/rake/build.rb
gemsmith-7.5.0 lib/gemsmith/rake/build.rb
gemsmith-7.4.0 lib/gemsmith/rake/build.rb
gemsmith-7.3.0 lib/gemsmith/rake/build.rb
gemsmith-7.2.0 lib/gemsmith/rake/build.rb
gemsmith-7.1.0 lib/gemsmith/rake/build.rb
gemsmith-7.0.0 lib/gemsmith/rake/build.rb