Module: Arfor::Util::Github

Defined in:
lib/arfor/util/github.rb

Class Method Summary collapse

Class Method Details

.create_repository(git_name, git_opts) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/arfor/util/github.rb', line 38

def self.create_repository(git_name, git_opts)
  puts "creating #{git_name}"
  client = Octokit::Client.new(:access_token => read_token)
  # user = client.user
  # puts user.login
  resp = client.create_repository(git_name, git_opts)

  resp
end

.read_tokenObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/arfor/util/github.rb', line 23

def self.read_token
  if File.exists?(Arfor::TOKEN_FILE)
    token = File.read(Arfor::TOKEN_FILE)
  else
    token = ask "#{Arfor::QUESTION} Github token (https://github.com/settings/tokens/new): "
    write_token(token)
  end

  token
end

.write_token(token) ⇒ Object



34
35
36
# File 'lib/arfor/util/github.rb', line 34

def self.write_token(token)
  File.write(Arfor::TOKEN_FILE, token)
end