Sha256: b3276b274a2e237b84f97a3dc8b029cebf7ad8de850d6c490a09e7b1f2134924
Contents?: true
Size: 1004 Bytes
Versions: 3
Compression:
Stored size: 1004 Bytes
Contents
#!/usr/bin/env ruby require 'safrano.rb' require 'sequel' require 'fileutils' class FiveApples CONFIGDIRNAME = 'fiveapples'.freeze DBFILENAME = 'fiveapples.db3'.freeze CONFIGRU = 'config5.ru' attr_reader :db def initialize gconfigdir = File.expand_path('.config', Dir.home) @apphome = File.expand_path(CONFIGDIRNAME, gconfigdir) @libdir = __dir__.dup @systemdbname = File.join(@libdir, DBFILENAME) @homedbname = File.expand_path(DBFILENAME, @apphome) @configru = File.expand_path(CONFIGRU, @libdir) end def setup_db_in_homedir FileUtils.mkdir_p(@apphome) unless Dir.exist?(@apphome) FileUtils.cp(@systemdbname, @homedbname) unless File.exist?(@homedbname) end def startdb setup_db_in_homedir @db = Sequel::Model.db = Sequel.sqlite(@homedbname) Kernel.at_exit { Sequel::Model.db.disconnect if Sequel::Model.db } end def serve Dir.chdir @libdir exec "rackup -I#{@libdir} #{@configru}" end end FiveA = FiveApples.new
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fiveapples-0.0.3 | lib/fiveapples.rb |
fiveapples-0.0.2 | lib/fiveapples.rb |
fiveapples-0.0.1 | lib/fiveapples.rb |