Class: Runfile::RunfileHelper
- Inherits:
-
Object
- Object
- Runfile::RunfileHelper
- Defined in:
- lib/runfile/runfile_helper.rb
Overview
The RunfileHelper class assists in:
-
Finding named.runfiles
-
Creating new runfiles (‘run make`)
-
Showing a list of found system runfiles in a colorful help
Instance Method Summary collapse
-
#handle(argv) ⇒ Object
Handle the case when ‘run` is called without a Runfile present.
Instance Method Details
#handle(argv) ⇒ Object
Handle the case when ‘run` is called without a Runfile present. We will let the user know they can type `run make` to create a new sample Runfile. If the first argument matches the name of a *.runfile name, we will return it to the caller. Otherwise, we return false to indicate “no further handling is needed”.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/runfile/runfile_helper.rb', line 18 def handle(argv) # make a new runfile if argv[0] == "make" make_runfile argv[1] return false end # get a list of *.runfile path-wide runfiles = find_runfiles || [] # if first arg is a valid *.runfile, run it if argv[0] runfile = runfiles.select { |f| f[/#{argv[0]}.runfile/] }.first runfile and return runfile end # if we are here, offer some help and advice show_make_help runfiles return false end |