Class: Devkit::Core

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

Class Method Summary collapse

Class Method Details

.check_if_devkit_file_exists?Boolean

Returns:

  • (Boolean)


44
45
46
47
48
49
50
# File 'lib/devkit/core.rb', line 44

def check_if_devkit_file_exists?
  if File.exists?(DEVKIT_FILE_PATH)
    return true
  else
    return false
  end
end

.clear_existing_devkit_fileObject



32
33
34
# File 'lib/devkit/core.rb', line 32

def clear_existing_devkit_file
  File.truncate(DEVKIT_FILE_PATH, 0)
end

.identitiesObject



36
37
38
39
40
41
42
# File 'lib/devkit/core.rb', line 36

def identities
  if check_if_devkit_file_exists?
    YAML.load_file(DEVKIT_FILE_PATH) || {}
  else
    {}
  end
end

.init!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/devkit/core.rb', line 7

def init!
  if check_if_devkit_file_exists?
    if agree(".devkit file already exist.You want to over ride existing file? (y/n)", true)
      clear_existing_devkit_file
      puts "Cleared existing identities in .devkit file"
    else
      puts "No changes made to the existing file."
    end
  else
    puts "Creating .devkit file in your home directory. Try devkit --add for adding more identities to devkit."
    File.new(DEVKIT_FILE_PATH, "w")
  end
end

.purge!Object



21
22
23
24
25
# File 'lib/devkit/core.rb', line 21

def purge!
  if check_if_devkit_file_exists? && agree("Are you sure you want to clear existing devkit file? (y/n)", true)
    clear_existing_devkit_file
  end
end

.statusObject



27
28
29
30
# File 'lib/devkit/core.rb', line 27

def status
  Devkit::GitIdentity::status
  Devkit::SshIdentity::status
end