Module: GitHub::Config

Defined in:
lib/github-api-client/config.rb

Overview

Keeps all the configuration stuff

Constant Summary collapse

Path =

Constant with defined all the paths used in the application

{
  :dir        => ENV['HOME'] + "/.github", 
  :dbfile     => ENV['HOME'] + "/.github/github.db", 
  :migrations => ROOT +  "/db/migrate", 
  :secrets    => ENV['HOME'] + "/.github" + "/secrets.yml"
}
Version =
File.read(
  ROOT + "/VERSION"
)
VERSION =
Version
Secrets =

Secrets array, uses env vars if defined

{
  "login" => ENV['GITHUB_USER'], 
  "token" => ENV['GITHUB_TOKEN']
}
Options =
{
  :verbose => false
}

Class Method Summary collapse

Class Method Details

.resetObject



60
61
62
63
# File 'lib/github-api-client/config.rb', line 60

def self.reset
  system "rm #{Path[:dbfile]}"
  setup
end

.setupnil

Sets up the database and migrates it

Returns:



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/github-api-client/config.rb', line 48

def self.setup
  Dir.mkdir GitHub::Config::Path[:dir] rescue nil
  ActiveRecord::Base.establish_connection(
    :adapter => 'sqlite3', 
    :database => GitHub::Config::Path[:dbfile]
  )
  ActiveRecord::Migrator.migrate(
    GitHub::Config::Path[:migrations], 
    nil
  ) if not File.exists? GitHub::Config::Path[:dbfile]
end