Class: RC::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/rc/setup.rb

Overview

Configuration setup is used to customize how a tool handles configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, options = {}, &block) ⇒ Setup

Intialize new configuration setup.



12
13
14
15
16
17
18
19
# File 'lib/rc/setup.rb', line 12

def initialize(command, options={}, &block)
  @command = command.to_s
  #@command = options[:command] || options[:tool] if options.key?(:command) || options.key?(:tool)

  @profile = options[:profile] if options.key?(:profile)

  @block = block
end

Instance Attribute Details

#commandObject (readonly)

Command for which this is the configuration setup.



24
25
26
# File 'lib/rc/setup.rb', line 24

def command
  @command
end

#profileObject (readonly)

Specific profile for which this is the configuration is the setup.



29
30
31
# File 'lib/rc/setup.rb', line 29

def profile
  @profile
end

Instance Method Details

#call(config) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rc/setup.rb', line 34

def call(config)
  return unless config.command == @command #.to_s if @command

  case profile
  when true
    return unless RC.profile?
  when nil, false
  else
    return unless config.profile == @profile.to_s #if @profile
  end

  @block.call(config)
end

#to_procObject



51
52
53
# File 'lib/rc/setup.rb', line 51

def to_proc
  @block
end