Class: GhIssues::GitHub
- Inherits:
-
Object
- Object
- GhIssues::GitHub
- 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
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(folder) ⇒ GitHub
constructor
A new instance of GitHub.
Constructor Details
#initialize(folder) ⇒ GitHub
Returns a new instance of GitHub.
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
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
23 24 25 |
# File 'lib/gh-issues/github.rb', line 23 def repository @repository end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
21 22 23 |
# File 'lib/gh-issues/github.rb', line 21 def user @user end |