Class: CfScript::Scope::Target
- Inherits:
-
Base
- Object
- Base
- CfScript::Scope::Target
show all
- Defined in:
- lib/cf_script/scope/target.rb
Constant Summary
Constants included
from UI
UI::COLORS, UI::EMOJI, UI::TAGS
Instance Method Summary
collapse
Methods inherited from Base
#finalize, #initialize, #method_missing, #spec_for
Methods included from UI
alert, call_type, debug, detail, emoji, emoji_for, error, info, print_err, print_out, progress, puts_err, puts_out, step, success, tag_char, tag_close, tag_color, tag_format, tag_open, tag_style, title, trace, ui_format, with_color_of
Methods included from Execution
exec_in
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class CfScript::Scope::Base
Instance Method Details
#app(name_or_info, &block) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/cf_script/scope/target.rb', line 38
def app(name_or_info, &block)
if block_given?
app = CfScript::Scope::App.new(name_or_info, @current_target)
exec_in(app, nil, &block)
else
app_name = name_or_info.respond_to?(:name) ? name_or_info.name : name_or_info
CfScript::Command.app(app_name)
end
end
|
#apps(options = {}, &block) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/cf_script/scope/target.rb', line 50
def apps(options = {}, &block)
apps = CfScript::Command.apps
apps.select!(options) unless options.empty?
if block_given?
apps.each do |app_info|
app(app_info, &block)
end
else
apps
end
end
|
#current_org ⇒ Object
3
4
5
|
# File 'lib/cf_script/scope/target.rb', line 3
def current_org
@current_target ? @current_target.org : ''
end
|
#current_space ⇒ Object
7
8
9
|
# File 'lib/cf_script/scope/target.rb', line 7
def current_space
@current_target ? @current_target.space : ''
end
|
#space(space_name, &block) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/cf_script/scope/target.rb', line 24
def space(space_name, &block)
space_scope = nil
if block_given?
space_scope = CfScript::Scope::Space.new(space_name)
exec_in(space_scope, nil, &block)
else
CfScript::Command.space(space_name)
end
ensure
space_scope.finalize if space_scope
end
|
#target(*args, &block) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/cf_script/scope/target.rb', line 11
def target(*args, &block)
unless args.empty?
if args.first.to_s == current_space
return @current_target
end
end
@current_target = CfScript::Command.run(:target, *args)
block_given? ? yield(@current_target) : @current_target
end
|