Snipsnap::Extensions
Sinatra Extensions from the SnipSnap
/ Goodfor
codebases
Installation
Since this is a private repository, you'll either need to setup your deployment box to have proper GitHub credentials, or more easily you need to vendor the gem.
$ mkdir -p vendor/private_gems
$ git clone [email protected]:snipsnap/snipsnap-extensions.git vendor/private_gems/snipsnap-extensions
Add this line to your application's Gemfile:
gem 'snipsnap-extensions', '0.0.1', path: 'vendor/private_gems/snipsnap-extensions'
And then execute:
$ bundle
Usage
In your Sinatra::Base
file, require the extension and then register
it
For example, to include the SnipSnap::CORSExtension
,
# app.rb
require 'snipsnap/extensions/cors'
# ...
class App < Sinatra::Base
# ...
register SnipSnap::CORSExtension
end
Require All
# app.rb
require 'snipsnap/extensions/all'
# ...
class App < Sinatra::Base
# ...
register SnipSnap::AuthExtension
register SnipSnap::CORSExtension
# ...
end
Extensions
SnipSnap::ActionMailerExtension
Require Path: 'snipsnap/extensions/action_mailer'
Optional:
ENV['EMAIL_ADDRESS']
defaults to "smtp.sendgrid.net"ENV['URL_ROOT']
for prepending email URLs withurl_for(path)
Requires:
gem 'actionmailer'
gem 'letter_opener'
in developmentENV['EMAIL_DOMAIN']
for outgoing mail domainENV['EMAIL_USER_NAME']
for sendgrid usernameENV['EMAIL_PASSWORD']
for sendgrid password
SnipSnap::ActiveRecord
Require path: snipsnap/extensions/active_record
Requires:
gem 'activerecord'
gem 'sinatra-activerecord'
SnipSnap::Auth
Require Path: snipsnap/extensions/auth
Requires:
Guest
model to act as an unfound user- include the
SnipSnap::Guest
mixin into your Guest class
- include the
include the
SnipSnap::User
mixin into yourUser
model that- responds to
authenticate
to check for password match (matching thehas_secure_password
interface) - responds to
authorized?
- responds to
SnipSnap::CORSExtension
Require Path: snipsnap/extensions/cors
SnipSnap::DeliveryExtension
Require Path: snipsnap/extensions/delivery
SnipSnap::JSONBodyExtension
Require Path: snipsnap/extensions/json_body
SnipSnap::LoggingExtension
Require Path: snipsnap/extensions/logging
SnipSnap::PaperclipExtension
Setup paperclip file management
Require Path: snipsnap/extensions/paperclip
Requires:
gem 'paperclip'
imagemagick
installed on system
SnipSnap::PlatformDetectExtension
Require Path: snipsnap/extensions/platform_detect
SnipSnap::SprocketsExtension
Require Path: snipsnap/extensions/sprockets
Optional:
ENV['ASSET_HOST']
prepended to asset URLsENV['API_ROOT']
prepended to API AJAX calls
Required:
gem 'sprockets'
gem 'sass'
gem 'coffee-script'
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request