From b07dd0f4c49ed42e1dd005118630da56228e4c9c Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Fri, 30 Oct 2015 19:29:42 +0100 Subject: Replace home grown config with sinatra-config-file --- Gemfile | 1 + Gemfile.lock | 11 +++++++++++ lib/config.rb | 14 -------------- registration.rb | 5 +++-- views/index.erb | 2 +- 5 files changed, 16 insertions(+), 17 deletions(-) delete mode 100644 lib/config.rb diff --git a/Gemfile b/Gemfile index dffb3f0..519fcbb 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source "https://rubygems.org" gem "sinatra" gem "sinatra-url-for" +gem "sinatra-config-file" gem "mail" gem "prawn" diff --git a/Gemfile.lock b/Gemfile.lock index 106561f..c4a3bbf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,7 @@ GEM remote: https://rubygems.org/ specs: + backports (3.6.6) byebug (6.0.2) capistrano (3.4.0) i18n @@ -69,6 +70,15 @@ GEM rack (~> 1.4) rack-protection (~> 1.4) tilt (>= 1.3, < 3) + sinatra-config-file (1.0) + sinatra-contrib + sinatra-contrib (1.4.6) + backports (>= 2.0) + multi_json + rack-protection + rack-test + sinatra (~> 1.4.0) + tilt (>= 1.3, < 3) sinatra-url-for (0.2.2.1) sinatra (>= 0.9.1.1) sshkit (1.7.1) @@ -97,6 +107,7 @@ DEPENDENCIES rspec selenium-webdriver sinatra + sinatra-config-file sinatra-url-for BUNDLED WITH diff --git a/lib/config.rb b/lib/config.rb deleted file mode 100644 index bc42c34..0000000 --- a/lib/config.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'yaml' - -class Config - attr_reader :contact_email - - def self.load - conf = YAML.load(IO.read("config.yml")) - Config.new(conf) - end - - def initialize(conf) - @contact_email = conf['contact_email'] - end -end diff --git a/registration.rb b/registration.rb index 34baf84..6875e52 100644 --- a/registration.rb +++ b/registration.rb @@ -1,17 +1,18 @@ require 'sinatra/base' require 'sinatra/url_for' +require 'sinatra/config_file' require 'tilt/erb' require_relative 'lib/registration' -require_relative 'lib/config' class RegistrationApp < Sinatra::Base + register Sinatra::ConfigFile helpers Sinatra::UrlForHelper include ERB::Util enable :sessions + config_file File.join(settings.root, 'config.yml') get '/' do - @config = Config.load @band = Band.new 3.times { @band.songs << Song.new } erb :index diff --git a/views/index.erb b/views/index.erb index 17a1d6c..9ad34ea 100644 --- a/views/index.erb +++ b/views/index.erb @@ -11,7 +11,7 @@ Vi holder også av nok CDer til at alle som deltar får noen eksemplarer hver til å dele ut til sine kontakter.

Har dere spørsmål til skjemaet, eller utgivelsen så send oss en - epost så vil vi hjelpe + epost så vil vi hjelpe så godt vi kan.

Felter merket med er obligatoriske og må fylles ut.

-- cgit v1.2.3