Class: GhIssues::GitHub

Inherits:
Object
  • Object
show all
Defined in:
lib/gh-issues/github.rb

Overview

I retrieve the GitHub user name and repository name from a local repository.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(folder) ⇒ GitHub

Returns a new instance of GitHub.

Parameters:

  • full (String)

    path of the local repository

Raises:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gh-issues/github.rb', line 26

def initialize folder
  hidden_git = File.join(folder, '.git')
  raise NoGitError unless File.directory?(hidden_git)
  
  config_file = File.join(hidden_git, 'config')
  raise NoConfigError unless File.file?(config_file)
  
  input = IO.readlines(config_file)
  url_line = ''
  input.each {|line| url_line = line if line =~ / *url *=/}
  raise BadConfigError if url_line.empty?
  
  /(?<repository>[\w-]+)\.git$/ =~ url_line
  @repository = repository
  
  /git@github\.com:(?<user>\w+)/ =~ url_line
  @user = user
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



23
24
25
# File 'lib/gh-issues/github.rb', line 23

def repository
  @repository
end

#userObject (readonly)

Returns the value of attribute user.



21
22
23
# File 'lib/gh-issues/github.rb', line 21

def user
  @user
end