Class: Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/dependency.rb

Constant Summary collapse

DESCRIPTION_TYPE_WIDTH =
8

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Dependency

Returns a new instance of Dependency.


14
15
16
# File 'lib/dependency.rb', line 14

def initialize(name)
	@name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


12
13
14
# File 'lib/dependency.rb', line 12

def name
  @name
end

Instance Method Details

#always_act?Boolean

if true, this type of resource must always have `meet` and `unmeet` called; useful for resources that can't easily be checked to see if they're met

Returns:

  • (Boolean)

40
41
42
# File 'lib/dependency.rb', line 40

def always_act?
	false
end

#exit_codeObject


56
57
58
# File 'lib/dependency.rb', line 56

def exit_code
	@executor&.exit_code
end

#meetObject

Raises:

  • (NotImplementedError)

22
23
24
# File 'lib/dependency.rb', line 22

def meet
	raise NotImplementedError
end

#met?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)

18
19
20
# File 'lib/dependency.rb', line 18

def met?
	raise NotImplementedError
end

#outputObject


52
53
54
# File 'lib/dependency.rb', line 52

def output
	@executor&.output
end

#should_meet?Boolean

should_meet? can be used to implement dependencies that should only be met on some platforms, e.g. brew on Macs and apt on Linux it can be used to base a decision on anything else that can be read from the environment at runtime

Returns:

  • (Boolean)

34
35
36
# File 'lib/dependency.rb', line 34

def should_meet?
	true
end

#success?Boolean

Returns:

  • (Boolean)

48
49
50
# File 'lib/dependency.rb', line 48

def success?
	@executor.nil? ? true : @executor.success?
end

#typeObject


44
45
46
# File 'lib/dependency.rb', line 44

def type
	self.class.name.split('::').last
end

#unmeetObject

Raises:

  • (NotImplementedError)

26
27
28
# File 'lib/dependency.rb', line 26

def unmeet
	raise NotImplementedError
end