Module: CfScript
- Extended by:
- Scope::Execution, UI
- Defined in:
- lib/cf_script.rb,
lib/cf_script/output.rb,
lib/cf_script/version.rb,
lib/cf_script/scope/proxy.rb,
lib/cf_script/output/tests.rb,
lib/cf_script/output/utils.rb,
lib/cf_script/output/buffer.rb,
lib/cf_script/output/parser.rb,
lib/cf_script/output/parser/table.rb,
lib/cf_script/output/parser/section.rb,
lib/cf_script/output/parser/attributes.rb
Defined Under Namespace
Modules: Command, Scope, UI, Utils
Classes: ApiEndpoint, AppInfo, AppList, Attribute, AttributeList, Config, InstanceStatus, Manifest, Output, RouteInfo, Space, Target
Constant Summary
collapse
- VERSION =
'0.0.2'
Constants included
from UI
UI::COLORS, UI::EMOJI, UI::TAGS
Class Attribute Summary collapse
Class Method Summary
collapse
exec_in
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
Class Attribute Details
.cf_call_count ⇒ Object
Returns the value of attribute cf_call_count.
18
19
20
|
# File 'lib/cf_script.rb', line 18
def cf_call_count
@cf_call_count
end
|
.cf_call_stack ⇒ Object
Returns the value of attribute cf_call_stack.
19
20
21
|
# File 'lib/cf_script.rb', line 19
def cf_call_stack
@cf_call_stack
end
|
.configuration ⇒ Object
Returns the value of attribute configuration.
14
15
16
|
# File 'lib/cf_script.rb', line 14
def configuration
@configuration
end
|
.definitions ⇒ Object
Returns the value of attribute definitions.
16
17
18
|
# File 'lib/cf_script.rb', line 16
def definitions
@definitions
end
|
Class Method Details
.cf(options = {}, &block) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/cf_script.rb', line 59
def cf(options = {}, &block)
@cf_call_count ||= 0
@cf_call_stack ||= []
if @cf_call_count == 0
info :cf, CfScript::Command::Runner.cf_id
end
@cf_call_count += 1
@cf_call_stack.push CfScript::Scope::Script.new(options)
@cf_call_stack.last.run(&block)
rescue StandardError => e
print_error(e)
ensure
@cf_call_stack.last.finalize if @cf_call_stack.last
@cf_call_stack.pop
end
|
.config ⇒ Object
27
28
29
|
# File 'lib/cf_script.rb', line 27
def config
@configuration ||= Config.new
end
|
31
32
33
|
# File 'lib/cf_script.rb', line 31
def configure
block_given? ? yield(config) : config
end
|
.define(app_name, &block) ⇒ Object
47
48
49
50
51
52
|
# File 'lib/cf_script.rb', line 47
def define(app_name, &block)
@definitions ||= {}
@definitions[app_name] = AppSpec.new(name: app_name).tap do |spec|
spec.instance_exec(&block)
end
end
|
.manifest(path = nil) ⇒ Object
43
44
45
|
# File 'lib/cf_script.rb', line 43
def manifest(path = nil)
@manifest ||= CfScript::Manifest.new(path)
end
|
.print_error(e) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/cf_script.rb', line 81
def print_error(e)
error "cf:#{stack_level}", e.message
e.backtrace.each do |line|
error "cf:#{stack_level}", line
end
if stdout.is_a?(StringIO)
STDOUT.puts "cf:#{stack_level} #{e.message}"
e.backtrace.each do |line|
STDOUT.puts "cf:#{stack_level} #{line}"
end
end
end
|
.spec_for(app_name) ⇒ Object
54
55
56
57
|
# File 'lib/cf_script.rb', line 54
def spec_for(app_name)
@definitions ||= {}
@definitions[app_name]
end
|
.stack_level ⇒ Object
77
78
79
|
# File 'lib/cf_script.rb', line 77
def stack_level
@cf_call_stack.length - 1
end
|
.stderr ⇒ Object
39
40
41
|
# File 'lib/cf_script.rb', line 39
def stderr
config.io.stderr
end
|
.stdout ⇒ Object
35
36
37
|
# File 'lib/cf_script.rb', line 35
def stdout
config.io.stdout
end
|