Sha256: 41a2eedb2a5e20bb00eacfa852fba16e6ed477c9beb07cab06f6edea7a24ee7a

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 Bytes

Contents

require 'fileutils'
require 'json'
module Radon
class Util
  def self.first_run
    return if (File.directory?(SETTINGS_DIR) && File.exist?(SETTINGS_FILE))
    puts "Performing first time setup..."
    
    # Make settings dir
    FileUtils.mkdir_p(SETTINGS_DIR)
    vprint("Creating #{SETTINGS_DIR}")

    puts "Welcome to radon! It looks like it's your first time running radon."
    email    = ask "  Email: "
    gh_uname = ask "  GitHub username: "

    data = {
      :email => email,
      :username => gh_uname
    }

    File.write(File.join(SETTINGS_DIR, 'settings.json'), JSON.pretty_generate(data))
    vprint "Writing settings to #{File.join(SETTINGS_DIR, 'settings.json')}"
  end

  def self.get_email
    JSON.parse(File.read(SETTINGS_FILE))['email']
  end

  def self.get_github_username
    JSON.parse(File.read(SETTINGS_FILE))['username']
  end
  
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radon-0.1.7 lib/core/util.rb