Class: Radon::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/core/util.rb

Class Method Summary collapse

Class Method Details

.first_runObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/core/util.rb', line 5

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

.get_emailObject



26
27
28
# File 'lib/core/util.rb', line 26

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

.get_github_usernameObject



30
31
32
# File 'lib/core/util.rb', line 30

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