Class: GitHubLayer

Inherits:
Object
  • Object
show all
Defined in:
lib/homer/github_layer.rb

Class Method Summary collapse

Class Method Details

.create_repo_if_repo_does_not_exist(repo_name) ⇒ Object


16
17
18
19
20
21
22
23
24
# File 'lib/homer/github_layer.rb', line 16

def create_repo_if_repo_does_not_exist(repo_name)
  token = FileLayer.read_authorization_token  
  github = Github.new(oauth_token: token)
  begin
    github.repos.get(github., repo_name)
  rescue Github::Error::NotFound
    github.repos.create(name: repo_name)
  end
end

.login(login, password) ⇒ Object


8
9
10
11
12
13
14
# File 'lib/homer/github_layer.rb', line 8

def (, password)
  github = Github.new(login: , password: password)
  authorization = github.oauth.create(scopes: ['public_repo'], note: 'Homer')
  FileLayer.save_authorization_token(authorization.token)
rescue Github::Error::Unauthorized
  raise "Invalid GitHub Login/Password"
end