aboutsummaryrefslogtreecommitdiff
path: root/src/guff/model.cr
blob: 1df437be60e93aee6513a5d06153fa7c939d516b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require "./database"
require "./database-updater"

module Guff
  class Model
    getter :config
    getter :db

    def initialize(@config : Config)
      # create site database
      db_path = "%s/site.db" % [config["data"]]

      # update database (if necessary)
      update_db(db_path)

      # open db
      @db = Database.new(db_path)
    end

    private def update_db(path)
      DatabaseUpdater.run(path, @config)
    end
  end
end