feedhub 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/feedhub.rb +65 -0
  2. metadata +56 -0
data/lib/feedhub.rb ADDED
@@ -0,0 +1,65 @@
1
+ require 'octokit'
2
+
3
+ module Feedhub
4
+
5
+ # Set github account
6
+ def self.set_user auth
7
+ @user_name = auth[:name]
8
+ @user_pw = auth[:password]
9
+ end
10
+
11
+ # Set repo
12
+ def self.set_repo repo
13
+ @repo_user = repo[:account]
14
+ @repo_name = repo[:name]
15
+ @repository = @repo_user + '/' + @repo_name
16
+ end
17
+
18
+ # Authenticate user
19
+ def self.github_auth
20
+ begin
21
+ @@client = Octokit::Client.new(:login => @user_name, :password => @user_pw)
22
+ rescue Exception => e
23
+ puts "Unable to login to github.\n#{e}"
24
+ end
25
+ end
26
+
27
+ # Return label if label exists
28
+ def self.label_exists name
29
+ github_auth
30
+ begin
31
+ @@client.label(@repository, name)
32
+ rescue
33
+ puts "This label does not exists"
34
+ false
35
+ end
36
+ end
37
+
38
+ # create a new label
39
+ def self.create_label name, color = "FF0000"
40
+ @@client.add_label(@repository, name, color) if !label_exists(name)
41
+ end
42
+
43
+ # Open issues
44
+ def self.open_issue issue
45
+ github_auth
46
+ return false if !label_exists(issue[:label])
47
+
48
+ begin
49
+ @@client.create_issue(@repository, issue[:title], issue[:body], { :labels => [issue[:label]] })
50
+ rescue Exception => e
51
+ puts "Error: Unable to create issue!\n#{e}"
52
+ end
53
+ end
54
+
55
+ # opens issue and creates label if it does not exists
56
+ def self.open_issue! issue
57
+ github_auth
58
+ begin
59
+ create_label(issue[:label]) if !label_exists(issue[:label])
60
+ @@client.create_issue(@repository, issue[:title], issue[:body], { :labels => [issue[:label]] })
61
+ rescue Exception => e
62
+ puts "Error: Unable to create issue!\n#{e}"
63
+ end
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: feedhub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Francois Weber
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: octokit
16
+ requirement: &19439904 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *19439904
25
+ description: Save data (from a form or from s.t. else) as github issue
26
+ email: webarbeit@gmail.com
27
+ executables: []
28
+ extensions: []
29
+ extra_rdoc_files: []
30
+ files:
31
+ - lib/feedhub.rb
32
+ homepage: https://github.com/webarbeit/feedhub
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.8.16
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: Save user feedback as github issue
56
+ test_files: []