Class: Jets::Commands::Call::BaseGuesser
- Inherits:
-
Object
- Object
- Jets::Commands::Call::BaseGuesser
show all
- Includes:
- AwsServices
- Defined in:
- lib/jets/commands/call/base_guesser.rb
Constant Summary
collapse
- @@stack_resources =
{}
- @@parent_stack =
nil
Instance Method Summary
collapse
#apigateway, #aws_lambda, #cfn, #dynamodb, #logs, #s3, #s3_resource, #sns, #sqs, #sts
#lookup, #stack_exists?, #stack_in_progress?
included
Constructor Details
#initialize(provided_function_name) ⇒ BaseGuesser
provided_function_name:
admin/related_pages_controller-list_all
admin-related-pages-controller-list-all
13
14
15
|
# File 'lib/jets/commands/call/base_guesser.rb', line 13
def initialize(provided_function_name)
@provided_function_name = provided_function_name
end
|
Instance Method Details
#class_name ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/jets/commands/call/base_guesser.rb', line 17
def class_name
return @class_name if @detection_ran
@class_name = detect_class_name
@detection_ran = true
@class_name
end
|
#function_name ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/jets/commands/call/base_guesser.rb', line 25
def function_name
@provided_function_name = @provided_function_name.sub("#{Jets.config.project_namespace}-", "")
code_path = class_name.underscore.gsub('/','-')
function_name = [Jets.config.project_namespace, code_path, method_name].join('-')
generated_function_name(function_name)
end
|
#generated_function_name(function_name) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/jets/commands/call/base_guesser.rb', line 36
def generated_function_name(function_name)
if function_name.size > Jets::MAX_FUNCTION_NAME_SIZE logical_id = @class_name.gsub('::','')
parent_resources = stack_resources(parent_stack.stack_id)
app_stack = parent_resources.find { |s| s.logical_resource_id == logical_id }
resources = stack_resources(app_stack.physical_resource_id)
resource = resources.find { |r| r.logical_resource_id == method_name.camelize + "LambdaFunction" } resource.physical_resource_id else
function_name
end
end
|
#parent_stack ⇒ Object
58
59
60
|
# File 'lib/jets/commands/call/base_guesser.rb', line 58
def parent_stack
@@parent_stack ||= cfn.describe_stacks(stack_name: Jets::Naming.parent_stack_name).stacks.first
end
|
#stack_resources(stack_name) ⇒ Object
53
54
55
|
# File 'lib/jets/commands/call/base_guesser.rb', line 53
def stack_resources(stack_name)
@@stack_resources[stack_name] ||= cfn.describe_stack_resources(stack_name: stack_name).stack_resources
end
|