Sha256: ba179efc5a4363f552f5353c0bd907fcbcf1fb9d312f3c3f45c634e348e239ed

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

require 'rubygems' if RUBY_VERSION <= "1.8.7"
require 'etc'
require 'json'
require 'yaml'
require 'fileutils'
require 'faraday'
require 'exercism/version'
require 'exercism/config'
require 'exercism/user'
require 'exercism/assignment'
require 'exercism/api'

class Exercism

  def self.home
    if ENV["OS"] == 'Windows_NT' then
      ENV["HOMEDRIVE"]+ENV["HOMEPATH"]
    else
      return File.expand_path('~') if RUBY_VERSION <= "1.8.7"
      Dir.home(Etc.getlogin)
    end
  end

  def self.login(github_username, key, dir)
    data = {
      'github_username' => github_username,
      'key' => key,
      'project_dir' => dir
    }
    Config.write(home, data)
    User.new(github_username, key)
  end

  def self.config
    Config.read(home)
  end

  def self.user
    c = config
    User.new(c.github_username, c.key)
  end

  def self.project_dir
    config.project_dir
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exercism-0.0.18 lib/exercism.rb