Sha256: 39f453a769b0f1226fb6f3135b503790ac58269f75decba8199885a6368e8b89

Contents?: true

Size: 853 Bytes

Versions: 4

Compression:

Stored size: 853 Bytes

Contents

require "bait/version"
require 'moneta'
require 'fileutils'
require 'bait/assets'
require 'pathname'

module Bait
  class << self
    include Bait::Assets

    def storage_dir
      path = File.join("#{home}", "#{env}")
      FileUtils.mkdir_p path
      path
    end

    def db_dir
      db_dir = File.join storage_dir, "databases"
      FileUtils.mkdir_p db_dir
      db_dir
    end

    def db_file name
      yaml_file = File.join db_dir, "#{name}.yaml"
      FileUtils.touch yaml_file
      yaml_file
    end

    def store
      @store ||= begin
        Moneta.new :YAML, :file => db_file("main")
      end
    end

    def env
      ENV['RACK_ENV'] ||= 'production'
    end

    def home
      File.join Etc.getpwuid.dir, '.bait'
    end

    def public
      Pathname.new(File.join(File.dirname(__FILE__), 'bait', 'public'))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bait-0.5.11 lib/bait.rb
bait-0.5.10 lib/bait.rb
bait-0.5.9 lib/bait.rb
bait-0.5.6 lib/bait.rb