Sha256: b178dc572dacf780e1b2009ff2b945e483220f586fb7af5ea9229e312f7d2597

Contents?: true

Size: 666 Bytes

Versions: 11

Compression:

Stored size: 666 Bytes

Contents

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

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

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

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

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

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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bait-0.5.4 lib/bait.rb
bait-0.5.2 lib/bait.rb
bait-0.5.1 lib/bait.rb
bait-0.5.0 lib/bait.rb
bait-0.4.1 lib/bait.rb
bait-0.4.0 lib/bait.rb
bait-0.3.2 lib/bait.rb
bait-0.3.1 lib/bait.rb
bait-0.3.0 lib/bait.rb
bait-0.2.1 lib/bait.rb
bait-0.2.0 lib/bait.rb