class Skippable::Task

Attributes

command[R]
name[R]
paths[R]

Public Class Methods

new(name:, command:, paths:) click to toggle source
# File lib/skippable/task.rb, line 5
def initialize(name:, command:, paths:)
  @name = name
  @command = command
  @paths = paths
end

Public Instance Methods

call() click to toggle source
# File lib/skippable/task.rb, line 11
def call
  if file_digests.none?(&:changed?)
    puts "Skipping #{name}..."
    return 0
  end

  execute_command

  if $?.success?
    file_digests.each(&:update_cached_digest)
  end

  $?.exitstatus
end

Private Instance Methods

execute_command() click to toggle source
# File lib/skippable/task.rb, line 30
def execute_command
  system(command)
end
file_digests() click to toggle source
# File lib/skippable/task.rb, line 34
def file_digests
  @file_digests ||= paths.map { |path| FileDigest.new(path: path) }
end