Class: Garlic::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/garlic/session.rb

Overview

this class runs the top level garlic commands

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actor = nil, &block) ⇒ Session

Returns a new instance of Session.



7
8
9
10
11
12
13
14
# File 'lib/garlic/session.rb', line 7

def initialize(actor = nil, &block)
  @actor = actor
  self.repos = []
  self.targets = []
  self.work_path = ".garlic"
  self.repo_path = "~/.garlic/repos"
  configure(&block) if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (protected)



137
138
139
# File 'lib/garlic/session.rb', line 137

def method_missing(method, *args, &block)
  actor ? actor.send(method, *args, &block) : super
end

Instance Attribute Details

#actorObject (readonly)

Returns the value of attribute actor.



4
5
6
# File 'lib/garlic/session.rb', line 4

def actor
  @actor
end

#repo_pathObject

Returns the value of attribute repo_path.



5
6
7
# File 'lib/garlic/session.rb', line 5

def repo_path
  @repo_path
end

#reposObject

Returns the value of attribute repos.



5
6
7
# File 'lib/garlic/session.rb', line 5

def repos
  @repos
end

#run_targetsObject

Returns the value of attribute run_targets.



4
5
6
# File 'lib/garlic/session.rb', line 4

def run_targets
  @run_targets
end

#targetsObject

Returns the value of attribute targets.



5
6
7
# File 'lib/garlic/session.rb', line 5

def targets
  @targets
end

#verboseObject

Returns the value of attribute verbose.



5
6
7
# File 'lib/garlic/session.rb', line 5

def verbose
  @verbose
end

#work_pathObject

Returns the value of attribute work_path.



5
6
7
# File 'lib/garlic/session.rb', line 5

def work_path
  @work_path
end

Class Method Details

.command_description(name) ⇒ Object



46
47
48
# File 'lib/garlic/session.rb', line 46

def command_description(name)
  @@command_descriptions[name]
end

.commandsObject



50
51
52
# File 'lib/garlic/session.rb', line 50

def commands
  @@command_descriptions.keys.map {|c| c.to_s}
end

.commands_with_descriptionObject



42
43
44
# File 'lib/garlic/session.rb', line 42

def commands_with_description
  @@commands.map{|m| [m, @@command_descriptions[m]]}
end

.define_command(name, desc, &block) ⇒ Object



36
37
38
39
40
# File 'lib/garlic/session.rb', line 36

def define_command(name, desc, &block)
  @@commands << name
  @@command_descriptions[name] = desc
  define_method name, &block
end

Instance Method Details

#configure(&block) ⇒ Object



16
17
18
# File 'lib/garlic/session.rb', line 16

def configure(&block)
  Configurator.new(self, &block)
end

#repo(name) ⇒ Object



20
21
22
# File 'lib/garlic/session.rb', line 20

def repo(name)
  repos.detect {|r| r.name == name.to_s} or raise "Can't find repo: #{name}"
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/garlic/session.rb', line 132

def respond_to?(method)
  super(method) || (actor && actor.respond_to?(method))
end