Class: Jets::Builders::ShimVars::App
- Defined in:
- lib/jets/builders/shim_vars/app.rb
Instance Method Summary collapse
-
#dest_path ⇒ Object
Example return: “handlers/controllers/posts.js” TODO: rename this to dest_path or something better now since using native ruby.
- #full(path) ⇒ Object
-
#functions ⇒ Object
Returns the public methods of the child_class.
-
#handler_for(meth) ⇒ Object
This gets called in the node shim js template IE handlers/controllers/posts_controller.index.
-
#initialize(path) ⇒ App
constructor
Allow user to specify relative or full path.
-
#klass ⇒ Object
Examples: PostsController, HardJob, Hello, HelloFunction.
- #lang(meth) ⇒ Object
-
#process_type ⇒ Object
process_type is key, it will either “controller” or “job”.
- #relative(path) ⇒ Object
Methods inherited from Base
#bundled_zip, #rack_zip, #s3_bucket
Methods included from AwsServices
#apigateway, #cfn, #lambda, #logs, #s3, #s3_resource, #sns, #sqs, #sts
Methods included from AwsServices::StackStatus
#lookup, #stack_exists?, #stack_in_progress?
Constructor Details
#initialize(path) ⇒ App
Allow user to specify relative or full path. The right path gets used internally. Example paths:
app/controllers/posts_controller.rb
app/jobs/hard_job.rb
/tmp/jets/build/app_root/app/jobs/hard_job.rb
/tmp/jets/build/app_root/app/functions/hello.rb
21 22 23 24 |
# File 'lib/jets/builders/shim_vars/app.rb', line 21 def initialize(path) @full_path = full(path) @relative_path = relative(path) end |
Instance Method Details
#dest_path ⇒ Object
Example return: “handlers/controllers/posts.js” TODO: rename this to dest_path or something better now since using native ruby
73 74 75 76 |
# File 'lib/jets/builders/shim_vars/app.rb', line 73 def dest_path @relative_path .sub("app", "handlers") end |
#full(path) ⇒ Object
26 27 28 29 |
# File 'lib/jets/builders/shim_vars/app.rb', line 26 def full(path) path = "#{Jets.root}#{path}" unless path.starts_with?("/") path end |
#functions ⇒ Object
Returns the public methods of the child_class. Example: [:create, :update]
50 51 52 |
# File 'lib/jets/builders/shim_vars/app.rb', line 50 def functions klass.lambda_functions end |
#handler_for(meth) ⇒ Object
This gets called in the node shim js template IE handlers/controllers/posts_controller.index
65 66 67 68 69 |
# File 'lib/jets/builders/shim_vars/app.rb', line 65 def handler_for(meth) # possibly not include _function underscored_name = @relative_path.sub(%r{app/(\w+)/},'').sub('.rb','') "handlers/#{process_type.pluralize}/#{underscored_name}.#{meth}" end |
#klass ⇒ Object
Examples: PostsController, HardJob, Hello, HelloFunction
55 56 57 |
# File 'lib/jets/builders/shim_vars/app.rb', line 55 def klass @klass ||= Jets::Klass.from_path(@relative_path) end |
#lang(meth) ⇒ Object
59 60 61 |
# File 'lib/jets/builders/shim_vars/app.rb', line 59 def lang(meth) klass.tasks.find end |
#process_type ⇒ Object
process_type is key, it will either “controller” or “job”. It is used to deduce klass, etc. We get the process_type from the path. Example paths:
app/controllers/posts_controller.rb
app/jobs/hard_job.rb
44 45 46 |
# File 'lib/jets/builders/shim_vars/app.rb', line 44 def process_type @relative_path.split('/')[1].singularize # controller or job end |