From fd7566157252e7bb090bbef32e4e377091deb003 Mon Sep 17 00:00:00 2001 From: Bertrand Paquet Date: Tue, 26 Jan 2016 15:34:40 +0100 Subject: [PATCH] Add sinatra adapter for figaro --- lib/figaro/sinatra.rb | 9 +++++++++ lib/figaro/sinatra/sinatra_app.rb | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 lib/figaro/sinatra.rb create mode 100644 lib/figaro/sinatra/sinatra_app.rb diff --git a/lib/figaro/sinatra.rb b/lib/figaro/sinatra.rb new file mode 100644 index 00000000..eb145054 --- /dev/null +++ b/lib/figaro/sinatra.rb @@ -0,0 +1,9 @@ +begin + require 'sinatra' +rescue LoadError +else + require 'figaro' + require 'figaro/sinatra/sinatra_app' + Figaro.adapter = Figaro::SinatraApp + Figaro.load +end diff --git a/lib/figaro/sinatra/sinatra_app.rb b/lib/figaro/sinatra/sinatra_app.rb new file mode 100644 index 00000000..37ef754f --- /dev/null +++ b/lib/figaro/sinatra/sinatra_app.rb @@ -0,0 +1,15 @@ + +module Figaro + class SinatraApp < Figaro::Application + private + + def default_path + File.join("config", "application.yml") + end + + def default_environment + ENV['RACK_ENV'] + end + + end +end