Class: Runfile::RunfileHelper
- Inherits:
-
Object
- Object
- Runfile::RunfileHelper
- Includes:
- SettingsMixin
- Defined in:
- lib/runfile/runfile_helper.rb
Overview
The RunfileHelper class assists in:
-
Finding named.runfiles
-
Creating new runfiles (‘run new`)
-
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.
- #purge_settings ⇒ Object
Methods included from SettingsMixin
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 new` 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”.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/runfile/runfile_helper.rb', line 19 def handle(argv) # make a new runfile if argv[0] == "new" && !settings_present? 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 and show a list # of possible runfiles to run. show_make_help runfiles, settings.folder return false end |
#purge_settings ⇒ Object
41 42 43 |
# File 'lib/runfile/runfile_helper.rb', line 41 def purge_settings @settings = OpenStruct.new end |