Repository URL to install this package:
|
Version:
2.5.2 ▾
|
| bin |
| lib |
| Gemfile |
| README.md |
| uoy-faculty-sinatra-aws.gemspec |
Add these lines to your application's Gemfile:
source 'https://gem.fury.io/universityofyork/' do gem 'aws-sessionstore-dynamodb', '~> 1' gem 'uoy-faculty-sinatra-aws', require: 'sinatra/faculty/aws' end
aws-sessionstore-dynamodb must be declared separately; we want the local version from gemfury,
not the one from rubygems, and declaring it as a dependency in gemspec will pull the rubygems version.
And then execute:
$ bundle
Or install it yourself as:
$ gem install uoy-faculty-sinatra-aws
Call this from the lambda handler function defined in your app. For example, in a lambda.rb file:
# frozen_string_literal: true
require 'rack'
require 'sinatra/lambda_handler'
# Global object that responds to the call method. Stay outside of the handler to take advantage of container reuse
$app ||= Rack::Builder.parse_file("#{__dir__}/config.ru").first # rubocop:disable Style/GlobalVars
ENV['RACK_ENV'] ||= 'production'
def lambda_handler(event:, context:)
Sinatra::LambdaHandler.handler(event: event, context: context)
end
This allows us to leave the handler in Cloudformation as lambda.lambda_handler but centralise the handler function.
configure blockin_lambda?
app_secrets
APP_SECRET_NAME as a hashaws_config
path=''configure do
if in_lambda?
aws_config
else
...
end
end
In your app.rb:
configure do
if in_lambda?
register Sinatra::CognitoAuth
else
...
end
end
Your Gem's version is picked up automatically from lib/sinatra/faculty/aws.rb. When any
changes are pushed to master, after the normal CI tasks the pipeline will push
to gemfury automatically. The usual workflow is:
For minor changes, update VERSION and make the change in a single commit
For anything else, create a branch and set VERSION to the version you're
aiming to release for. Make the changes; when the branch is merged, the gem
will be uploaded.
Note that gemfury will never overwrite an existing gem version, even if the old one is yanked!
Tests can be run via rake: bundle exec rake spec - this doesn't run
performance tests; they can be run separately via bundle exec rake perf.
You can also run rspec normally e.g. bundle exec rspec -fd.
If you have performance tests that take a while, tag the context / describe
block like this:
context 'when foo is bar baz', :perf do
...
end
Bug reports and pull requests are welcome at https://github.com/university-of-york/faculty-dev-sinatra-aws-gem