Class: T1k::Repositories::Github

Inherits:
Object
  • Object
show all
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

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.
    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.
    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

.loginObject



52
53
54
# File 'lib/t1k/repositories/github.rb', line 52

def self.
  ::Github.new(oauth_token: self.oauth_token)
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



56
57
58
# File 'lib/t1k/repositories/github.rb', line 56

def self.setup &block
  yield(self) if block_given?
end

.valid_keys?Boolean

Returns:

  • (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..users.get
    @@messages << "Wecolme #{me.name} - Github"
    return true
  rescue Exception => e
    @@errors << e.message
    return false
  end
end