Class: LogicalConstruct::SatisfiableTask

Inherits:
Rake::Task
  • Object
show all
Includes:
Mattock::TaskMixin
Defined in:
lib/logical-construct/satisfiable-task.rb

Overview

This task won’t kill the run if it fails - the assumption is that there’s a ResolvingTask that depends on this task to make it work.

Based on my reasoning about Rake (c.f. ResolvingTask): Each ST should have a configured #needed? that checks it’s responsibility Execute needs to catch errors

Direct Known Subclasses

Manifest, SatisfiableEnvTask, SatisfiableFileTask

Instance Method Summary collapse

Instance Method Details

#criteria(me) ⇒ Object



50
51
# File 'lib/logical-construct/satisfiable-task.rb', line 50

def criteria(me)
end

#execute(args = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/logical-construct/satisfiable-task.rb', line 13

def execute(args=nil)
  super
  if application.options.trace and needed?
    $stderr.puts "** Unsatisfied: #{name}"
  end
rescue Object => ex
  warn "#{ex.class}: #{ex.message} while performing #{name}"
  #Swallowed
end

#fulfill(string) ⇒ Object



43
44
# File 'lib/logical-construct/satisfiable-task.rb', line 43

def fulfill(string)
end

#needed?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/logical-construct/satisfiable-task.rb', line 46

def needed?
  return !criteria(self)
end

#prefer_file?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/logical-construct/satisfiable-task.rb', line 23

def prefer_file?
  false
end

#receive(data) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/logical-construct/satisfiable-task.rb', line 27

def receive(data)
  return unless needed?
  fulfill(data)
  if data.respond_to? :path
    fulfill_file(data)
  elsif data.respond_to? :read
    fulfill(data.read)
  else
    fulfill(data.to_s)
  end
end

#receive_file(file) ⇒ Object



39
40
41
# File 'lib/logical-construct/satisfiable-task.rb', line 39

def receive_file(file)
  fulfill(file.read)
end