Module: Runfile
- Includes:
- Colsole
- Defined in:
- lib/runfile/dsl.rb,
lib/runfile/util.rb,
lib/runfile/action.rb,
lib/runfile/runner.rb,
lib/runfile/version.rb,
lib/runfile/docopt_helper.rb,
lib/runfile/runfile_helper.rb
Overview
Utility methods
Defined Under Namespace
Classes: Action, DocoptHelper, RunfileHelper, Runner
Constant Summary collapse
- VERSION =
"0.5.2"
Instance Method Summary collapse
-
#action(name, altname = nil, &block) ⇒ Object
Define the action.
-
#call(command_string) ⇒ Object
Cross-call another action.
-
#command(name = nil) ⇒ Object
(also: #endcommand)
Define a new command namespace.
-
#d(obj) ⇒ Object
Debug print and exit Smells of :reek:UncommunicativeMethodName.
-
#example(text) ⇒ Object
Set an example command (can be called multiple times).
-
#help(text) ⇒ Object
Set the help message for the next action.
-
#name(name) ⇒ Object
Set the name of your Runfile program.
-
#option(flag, text, scope = nil) ⇒ Object
Add an option/flag to the next action (can be called multiple times).
-
#path_dirs ⇒ Object
Return an array of path directories Smells of :reek:UtilityFunction.
-
#summary(text) ⇒ Object
Set the one line summary of your Runfile program.
-
#usage(text) ⇒ Object
Set the usage pattern for the next action.
-
#version(ver) ⇒ Object
Set the version of your Runfile program.
Instance Method Details
#action(name, altname = nil, &block) ⇒ Object
Define the action
44 45 46 |
# File 'lib/runfile/dsl.rb', line 44 def action(name, altname=nil, &block) Runner.instance.add_action name, altname, &block end |
#call(command_string) ⇒ Object
Cross-call another action
54 55 56 |
# File 'lib/runfile/dsl.rb', line 54 def call(command_string) Runner.instance.cross_call command_string end |
#command(name = nil) ⇒ Object Also known as: endcommand
Define a new command namespace
49 50 51 |
# File 'lib/runfile/dsl.rb', line 49 def command(name=nil) Runner.instance.namespace = name end |
#d(obj) ⇒ Object
Debug print and exit Smells of :reek:UncommunicativeMethodName
5 6 7 8 |
# File 'lib/runfile/util.rb', line 5 def d(obj) pp obj exit end |
#example(text) ⇒ Object
Set an example command (can be called multiple times)
39 40 41 |
# File 'lib/runfile/dsl.rb', line 39 def example(text) Runner.instance.add_example text end |
#help(text) ⇒ Object
Set the help message for the next action
28 29 30 |
# File 'lib/runfile/dsl.rb', line 28 def help(text) Runner.instance.last_help = text end |
#name(name) ⇒ Object
Set the name of your Runfile program
8 9 10 |
# File 'lib/runfile/dsl.rb', line 8 def name(name) Runner.instance.name = name end |
#option(flag, text, scope = nil) ⇒ Object
Add an option/flag to the next action (can be called multiple times)
34 35 36 |
# File 'lib/runfile/dsl.rb', line 34 def option(flag, text, scope=nil) Runner.instance.add_option flag, text, scope end |
#path_dirs ⇒ Object
Return an array of path directories Smells of :reek:UtilityFunction
12 13 14 |
# File 'lib/runfile/util.rb', line 12 def path_dirs ENV['PATH'].split(File::PATH_SEPARATOR) end |
#summary(text) ⇒ Object
Set the one line summary of your Runfile program
18 19 20 |
# File 'lib/runfile/dsl.rb', line 18 def summary(text) Runner.instance.summary = text end |
#usage(text) ⇒ Object
Set the usage pattern for the next action
23 24 25 |
# File 'lib/runfile/dsl.rb', line 23 def usage(text) Runner.instance.last_usage = text end |
#version(ver) ⇒ Object
Set the version of your Runfile program
13 14 15 |
# File 'lib/runfile/dsl.rb', line 13 def version(ver) Runner.instance.version = ver end |