Module: Vop::PluginSyntax

Defined in:
lib/vop/syntax/plugin_syntax.rb

Instance Method Summary collapse

Instance Method Details

#auto_load(bool) ⇒ Object



32
33
34
# File 'lib/vop/syntax/plugin_syntax.rb', line 32

def auto_load(bool)
  @plugin.options[:auto_load] = bool
end

#config_param(name, options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/vop/syntax/plugin_syntax.rb', line 14

def config_param(name, options = {})
  options = resolve_options_string(options)

  @plugin.params << CommandParam.new(name, options)
end

#config_param!(name, options = {}) ⇒ Object



20
21
22
23
24
# File 'lib/vop/syntax/plugin_syntax.rb', line 20

def config_param!(name, options = {})
  options = resolve_options_string(options)
  options.merge! mandatory: true
  config_param(name, options)
end

#depends_on(others) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/vop/syntax/plugin_syntax.rb', line 36

def depends_on(others)
  others = [ others ] unless others.is_a?(Array)

  others.each do |other|
    $logger.debug "plugin #{@plugin.name} depends on #{other}"
    @plugin.dependencies << other.to_s
  end
end

#description(string) ⇒ Object



28
29
30
# File 'lib/vop/syntax/plugin_syntax.rb', line 28

def description(string)
  @plugin.description = string
end

#hook(hook_sym, &block) ⇒ Object



49
50
51
# File 'lib/vop/syntax/plugin_syntax.rb', line 49

def hook(hook_sym, &block)
  @op.hook(hook_sym, &block)
end

#on(hook_sym, &block) ⇒ Object



45
46
47
# File 'lib/vop/syntax/plugin_syntax.rb', line 45

def on(hook_sym, &block)
  @plugin.hook(hook_sym, &block)
end

#resolve_options_string(options) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/vop/syntax/plugin_syntax.rb', line 5

def resolve_options_string(options)
  if options.is_a? String
    options = {
      description: options
    }
  end
  options
end