class Gemsmith::Rake::Builder
Provides gem build functionality. Meant to be wrapped in Rake
tasks.
Attributes
kernel[R]
root[R]
shell[R]
Public Class Methods
new(root: Pathname("pkg"), shell: Bundler::UI::Shell.new, kernel: Kernel)
click to toggle source
# File lib/gemsmith/rake/builder.rb, line 12 def initialize root: Pathname("pkg"), shell: Bundler::UI::Shell.new, kernel: Kernel @root = root @shell = shell @kernel = kernel end
Public Instance Methods
build(gem_spec)
click to toggle source
# File lib/gemsmith/rake/builder.rb, line 30 def build gem_spec path = gem_spec.package_path if kernel.system "gem build #{gem_spec.name}.gemspec" root.make_path Pathname(gem_spec.package_file_name).copy path shell.confirm "Built: #{path}." else shell.error "Unable to build: #{path}." end end
clean()
click to toggle source
# File lib/gemsmith/rake/builder.rb, line 18 def clean root.remove_tree shell.confirm "Cleaned gem artifacts." end
install(gem_spec)
click to toggle source
# File lib/gemsmith/rake/builder.rb, line 42 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
validate()
click to toggle source
# File lib/gemsmith/rake/builder.rb, line 23 def validate return if `git status --porcelain`.empty? shell.error "Build failed: Gem has uncommitted changes." kernel.exit 1 end