Module: Runfile::DSL

Included in:
Userfile
Defined in:
lib/runfile/concerns/dsl.rb

Instance Method Summary collapse

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

#actionsObject

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_varsObject



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

#examplesObject



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(message)
  current_action.help = message
end

#helper_blocksObject



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

#importsObject



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)
  options[name] = help
end

#optionsObject



111
112
113
# File 'lib/runfile/concerns/dsl.rb', line 111

def options
  @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

#paramsObject



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_contextsObject



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

#shortcutsObject



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(message)
  message = "#{name} #{message}" if name
  message = "#{host.full_name} #{message}".strip if host
  current_action.usages.push message
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