Sha256: 42f549e658fa16d1420e0675fbdeff992b72ab1fb97005f820813e4ec33e17ba

Contents?: true

Size: 838 Bytes

Versions: 3

Compression:

Stored size: 838 Bytes

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
gemsmith-6.2.0 lib/gemsmith/rake/build.rb
gemsmith-6.1.0 lib/gemsmith/rake/build.rb
gemsmith-6.0.0 lib/gemsmith/rake/build.rb