Class: Garlic::Session
- Inherits:
-
Object
- Object
- Garlic::Session
- Defined in:
- lib/garlic/session.rb
Overview
this class runs the top level garlic commands
Instance Attribute Summary collapse
-
#actor ⇒ Object
readonly
Returns the value of attribute actor.
-
#repo_path ⇒ Object
Returns the value of attribute repo_path.
-
#repos ⇒ Object
Returns the value of attribute repos.
-
#run_targets ⇒ Object
Returns the value of attribute run_targets.
-
#targets ⇒ Object
Returns the value of attribute targets.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#work_path ⇒ Object
Returns the value of attribute work_path.
Class Method Summary collapse
- .command_description(name) ⇒ Object
- .commands ⇒ Object
- .commands_with_description ⇒ Object
- .define_command(name, desc, &block) ⇒ Object
Instance Method Summary collapse
- #configure(&block) ⇒ Object
-
#initialize(actor = nil, &block) ⇒ Session
constructor
A new instance of Session.
- #repo(name) ⇒ Object
- #respond_to?(method) ⇒ Boolean
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
#actor ⇒ Object (readonly)
Returns the value of attribute actor.
4 5 6 |
# File 'lib/garlic/session.rb', line 4 def actor @actor end |
#repo_path ⇒ Object
Returns the value of attribute repo_path.
5 6 7 |
# File 'lib/garlic/session.rb', line 5 def repo_path @repo_path end |
#repos ⇒ Object
Returns the value of attribute repos.
5 6 7 |
# File 'lib/garlic/session.rb', line 5 def repos @repos end |
#run_targets ⇒ Object
Returns the value of attribute run_targets.
4 5 6 |
# File 'lib/garlic/session.rb', line 4 def run_targets @run_targets end |
#targets ⇒ Object
Returns the value of attribute targets.
5 6 7 |
# File 'lib/garlic/session.rb', line 5 def targets @targets end |
#verbose ⇒ Object
Returns the value of attribute verbose.
5 6 7 |
# File 'lib/garlic/session.rb', line 5 def verbose @verbose end |
#work_path ⇒ Object
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 |
.commands ⇒ Object
50 51 52 |
# File 'lib/garlic/session.rb', line 50 def commands @@command_descriptions.keys.map {|c| c.to_s} end |
.commands_with_description ⇒ Object
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
132 133 134 |
# File 'lib/garlic/session.rb', line 132 def respond_to?(method) super(method) || (actor && actor.respond_to?(method)) end |