Module: Hudkins::Command::Exec
- Included in:
- Hudkins::Command
- Defined in:
- lib/hudkins/command/exec.rb
Overview
Description
mixin for interacting with the lib
the bin is setup to run any command prefaced with ‘run_’ each command should return something to be puts or nil
Instance Method Summary collapse
- #cmd_list ⇒ Object
- #command_list ⇒ Object
- #config ⇒ Object
-
#hud ⇒ Object
helper commands.
- #hud_host ⇒ Object
- #hudkins_rc ⇒ Object
- #job(job_name = nil) ⇒ Object
- #load_rc ⇒ Object
- #names(name = "") ⇒ Object
-
#required_params(values) ⇒ Object
could probably be cleaned up.
- #run_build ⇒ Object
- #run_config(job_name = @job_name) ⇒ Object
- #run_create(job_name = @job_name) ⇒ Object
-
#run_default ⇒ Object
default command.
- #run_host ⇒ Object
- #run_list(job_name = @job_name) ⇒ Object
- #run_start_irb ⇒ Object
Instance Method Details
#cmd_list ⇒ Object
77 78 79 |
# File 'lib/hudkins/command/exec.rb', line 77 def cmd_list command_list.map {|m| m.gsub(/^run_/, '')} end |
#command_list ⇒ Object
81 82 83 |
# File 'lib/hudkins/command/exec.rb', line 81 def command_list self.methods.select {|m| m =~ /^run_/} end |
#config ⇒ Object
93 94 95 |
# File 'lib/hudkins/command/exec.rb', line 93 def config @config ||= load_rc end |
#hud ⇒ Object
helper commands
55 56 57 |
# File 'lib/hudkins/command/exec.rb', line 55 def hud @hud end |
#hud_host ⇒ Object
89 90 91 |
# File 'lib/hudkins/command/exec.rb', line 89 def hud_host ENV["hudkins_host"] || config[:host] || raise_usage( "no hudkins_host defined." ) end |
#hudkins_rc ⇒ Object
105 106 107 108 109 110 |
# File 'lib/hudkins/command/exec.rb', line 105 def hudkins_rc [ File.("~/.hudkinsrc"), File.join(Dir.pwd, ".hudkinsrc") ].select {|f| File.size? f} # exists and is non 0 end |
#job(job_name = nil) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/hudkins/command/exec.rb', line 59 def job job_name = nil if job_name @job = hud.jobs.find_by_name job_name end @job end |
#load_rc ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/hudkins/command/exec.rb', line 97 def load_rc hudkins_rc.inject({}) do |ret, rc| h = YAML.load_file( rc ) ret.merge! h if h ret end end |
#names(name = "") ⇒ Object
85 86 87 |
# File 'lib/hudkins/command/exec.rb', line 85 def names name = "" hud.jobs.names name end |
#required_params(values) ⇒ Object
could probably be cleaned up
67 68 69 70 71 72 73 74 75 |
# File 'lib/hudkins/command/exec.rb', line 67 def required_params values e = Hudkins::ArgumentError.new "" raize = false values.each do |k,msg| e << msg unless k raize = true unless k end raise e if raize end |
#run_build ⇒ Object
14 15 16 |
# File 'lib/hudkins/command/exec.rb', line 14 def run_build "building!!!" end |
#run_config(job_name = @job_name) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/hudkins/command/exec.rb', line 18 def run_config job_name = @job_name required_params job_name => "job_name is required for this command." [ job( job_name ).name, job( job_name ).config ] end |
#run_create(job_name = @job_name) ⇒ Object
26 27 28 29 |
# File 'lib/hudkins/command/exec.rb', line 26 def run_create job_name = @job_name required_params job_name => "job_name is required for this command." "creating!!!" end |
#run_default ⇒ Object
default command. here as a place holder
11 12 |
# File 'lib/hudkins/command/exec.rb', line 11 def run_default end |
#run_host ⇒ Object
31 32 33 |
# File 'lib/hudkins/command/exec.rb', line 31 def run_host hud_host end |
#run_list(job_name = @job_name) ⇒ Object
35 36 37 |
# File 'lib/hudkins/command/exec.rb', line 35 def run_list job_name = @job_name names( job_name || "" ) end |
#run_start_irb ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/hudkins/command/exec.rb', line 39 def run_start_irb puts <<-EOS --- Welcome to hudkins irb console. type hudkins for help. EOS require "hudkins/command/irb_start" # turn job names into methods extend Hudkins::Command::Irb IRB.start_session(nil, binding) end |