Class: KnifeSpork::SporkBump

Inherits:
Chef::Knife
  • Object
show all
Defined in:
lib/chef/knife/spork-bump.rb

Constant Summary collapse

TYPE_INDEX =
{ :major => 0, :minor => 1, :patch => 2, :manual => 3 }.freeze

Instance Method Summary collapse

Instance Method Details

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/chef/knife/spork-bump.rb', line 33

def run
  self.class.send(:include, KnifeSpork::Runner)
  self.config = Chef::Config.merge!(config)
  config[:cookbook_path] ||= Chef::Config[:cookbook_path]

  cookbook_name = ""

  if @name_args.empty? && File.exists?("#{Dir.pwd}/metadata.rb")
    cookbook_name = File.read("#{Dir.pwd}/metadata.rb").split("\n").select{|l|l.start_with?("name")}.first.split.last.gsub("\"","").gsub("'","")
    ui.info "Cookbook name omitted, but metadata.rb for cookbook #{cookbook_name} found - bumping that."
  elsif @name_args.empty?
    show_usage
    ui.error("You must specify at least a cookbook name")
    exit 1
  else
    cookbook_name = name_args.first
  end

  # Temporary fix for #138 to allow Berkshelf functionality
  # to be bypassed until #85 has been completed and Berkshelf 3 support added
  unload_berkshelf_if_specified

  #First load so plugins etc know what to work with
  @cookbook = load_cookbook(cookbook_name)

  run_plugins(:before_bump)

  #Reload cookbook in case a VCS plugin found updates
  @cookbook = load_cookbook(cookbook_name)
  bump
  run_plugins(:after_bump)
end