Class: CLI::Dependencies

Inherits:
Object
  • Object
show all
Defined in:
lib/what_is_this/Dependencies.rb

Constant Summary collapse

@@spacing =
"\n\n\n"
@@message_spacing =
"         "
@@dependencies =
[]

Class Method Summary collapse

Class Method Details

.display_dependenciesObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/what_is_this/Dependencies.rb', line 6

def self.display_dependencies
    print = false
    text = File.readlines('Gemfile.lock').each do |line|
        line = line.to_str
        if (line == "DEPENDENCIES\n")
            print = true
        else
            if (line == "BUNDLED WITH\n")
                print = false
            elsif (print == true)
                if (!@@dependencies.include?(line.split[0]))
                    @@dependencies << line.split[0] unless line.split[0].nil?
                end
                puts line

                
            end
        end
        
    end
    self.enquire
end

.enquireObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/what_is_this/Dependencies.rb', line 28

def self.enquire
    puts @@message_spacing + "List the gem you would like to delete, or type 'back'" + @@spacing
    p @@dependencies
    input = gets.chomp
    case input
    when "back"
        CLI.restart
    else 
        if (@@dependencies.include?(input))

            system("gem uninstall #{input}")
            system("bundle remove #{input}")
            system("bundle install")
            @@dependencies.delete(input)
            self.display_dependencies
            
        else
            puts @@message_spacing + "Command not recognised. Try again" + @@spacing
            self.enquire
        end
        
    
    end
end