Class: Object

Inherits:
BasicObject
Extended by:
Shef::Extensions::Object::ClassMethods
Includes:
FileUtils, Shef::Extensions::Object
Defined in:
lib/chef/shef/ext.rb

Instance Method Summary collapse

Methods included from Shef::Extensions::Object::ClassMethods

all_help_descriptions, desc, help_descriptions, method_added, subcommands

Methods included from Shef::Extensions::Object

#ensure_session_select_defined, #find_or_create_session_for, #help_banner, #off, #on

Instance Method Details

#attributesObject



209
210
211
212
# File 'lib/chef/shef/ext.rb', line 209

def attributes
  find_or_create_session_for Shef.session.node
  :attributes
end

#chef_runObject



239
240
241
# File 'lib/chef/shef/ext.rb', line 239

def chef_run
  Shef.session.collection.iterator
end

#echo(on_or_off) ⇒ Object



249
250
251
# File 'lib/chef/shef/ext.rb', line 249

def echo(on_or_off)
  conf.echo = on_or_off.on_off_to_bool
end

#echo?Boolean

Returns:

  • (Boolean)


254
255
256
# File 'lib/chef/shef/ext.rb', line 254

def echo?
  puts "echo is #{conf.echo.to_on_off_str}"
end

#ls(directory) ⇒ Object



272
273
274
# File 'lib/chef/shef/ext.rb', line 272

def ls(directory)
  Dir.entries(directory)
end

#nodeObject



215
216
217
# File 'lib/chef/shef/ext.rb', line 215

def node
  Shef.session.node
end

#ohai(key = nil) ⇒ Object



220
221
222
# File 'lib/chef/shef/ext.rb', line 220

def ohai(key=nil)
  pp(key ? node.attribute[key] : node.attribute)
end

#recipeObject



203
204
205
206
# File 'lib/chef/shef/ext.rb', line 203

def recipe
  find_or_create_session_for Shef.session.recipe
  :recipe
end

#resetObject



244
245
246
# File 'lib/chef/shef/ext.rb', line 244

def reset
  Shef.session.reset!
end

#run_chefObject



225
226
227
228
229
230
231
232
# File 'lib/chef/shef/ext.rb', line 225

def run_chef
  Chef::Log.level = :debug
  session = Shef.session
  session.rebuild_collection
  runrun = Chef::Runner.new(node, session.collection, session.definitions, session.cookbook_loader).converge
  Chef::Log.level = :info
  runrun
end

#shef_help(title = "Help: Shef") ⇒ Object Also known as: halp



185
186
187
188
189
# File 'lib/chef/shef/ext.rb', line 185

def shef_help(title="Help: Shef")
  #puts Shef::Extensions::Object.help_banner("Shef Help")
  puts help_banner(title)
  :ucanhaz_halp
end

#tracing(on_or_off) ⇒ Object Also known as: trace



259
260
261
262
# File 'lib/chef/shef/ext.rb', line 259

def tracing(on_or_off)
  conf.use_tracer = on_or_off.on_off_to_bool
  tracing?
end

#tracing?Boolean Also known as: trace?

Returns:

  • (Boolean)


266
267
268
# File 'lib/chef/shef/ext.rb', line 266

def tracing?
  puts "tracing is #{conf.use_tracer.to_on_off_str}"
end

#versionObject Also known as: shef



193
194
195
196
197
198
199
# File 'lib/chef/shef/ext.rb', line 193

def version
  puts  "This is shef, the Chef shell.\n" + 
        " Chef Version: #{::Chef::VERSION}\n" +
        " http://www.opscode.com/chef\n" +
        " http://wiki.opscode.com/display/chef/Home"
  :ucanhaz_automation
end