Class: Releasinator::GitHubRepo
- Inherits:
-
Object
- Object
- Releasinator::GitHubRepo
- Defined in:
- lib/github_repo.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#org ⇒ Object
readonly
Returns the value of attribute org.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #check_token(token_param) ⇒ Object
-
#initialize(url) ⇒ GitHubRepo
constructor
A new instance of GitHubRepo.
Constructor Details
#initialize(url) ⇒ GitHubRepo
Returns a new instance of GitHubRepo.
9 10 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 |
# File 'lib/github_repo.rb', line 9 def initialize(url) @url = url if url.start_with?("https") # https: "https://github.com/braebot/test.git" slash_split = url.split("/") @domain = slash_split[2] @repo = slash_split.last.split(".git").first slash_split.pop @org = slash_split.last else # ssh: [email protected]:braebot/test.git" colon_split = url.split(":") at_split = colon_split.first.split("@") @domain = at_split.last slash_split = colon_split.last.split("/") @org = slash_split.first @repo = slash_split.last.split(".git").first end @url.freeze @org.freeze @repo.freeze @domain.freeze if @domain == "github.com" check_token("GITHUB_TOKEN") @client = Octokit::Client.new(:access_token => ENV["GITHUB_TOKEN"]) else env_key = "#{@domain.gsub(".", "_").upcase}_GITHUB_TOKEN" check_token(env_key) @client = Octokit::Client.new(:access_token => ENV[env_key], :api_endpoint => "https://#{@domain}/api/v3/") end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/github_repo.rb', line 7 def client @client end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
7 8 9 |
# File 'lib/github_repo.rb', line 7 def domain @domain end |
#org ⇒ Object (readonly)
Returns the value of attribute org.
7 8 9 |
# File 'lib/github_repo.rb', line 7 def org @org end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
7 8 9 |
# File 'lib/github_repo.rb', line 7 def repo @repo end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/github_repo.rb', line 7 def url @url end |
Instance Method Details
#check_token(token_param) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/github_repo.rb', line 43 def check_token(token_param) if !ENV[token_param] Printer.fail("#{token_param} environment variable required. Please set this to your personal access token.") abort() end end |