summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2015-10-30 19:29:42 +0100
committerHarald Eilertsen <haraldei@anduin.net>2015-10-30 19:30:31 +0100
commitb07dd0f4c49ed42e1dd005118630da56228e4c9c (patch)
tree3ef74344916e3f802a34af52417fe1aeabbc6881
parent1b587d847f228eb474e1b33991b3fa5086725935 (diff)
downloadnorsk-urskog-registrations-b07dd0f4c49ed42e1dd005118630da56228e4c9c.tar.gz
norsk-urskog-registrations-b07dd0f4c49ed42e1dd005118630da56228e4c9c.tar.bz2
norsk-urskog-registrations-b07dd0f4c49ed42e1dd005118630da56228e4c9c.zip
Replace home grown config with sinatra-config-file
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock11
-rw-r--r--lib/config.rb14
-rw-r--r--registration.rb5
-rw-r--r--views/index.erb2
5 files changed, 16 insertions, 17 deletions
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.</p>
<p>Har dere spørsmål til skjemaet, eller utgivelsen så send oss en
- <a href="mailto:<%= @config.contact_email %>">epost</a> så vil vi hjelpe
+ <a href="mailto:<%= settings.contact_email %>">epost</a> så vil vi hjelpe
så godt vi kan.</p>
<p>Felter merket med <span class="required"></span> er obligatoriske og må fylles ut.</p>
<form id="registration-form" action="<%= url('submit') %>" method="POST" >