Sha256: 7e51ff88d7259a3dffcdbff47bef0dfe38dba1aad76dde678cd17cc89bde4074

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

require "gdshowsdb/version"

require 'rubygems'
require 'active_record'
require 'rails/generators'

require File.dirname(__FILE__) + '/gdshowsdb/diff.rb'
Dir[File.dirname(__FILE__) + '/gdshowsdb/*.rb'].each {|file| require file }
Dir[File.dirname(__FILE__) + '/gdshowsdb/db/migrations/*.rb'].each {|file| require file }
Dir[File.dirname(__FILE__) + '/gdshowsdb/models/extensions/*.rb'].each {|file| require file }
Dir[File.dirname(__FILE__) + '/gdshowsdb/models/*.rb'].each {|file| require file }
Dir[File.dirname(__FILE__) + '/gdshowsdb/generators/*.rb'].each {|file| require file }

module Gdshowsdb

  def generate_uuid
    SecureRandom.uuid
  end

	def self.init(params = { adapter: 'sqlite3', database: 'gdshowsdb.db' })
    @@connection = ActiveRecord::Base.establish_connection(params)		
	end

	def self.load(level = nil)
    ActiveRecord::Migrator.up File.dirname(__FILE__) + '/gdshowsdb/db/migrations', level		
  end 
  
  def self.yaml_file_location(file_name)
    Gem.loaded_specs['gdshowsdb'].full_gem_path + "/data/gdshowsdb/#{file_name}"
  end

  def self.load_yaml(file_name)
    YAML.load_file(yaml_file_location(file_name))
  end 

  def self.load_yaml_for_year(year)
    load_yaml("#{year}.yaml")
  end

  def self.write_yaml(file_name, data)
    File.open(yaml_file_location(file_name), "w") do |file|
      file.write data.to_yaml
    end
  end
end

class Hash
  def convert_to_sym
      inject({}) do |symboled, (k,v)| 
        symboled[k.to_sym] = v
        symboled
      end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gdshowsdb-1.0.3 lib/gdshowsdb.rb
gdshowsdb-1.0.2 lib/gdshowsdb.rb
gdshowsdb-1.0.1 lib/gdshowsdb.rb