Class: Monolith::Formatter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFormatter

Returns a new instance of Formatter.



6
7
8
9
10
# File 'lib/monolith/formatter.rb', line 6

def initialize
  @quiet = false
  @debug = false
  @base_path = Pathname.new(Dir.pwd)
end

Instance Attribute Details

#debug(msg) ⇒ Object

Returns the value of attribute debug.



4
5
6
# File 'lib/monolith/formatter.rb', line 4

def debug
  @debug
end

#quietObject

Returns the value of attribute quiet.



3
4
5
# File 'lib/monolith/formatter.rb', line 3

def quiet
  @quiet
end

Instance Method Details

#clean(cookbook, destination) ⇒ Object



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

def clean(cookbook, destination)
  msg "Removing #{cookbook.cookbook_name} from #{rel_dir(destination)}"
end

#error(msg) ⇒ Object



42
43
44
# File 'lib/monolith/formatter.rb', line 42

def error(msg)
  STDERR.puts msg
end

#install(cookbook, destination) ⇒ Object



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

def install(cookbook, destination)
  msg "Installing #{cookbook.cookbook_name} to #{rel_dir(destination)}"
end

#msg(msg) ⇒ Object



38
39
40
# File 'lib/monolith/formatter.rb', line 38

def msg(msg)
  puts msg unless @quiet
end

#rel_dir(dir) ⇒ Object



46
47
48
# File 'lib/monolith/formatter.rb', line 46

def rel_dir(dir)
  return Pathname.new(dir).relative_path_from(@base_path)
end

#skip(cookbook, reason) ⇒ Object



24
25
26
# File 'lib/monolith/formatter.rb', line 24

def skip(cookbook, reason)
  msg "Skipping #{cookbook.cookbook_name} (#{reason})"
end

#unsupported_location(cookbook, dep) ⇒ Object



28
29
30
31
32
# File 'lib/monolith/formatter.rb', line 28

def unsupported_location(cookbook, dep)
  loctype = dep.location.class.name.split('::')[-1]
  msg "Unsupported location type #{loctype} for cookbook " \
    "#{cookbook.cookbook_name}. Skipping."
end

#update(cookbook, destination) ⇒ Object



16
17
18
# File 'lib/monolith/formatter.rb', line 16

def update(cookbook, destination)
  msg "Updating #{cookbook.cookbook_name} at #{rel_dir(destination)}"
end