From df8dbe48e73581599f73c365e173fb017f0919c3 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sat, 5 Mar 2016 19:01:25 -0500 Subject: refactor model and db --- src/guff.cr | 15 --------------- src/guff/database.cr | 7 +++++++ src/guff/model.cr | 11 +++++++++++ 3 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 src/guff/database.cr create mode 100644 src/guff/model.cr diff --git a/src/guff.cr b/src/guff.cr index b19db4c..e62ff1f 100644 --- a/src/guff.cr +++ b/src/guff.cr @@ -1,22 +1,7 @@ -require "sqlite3" require "http/server" require "./guff/*" module Guff - class Database < ::SQLite3::Database - # TODO (add table_exists?) - end - - class Model - getter :db - - def initialize(@config : Config) - # create site database - db_path = "%s/site.db" % [config["data"]] - @db = Database.new(db_path) - end - end - class BlogHandler < Handler MATCHES = [%r{ ^/ diff --git a/src/guff/database.cr b/src/guff/database.cr new file mode 100644 index 0000000..de11eb2 --- /dev/null +++ b/src/guff/database.cr @@ -0,0 +1,7 @@ +require "sqlite3" + +module Guff + class Database < ::SQLite3::Database + # TODO (add table_exists?) + end +end diff --git a/src/guff/model.cr b/src/guff/model.cr new file mode 100644 index 0000000..370229c --- /dev/null +++ b/src/guff/model.cr @@ -0,0 +1,11 @@ +module Guff + class Model + getter :db + + def initialize(@config : Config) + # create site database + db_path = "%s/site.db" % [config["data"]] + @db = Database.new(db_path) + end + end +end -- cgit v1.2.3