Class: T1k::Repositories::Github
- Inherits:
-
Object
- Object
- T1k::Repositories::Github
- Defined in:
- lib/t1k/repositories/github.rb
Defined Under Namespace
Classes: Issue
Constant Summary collapse
- @@oauth_token =
""
- @@user =
""
- @@repo =
""
- @@messages =
[]
- @@errors =
[]
Class Method Summary collapse
- .create_issue(title) ⇒ Object
- .get_issue(issue_number) ⇒ Object
- .get_issue_number(html_url) ⇒ Object
- .login ⇒ Object
- .setup {|_self| ... } ⇒ Object
- .valid_keys? ⇒ Boolean
Class Method Details
.create_issue(title) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/t1k/repositories/github.rb', line 23 def self.create_issue title begin puts 'Creating issue' github_auth = self.login issue = github_auth.issues.create(user: self.user, repo: self.repo, title: title) issue.html_url rescue raise 'Issue not created' end end |
.get_issue(issue_number) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/t1k/repositories/github.rb', line 35 def self.get_issue issue_number begin puts 'Recovering existent issue' github_auth = self.login issue = github_auth.issues.get(user: self.user, repo: self.repo, number: issue_number) issue.html_url rescue raise 'Issue not recovered' end end |
.get_issue_number(html_url) ⇒ Object
47 48 49 50 |
# File 'lib/t1k/repositories/github.rb', line 47 def self.get_issue_number html_url code = html_url[html_url.rindex('/')+1..html_url.size] Issue.new(code, "Link to code: [#{code}](#{html_url})") end |
.login ⇒ Object
52 53 54 |
# File 'lib/t1k/repositories/github.rb', line 52 def self.login ::Github.new(oauth_token: self.oauth_token) end |
.setup {|_self| ... } ⇒ Object
56 57 58 |
# File 'lib/t1k/repositories/github.rb', line 56 def self.setup &block yield(self) if block_given? end |
.valid_keys? ⇒ Boolean
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/t1k/repositories/github.rb', line 60 def self.valid_keys? begin me = self.login.users.get @@messages << "Wecolme #{me.name} - Github" return true rescue Exception => e @@errors << e. return false end end |