Class: Reclone::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/reclone/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user.



2
3
4
# File 'lib/reclone/cli.rb', line 2

def current_user
  @current_user
end

Instance Method Details

#callObject



4
5
6
7
8
9
# File 'lib/reclone/cli.rb', line 4

def call
   up?
   puts "Hiya friend"; sleep 0.5
   
   recloner
end

#directory_exists?(directory) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/reclone/cli.rb', line 21

def directory_exists?(directory)
  Dir.exists?(directory)
end

#log_inObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/reclone/cli.rb', line 25

def 
  puts "Please enter your Github user name."
  user_name = gets.strip.to_s
  @current_user = User.new(user_name)

  if user_name == "exit"
    exit!
  elsif @current_user.
    puts "Oh hayyy, I found you!"
  else
    puts "I'm having a hard time locating that username."
    puts "Please try again."
    
  end
end

#reclonerObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/reclone/cli.rb', line 41

def recloner
  puts "Remember, the next step will clone repositories"
  puts "in your present working directory."
  puts " "
  puts "Make sure you are in the right place before doing the thing."
  puts " "
  puts " "
  puts "Shall I do the thing?"

  user_input = gets.strip

  if user_input == "yes"|| user_input == "y" || user_input == 'yis' ||user_input == "yeth"
    current_user.repos.each do |repo|
      if !directory_exists?(repo[:full_name])
        `git clone #{repo[:ssh_url]}`
      end
    end
  elsif user_input == "no"|| user_input == "n" || user_input == "nah"
    puts "Thanks for stopping by, I guess?"
    exit
  else
    recloner
  end
end

#up?Boolean

Internet connection check

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
# File 'lib/reclone/cli.rb', line 12

def up?
  if Net::Ping::External.new("www.google.com").ping? != true
    puts "You need an internet connection to run this program..."
    puts "As if I needed to tell you that."; sleep 1
    puts "Good bye for now."
    exit
  end
end