Class: Gemsmith::Rake::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/gemsmith/rake/build.rb

Overview

Provides gem build functionality. Meant to be wrapped in Rake tasks.

Instance Method Summary collapse

Constructor Details

#initialize(tocer: Tocer::Writer, shell: Bundler::UI::Shell, kernel: Kernel) ⇒ Build

Returns a new instance of Build.



8
9
10
11
12
# File 'lib/gemsmith/rake/build.rb', line 8

def initialize tocer: Tocer::Writer, shell: Bundler::UI::Shell, kernel: Kernel
  @tocer = tocer
  @shell = shell.new
  @kernel = kernel
end

Instance Method Details

#cleanObject



20
21
22
23
# File 'lib/gemsmith/rake/build.rb', line 20

def clean
  FileUtils.rm_rf "pkg"
  shell.confirm "Cleaned gem artifacts."
end

#docObject



14
15
16
17
18
# File 'lib/gemsmith/rake/build.rb', line 14

def doc
  readme = File.join Dir.pwd, "README.md"
  tocer.new(readme).write
  shell.confirm "Updated gem documentation."
end

#validateObject



25
26
27
28
29
# File 'lib/gemsmith/rake/build.rb', line 25

def validate
  return if `git status --porcelain`.empty?
  shell.error "Build failed: Gem has uncommitted changes."
  kernel.exit 1
end