Class: Monolith::Command

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Command

Returns a new instance of Command.



32
33
34
35
36
37
# File 'lib/monolith/commands.rb', line 32

def initialize(*args)
  super(*args)

  Monolith.formatter.quiet = @options[:quiet]
  Monolith.formatter.debug = @options[:debug]
end

Instance Method Details

#clean(path = File.join(Dir.pwd, "cookbooks")) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/monolith/commands.rb', line 63

def clean(path = File.join(Dir.pwd, "cookbooks"))
  berksfile = Monolith::Berksfile.new(options.dup)
  # This is counter-intuitive given we're actually getting rid of the
  # cookbooks. This performs the dependency resolution needed to work out
  # what we need to remove.
  berksfile.install
  gitpath = File.expand_path('../.git', berksfile.berksfile.filepath)
  gitexclude = GitExclude.new(gitpath, options)
  berksfile.cookbooks(path) do |cookbook, dep, destination|
    changed = berksfile.monolith_action(:clean, cookbook, dep, destination)
    gitexclude.remove(destination) if changed
  end
  gitexclude.update
end

#install(path = File.join(Dir.pwd, "cookbooks")) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/monolith/commands.rb', line 40

def install(path = File.join(Dir.pwd, "cookbooks"))
  berksfile = Monolith::Berksfile.new(options.dup)
  berksfile.install # We need to run berks install first
  gitpath = File.expand_path('../.git', berksfile.berksfile.filepath)
  gitexclude = GitExclude.new(gitpath, options)
  berksfile.cookbooks(path) do |cookbook, dep, destination|
    changed = berksfile.monolith_action(:install, cookbook, dep, destination)

    gitexclude.add(destination) if changed
  end
  gitexclude.update
end

#update(path = File.join(Dir.pwd, "cookbooks")) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/monolith/commands.rb', line 54

def update(path = File.join(Dir.pwd, "cookbooks"))
  berksfile = Monolith::Berksfile.new(options.dup)
  berksfile.install # We need to run berks install first
  berksfile.cookbooks(path) do |cookbook, dep, destination|
    berksfile.monolith_action(:update, cookbook, dep, destination)
  end
end

#versionObject



79
80
81
# File 'lib/monolith/commands.rb', line 79

def version
  puts Monolith::VERSION
end