Module: Ghruby

Extended by:
Ghruby
Included in:
Ghruby
Defined in:
lib/ghruby.rb,
lib/ghruby/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#prompt_passwordObject



46
47
48
49
# File 'lib/ghruby.rb', line 46

def prompt_password
  puts "password > "
  password = STDIN.noecho(&:gets).chomp
end

#prompt_usernameObject



59
60
61
62
# File 'lib/ghruby.rb', line 59

def prompt_username
  puts "github username > "
  username = STDIN.gets.chomp
end

#set_credentials(args) ⇒ Object



68
69
70
# File 'lib/ghruby.rb', line 68

def set_credentials(args)
  {url: set_url(args), username: set_username, password: set_password}
end

#set_passwordObject



64
65
66
# File 'lib/ghruby.rb', line 64

def set_password
  ENV['GHREPO_KEY'] || prompt_password
end

#set_url(args) ⇒ Object



51
52
53
# File 'lib/ghruby.rb', line 51

def set_url(args)
  args.include?('-ssl') ? 'ssh_url' : 'git_url'
end

#set_usernameObject



55
56
57
# File 'lib/ghruby.rb', line 55

def set_username
  ENV['GHREPO_USERNAME'] || prompt_username
end

#start(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ghruby.rb', line 11

def start(args)
  if args.any?
    repo_name = args.pop
    credentials = set_credentials(args)
    response = `curl -u "#{credentials[:username]}:#{credentials[:password]}" https://api.github.com/user/repos -d '{"name":"'#{repo_name}'"}'`
    git_url = JSON.parse(response)[credentials[:url]]

    `git clone "#{git_url}"`
  else
    puts "RTFM dummy!"
    puts <<-eos
      ░░░░░░░░░▄░░░░░░░░░░░░░░▄░░░░
      ░░░░░░░░▌▒█░░░░░░░░░░░▄▀▒▌░░░
      ░░░░░░░░▌▒▒█░░░░░░░░▄▀▒▒▒▐░░░
      ░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐░░░
      ░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐░░░
      ░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌░░░
      ░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌░░
      ░░▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐░░
      ░▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌░
      ░▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌░
      ▀▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒▐░
      ▐▒▒▐▀▐▀▒░▄▄▒▄▒▒▒▒▒▒░▒░▒░▒▒▒▒▌
      ▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐░
      ░▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒░▒░▒░▒░▒▒▒▌░
      ░▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐░░
      ░░▀▄▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▄▒▒▒▒▌░░
      ░░░░▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀░░░
      ░░░░░░▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀░░░░░
      ░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▀▀░░░░░░░░
    eos
    puts "such moron very dumb"
  end
end