Module: Hudkins::Command::Irb

Defined in:
lib/hudkins/command/irb_start.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object

This is cool. Override default method to add convenience methods for each job_name in #jobs. This allows ‘job_name’ to be used as a method to access that particular job.



52
53
54
55
56
57
58
# File 'lib/hudkins/command/irb_start.rb', line 52

def method_missing sym, *args, &block
  if job = @hud.jobs.find_by_name( sym )
    job
  else
    super sym, *args, &block
  end
end

Class Method Details

.extend_object(obj) ⇒ Object

In the irb console I want to access the same commands as Hudkins::Command::Exec but without the ‘run_’ part.



37
38
39
40
41
42
43
44
45
46
# File 'lib/hudkins/command/irb_start.rb', line 37

def self.extend_object obj # :doc:
  # in IRB allow run_* commands to be exec without `run_'
  obj.command_list.each do |cmd|
    s = <<-EOE
      def self.#{cmd.gsub(/^run_/, '')} *args; #{cmd} *args; end
    EOE
    obj.module_eval s
  end
  super
end

Instance Method Details

#hudkinsObject

help method in irb console



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/hudkins/command/irb_start.rb', line 62

def hudkins
  puts <<-EOS

  self is Hudkins::Command
  hudkins            => This help message
  reload!         => reload lib
  hud             => Hudkins.new <hud_host>
  job [job_name]  => Hudkins::Job
  job_name        => Hudkins::Job
  commands:
#{cmd_list.join("\n    ")}

  EOS
end

#reload!Object

helper method in irb console to reload all the lib files.



79
80
81
82
83
84
# File 'lib/hudkins/command/irb_start.rb', line 79

def reload!
  $".grep( /hudkins/ ).each do |f|
    load f
  end
  nil
end