Class: Chef::Cookbook::GemInstaller::ChefBundlerUI

Inherits:
Bundler::UI::Silent
  • Object
show all
Defined in:
lib/chef/cookbook/gem_installer.rb

Overview

Bundler::UI object so that we can intercept and log the output of the in-memory bundle install that we are going to do.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events) ⇒ ChefBundlerUI

Returns a new instance of ChefBundlerUI.



69
70
71
72
# File 'lib/chef/cookbook/gem_installer.rb', line 69

def initialize(events)
  @events = events
  super()
end

Instance Attribute Details

#eventsObject

Returns the value of attribute events.



67
68
69
# File 'lib/chef/cookbook/gem_installer.rb', line 67

def events
  @events
end

Instance Method Details

#confirm(msg, newline = nil) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/chef/cookbook/gem_installer.rb', line 74

def confirm(msg, newline = nil)
  # looks like "Installing time_ago_in_words 0.1.1" when installing
  if msg =~ /Installing\s+(\S+)\s+(\S+)/
    events.cookbook_gem_installing($1, $2)
  end
  Chef::Log.info(msg)
end

#debug(msg, newline = nil) ⇒ Object



86
87
88
# File 'lib/chef/cookbook/gem_installer.rb', line 86

def debug(msg, newline = nil)
  Chef::Log.debug(msg)
end

#error(msg, newline = nil) ⇒ Object



82
83
84
# File 'lib/chef/cookbook/gem_installer.rb', line 82

def error(msg, newline = nil)
  Chef::Log.error(msg)
end

#info(msg, newline = nil) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/chef/cookbook/gem_installer.rb', line 90

def info(msg, newline = nil)
  # looks like "Using time_ago_in_words 0.1.1" when using, plus other misc output
  if msg =~ /Using\s+(\S+)\s+(\S+)/
    events.cookbook_gem_using($1, $2)
  end
  Chef::Log.info(msg)
end

#warn(msg, newline = nil) ⇒ Object



98
99
100
# File 'lib/chef/cookbook/gem_installer.rb', line 98

def warn(msg, newline = nil)
  Chef::Log.warn(msg)
end