Module: Feedhub
- Defined in:
- lib/feedhub.rb
Class Method Summary collapse
-
.create_label(name, color = "FF0000") ⇒ Object
create a new label.
-
.github_auth ⇒ Object
Authenticate user.
-
.label_exists(name) ⇒ Object
Return label if label exists.
-
.open_issue(issue) ⇒ Object
Open issues.
-
.open_issue!(issue) ⇒ Object
opens issue and creates label if it does not exists.
-
.set_repo(repo) ⇒ Object
Set repo.
-
.set_user(auth) ⇒ Object
Set github account.
Class Method Details
.create_label(name, color = "FF0000") ⇒ Object
create a new label
39 40 41 |
# File 'lib/feedhub.rb', line 39 def self.create_label name, color = "FF0000" @@client.add_label(@repository, name, color) if !label_exists(name) end |
.github_auth ⇒ Object
Authenticate user
19 20 21 22 23 24 25 |
# File 'lib/feedhub.rb', line 19 def self.github_auth begin @@client = Octokit::Client.new(:login => @user_name, :password => @user_pw) rescue Exception => e puts "Unable to login to github.\n#{e}" end end |
.label_exists(name) ⇒ Object
Return label if label exists
28 29 30 31 32 33 34 35 36 |
# File 'lib/feedhub.rb', line 28 def self.label_exists name github_auth begin @@client.label(@repository, name) rescue puts "This label does not exists" false end end |
.open_issue(issue) ⇒ Object
Open issues
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/feedhub.rb', line 44 def self.open_issue issue github_auth return false if !label_exists(issue[:label]) begin @@client.create_issue(@repository, issue[:title], issue[:body], { :labels => [issue[:label]] }) rescue Exception => e puts "Error: Unable to create issue!\n#{e}" end end |
.open_issue!(issue) ⇒ Object
opens issue and creates label if it does not exists
56 57 58 59 60 61 62 63 64 |
# File 'lib/feedhub.rb', line 56 def self.open_issue! issue github_auth begin create_label(issue[:label]) if !label_exists(issue[:label]) @@client.create_issue(@repository, issue[:title], issue[:body], { :labels => [issue[:label]] }) rescue Exception => e puts "Error: Unable to create issue!\n#{e}" end end |
.set_repo(repo) ⇒ Object
Set repo
12 13 14 15 16 |
# File 'lib/feedhub.rb', line 12 def self.set_repo repo @repo_user = repo[:account] @repo_name = repo[:name] @repository = @repo_user + '/' + @repo_name end |
.set_user(auth) ⇒ Object
Set github account
6 7 8 9 |
# File 'lib/feedhub.rb', line 6 def self.set_user auth @user_name = auth[:name] @user_pw = auth[:password] end |