mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-22 02:52:49 +01:00
Use a minimal app framework
This commit is contained in:
parent
1f9e2f1932
commit
4fdd65ac3c
7
Rakefile
7
Rakefile
@ -1,8 +1,7 @@
|
||||
$: << 'lib'
|
||||
|
||||
require 'fixer'
|
||||
require_relative 'config/environment'
|
||||
require 'rake/testtask'
|
||||
require 'db'
|
||||
require 'currency'
|
||||
require 'fixer'
|
||||
|
||||
namespace :rates do
|
||||
desc 'Reload all rates'
|
||||
|
@ -1,3 +1,3 @@
|
||||
$: << 'lib'
|
||||
require 'app'
|
||||
require './config/environment'
|
||||
require 'api'
|
||||
run Sinatra::Application
|
||||
|
18
config/app.rb
Normal file
18
config/app.rb
Normal file
@ -0,0 +1,18 @@
|
||||
require 'logger'
|
||||
require 'pathname'
|
||||
|
||||
module App
|
||||
class << self
|
||||
attr :logger
|
||||
|
||||
def env
|
||||
ENV['RACK_ENV'] || 'development'
|
||||
end
|
||||
|
||||
def root
|
||||
Pathname.pwd
|
||||
end
|
||||
end
|
||||
|
||||
@logger = Logger.new(STDOUT)
|
||||
end
|
3
config/environment.rb
Normal file
3
config/environment.rb
Normal file
@ -0,0 +1,3 @@
|
||||
require_relative 'app'
|
||||
$LOAD_PATH << App.root.join('lib')
|
||||
Dir[App.root.join('config/initializers/*.rb')].each { |f| require f }
|
5
config/initializers/sequel.rb
Normal file
5
config/initializers/sequel.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require 'pg'
|
||||
require 'sequel'
|
||||
|
||||
Sequel.single_threaded = true
|
||||
Sequel.connect(ENV['DATABASE_URL'] || "postgres://localhost/fixer_#{App.env}")
|
@ -1,7 +1,3 @@
|
||||
require 'sequel'
|
||||
|
||||
Sequel.connect ENV['DATABASE_URL'] || 'postgres://localhost/fixer'
|
||||
|
||||
class Currency < Sequel::Model
|
||||
def self.last_date
|
||||
order(:date).last.date
|
@ -1,5 +1,5 @@
|
||||
require 'virtus'
|
||||
require 'db'
|
||||
require 'currency'
|
||||
|
||||
class Snapshot
|
||||
include Virtus
|
||||
|
@ -1,8 +1,8 @@
|
||||
require_relative 'helper'
|
||||
require 'rack/test'
|
||||
require 'app'
|
||||
require 'api'
|
||||
|
||||
describe 'the application' do
|
||||
describe 'the API' do
|
||||
include Rack::Test::Methods
|
||||
|
||||
let(:app) { Sinatra::Application }
|
@ -1,6 +1,6 @@
|
||||
require_relative 'helper'
|
||||
require 'rack/test'
|
||||
require 'app'
|
||||
require 'server'
|
||||
|
||||
if ENV['BENCH']
|
||||
describe 'benchmark the app' do
|
||||
|
@ -1,3 +1,5 @@
|
||||
ENV['RACK_ENV'] = 'test'
|
||||
require './config/environment'
|
||||
require 'minitest/autorun'
|
||||
require 'minitest/benchmark' if ENV['BENCH']
|
||||
require 'minitest/pride'
|
||||
|
Loading…
Reference in New Issue
Block a user