Module: Runfile::DSL
- Included in:
- Userfile
- Defined in:
- lib/runfile/concerns/dsl.rb
Instance Method Summary collapse
-
#action(name = nil, shortcut = nil, &block) ⇒ Object
Commands.
-
#actions ⇒ Object
Evaluation Artifacts.
- #env_var(name, help) ⇒ Object
- #env_vars ⇒ Object
- #example(text) ⇒ Object
- #examples ⇒ Object
- #help(message) ⇒ Object
- #helper_blocks ⇒ Object
- #helpers(&block) ⇒ Object
- #import(pathspec, context = nil) ⇒ Object
- #import_gem(pathspec, context = nil) ⇒ Object
- #imports ⇒ Object
- #option(name, help) ⇒ Object
- #options ⇒ Object
- #param(name, help) ⇒ Object
- #params ⇒ Object
- #require_context(varname, default: nil) ⇒ Object
- #required_contexts ⇒ Object
- #shortcut(from, to) ⇒ Object
- #shortcuts ⇒ Object
- #summary(text = nil) ⇒ Object
- #title(text = nil) ⇒ Object
- #usage(message) ⇒ Object
- #version(text = nil) ⇒ Object
Instance Method Details
#action(name = nil, shortcut = nil, &block) ⇒ Object
Commands
5 6 7 8 9 10 11 |
# File 'lib/runfile/concerns/dsl.rb', line 5 def action(name = nil, shortcut = nil, &block) current_action.block = block current_action.name = name.to_s current_action.shortcut = shortcut.to_s if shortcut current_action.host = self finalize_current_action name.to_s end |
#actions ⇒ Object
Evaluation Artifacts
87 88 89 |
# File 'lib/runfile/concerns/dsl.rb', line 87 def actions @actions ||= {} end |
#env_var(name, help) ⇒ Object
13 14 15 |
# File 'lib/runfile/concerns/dsl.rb', line 13 def env_var(name, help) env_vars[name] = help end |
#env_vars ⇒ Object
95 96 97 |
# File 'lib/runfile/concerns/dsl.rb', line 95 def env_vars @env_vars ||= {} end |
#example(text) ⇒ Object
17 18 19 |
# File 'lib/runfile/concerns/dsl.rb', line 17 def example(text) examples.push text end |
#examples ⇒ Object
99 100 101 |
# File 'lib/runfile/concerns/dsl.rb', line 99 def examples @examples ||= [] end |
#help(message) ⇒ Object
21 22 23 |
# File 'lib/runfile/concerns/dsl.rb', line 21 def help() current_action.help = end |
#helper_blocks ⇒ Object
103 104 105 |
# File 'lib/runfile/concerns/dsl.rb', line 103 def helper_blocks @helper_blocks ||= [] end |
#helpers(&block) ⇒ Object
25 26 27 28 |
# File 'lib/runfile/concerns/dsl.rb', line 25 def helpers(&block) helper_blocks.push block if block helper_blocks end |
#import(pathspec, context = nil) ⇒ Object
30 31 32 |
# File 'lib/runfile/concerns/dsl.rb', line 30 def import(pathspec, context = nil) imports[pathspec] = context end |
#import_gem(pathspec, context = nil) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/runfile/concerns/dsl.rb', line 34 def import_gem(pathspec, context = nil) gem_name, glob = pathspec.split('/', 2) glob ||= '*' path = GemFinder.find gem_name, glob imports[path] = context end |
#imports ⇒ Object
107 108 109 |
# File 'lib/runfile/concerns/dsl.rb', line 107 def imports @imports ||= {} end |
#option(name, help) ⇒ Object
41 42 43 |
# File 'lib/runfile/concerns/dsl.rb', line 41 def option(name, help) [name] = help end |
#options ⇒ Object
111 112 113 |
# File 'lib/runfile/concerns/dsl.rb', line 111 def @options ||= {} end |
#param(name, help) ⇒ Object
45 46 47 |
# File 'lib/runfile/concerns/dsl.rb', line 45 def param(name, help) params[name] = help end |
#params ⇒ Object
91 92 93 |
# File 'lib/runfile/concerns/dsl.rb', line 91 def params @params ||= {} end |
#require_context(varname, default: nil) ⇒ Object
49 50 51 |
# File 'lib/runfile/concerns/dsl.rb', line 49 def require_context(varname, default: nil) required_contexts[varname] = default end |
#required_contexts ⇒ Object
53 54 55 |
# File 'lib/runfile/concerns/dsl.rb', line 53 def required_contexts @required_contexts ||= {} end |
#shortcut(from, to) ⇒ Object
57 58 59 |
# File 'lib/runfile/concerns/dsl.rb', line 57 def shortcut(from, to) shortcuts[from] = to end |
#shortcuts ⇒ Object
115 116 117 |
# File 'lib/runfile/concerns/dsl.rb', line 115 def shortcuts @shortcuts ||= {} end |
#summary(text = nil) ⇒ Object
61 62 63 64 65 |
# File 'lib/runfile/concerns/dsl.rb', line 61 def summary(text = nil) return @summary unless text @summary = text end |
#title(text = nil) ⇒ Object
67 68 69 70 71 |
# File 'lib/runfile/concerns/dsl.rb', line 67 def title(text = nil) return @title unless text @title = text end |
#usage(message) ⇒ Object
73 74 75 76 77 |
# File 'lib/runfile/concerns/dsl.rb', line 73 def usage() = "#{name} #{}" if name = "#{host.full_name} #{}".strip if host current_action.usages.push end |
#version(text = nil) ⇒ Object
79 80 81 82 83 |
# File 'lib/runfile/concerns/dsl.rb', line 79 def version(text = nil) return @version unless text @version = text end |