Class: Monolith::BaseLocation

Inherits:
Object
  • Object
show all
Defined in:
lib/monolith/locations/base.rb

Direct Known Subclasses

DefaultLocation, GitLocation, PathLocation

Instance Method Summary collapse

Constructor Details

#initialize(cookbook, dep, destination) ⇒ BaseLocation

Returns a new instance of BaseLocation.



3
4
5
6
7
8
# File 'lib/monolith/locations/base.rb', line 3

def initialize(cookbook, dep, destination)
  @dep = dep
  @location = dep.location unless dep.nil?
  @cookbook = cookbook
  @destination = destination
end

Instance Method Details

#cleanObject

Remove a previously installed cookbook. If a cookbook was never installed in the first place (either because install wasn’t run, or because of the location type), then this should do nothing.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/monolith/locations/base.rb', line 27

def clean
  if File.exist?(@destination)
    Monolith.formatter.clean(@cookbook, @destination)
    FileUtils.rm_rf(@destination)
    true
  else
    rel_dest = Monolith.formatter.rel_dir(@destination)
    Monolith.formatter.skip(@cookbook, "#{rel_dest} doesn't exist")
    nil
  end
end

#installObject

Install the cookbook in the development environment. If possible, the installed cookbook should look exactly as it would when used for development (e.g. a git checkout with all git metadata, no compiled artefacts).



14
15
16
# File 'lib/monolith/locations/base.rb', line 14

def install
  nil
end

#updateObject

Update the cookbook in the development environment to the latest version. E.g. if git is used, run git pull.



20
21
22
# File 'lib/monolith/locations/base.rb', line 20

def update
  nil
end