errbit_github_plugin 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d065fceb33bbad9df6e9df79471b912477ecc0b
4
- data.tar.gz: cbe28f266f253f9893578f92e2df28decd5aaeb1
3
+ metadata.gz: afa68dc7f2ff60cfa5bca4d26fd9889a36bca7ad
4
+ data.tar.gz: f80c19060d3f571fe4882b3c62efbe6bc585ad42
5
5
  SHA512:
6
- metadata.gz: 64c90834ef30e02d15bfaf2d0fb7e922adb4b2768d978fc8c8ee120d0130d3afb78b27b98a7a03c5bdad425789c27153b9e718d939d48d5f4d8f047032c9d841
7
- data.tar.gz: 01ff1b430847c82bebc1b6e58219daffd43bba58ad25086b960d215b3628ac5db3c31ac7dbcfd79613178f1a4a7e8e9264cebe12fc013c73d7b47898366aca83
6
+ metadata.gz: e6101c37634049d1a0cdba1fad9c4f272f70ce64fa4e925265272974ad21d4fed6b61f91c4c133b957215931d40dc600ab81d4dccb715879a6a671023c0e1ef1
7
+ data.tar.gz: f3af3a3f80dda0814de880fd94b40a0497ecc7960f98df2c8bfb9063a078acd4c2ae73d91ba137130d2368c1432c0bcc4d9d0c1de836ae0b60153a3fb5e874cd
@@ -6,8 +6,9 @@ require 'errbit_github_plugin/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "errbit_github_plugin"
8
8
  spec.version = ErrbitGithubPlugin::VERSION
9
- spec.authors = ["Stephen Crosby"]
10
- spec.email = ["stevecrozz@gmail.com"]
9
+ spec.authors = ["Stephen Crosby", "Cyril Mougel"]
10
+ spec.email = ["stevecrozz@gmail.com", "cyril.mougel@gmail.com"]
11
+
11
12
  spec.description = %q{GitHub integration for Errbit}
12
13
  spec.summary = %q{GitHub integration for Errbit}
13
14
  spec.homepage = "https://github.com/brandedcrate/errbit_github_plugin"
@@ -1,12 +1,15 @@
1
1
  require "errbit_github_plugin/version"
2
2
  require 'errbit_github_plugin/error'
3
3
  require 'errbit_github_plugin/issue_tracker'
4
- require 'errbit_github_plugin/rails'
5
4
 
6
5
  module ErrbitGithubPlugin
7
6
  def self.root
8
7
  File.expand_path '../..', __FILE__
9
8
  end
9
+
10
+ def self.read_static_file(file)
11
+ File.read(File.join(self.root, 'static', file))
12
+ end
10
13
  end
11
14
 
12
15
  ErrbitPlugin::Registry.add_issue_tracker(ErrbitGithubPlugin::IssueTracker)
@@ -12,11 +12,11 @@ module ErrbitGithubPlugin
12
12
  'OAuth token.'
13
13
 
14
14
  FIELDS = {
15
- :username => {
16
- :placeholder => "Your username on GitHub"
15
+ username: {
16
+ placeholder: "Your username on GitHub"
17
17
  },
18
- :password => {
19
- :placeholder => "Password for your account"
18
+ password: {
19
+ placeholder: "Password for your account"
20
20
  }
21
21
  }
22
22
 
@@ -32,62 +32,55 @@ module ErrbitGithubPlugin
32
32
  FIELDS
33
33
  end
34
34
 
35
- def self.body_template
36
- @body_template ||= ERB.new(File.read(
37
- File.join(
38
- ErrbitGithubPlugin.root, 'views', 'github_issues_body.txt.erb'
39
- )
40
- ))
35
+ def self.icons
36
+ @icons ||= {
37
+ create: [
38
+ 'image/png', ErrbitGithubPlugin.read_static_file('github_create.png')
39
+ ],
40
+ goto: [
41
+ 'image/png', ErrbitGithubPlugin.read_static_file('github_goto.png'),
42
+ ],
43
+ inactive: [
44
+ 'image/png', ErrbitGithubPlugin.read_static_file('github_inactive.png'),
45
+ ]
46
+ }
41
47
  end
42
48
 
43
- attr_accessor :oauth_token
44
- attr_reader :url
45
-
46
49
  def configured?
47
- project_id.present?
50
+ errors.empty?
48
51
  end
49
52
 
50
- def comments_allowed?; false; end
51
-
52
- def project_id
53
- app.github_repo
53
+ def url
54
+ "https://github.com/#{repo}/issues"
54
55
  end
55
56
 
56
57
  def errors
57
58
  errors = []
58
- if self.class.fields.detect {|f| params[f[0]].blank? }
59
+ if self.class.fields.detect {|f| options[f[0]].blank? }
59
60
  errors << [:base, 'You must specify your GitHub username and password']
60
61
  end
62
+ if repo.blank?
63
+ errors << [:base, 'You must specify your GitHub repository url.']
64
+ end
61
65
  errors
62
66
  end
63
67
 
64
- def github_client
65
- # Login using OAuth token, if given.
66
- if oauth_token
67
- Octokit::Client.new(
68
- :login => params['username'], :oauth_token => oauth_token)
69
- else
70
- Octokit::Client.new(
71
- :login => params['username'], :password => params['password'])
72
- end
68
+ def repo
69
+ options[:github_repo]
73
70
  end
74
71
 
75
- def create_issue(problem, reported_by = nil)
76
- begin
77
- issue = github_client.create_issue(
78
- project_id,
79
- "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}",
80
- self.class.body_template.result(binding).unpack('C*').pack('U*')
81
- )
82
- @url = issue.html_url
83
- problem.update_attributes(
84
- :issue_link => issue.html_url,
85
- :issue_type => self.class.label
86
- )
87
-
88
- rescue Octokit::Unauthorized
89
- raise ErrbitGithubPlugin::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password."
72
+ def create_issue(title, body, user: {})
73
+ if user['github_login'] && user['github_oauth_token']
74
+ github_client = Octokit::Client.new(
75
+ login: user['github_login'], access_token: user['github_oauth_token'])
76
+ else
77
+ github_client = Octokit::Client.new(
78
+ login: options['username'], password: options['password'])
90
79
  end
80
+ issue = github_client.create_issue(repo, title, body)
81
+ issue.html_url
82
+ rescue Octokit::Unauthorized
83
+ raise ErrbitGithubPlugin::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password."
91
84
  end
92
85
  end
93
86
  end
@@ -1,3 +1,3 @@
1
1
  module ErrbitGithubPlugin
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: errbit_github_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Crosby
8
+ - Cyril Mougel
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-08-30 00:00:00.000000000 Z
12
+ date: 2015-04-23 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: errbit_plugin
@@ -69,6 +70,7 @@ dependencies:
69
70
  description: GitHub integration for Errbit
70
71
  email:
71
72
  - stevecrozz@gmail.com
73
+ - cyril.mougel@gmail.com
72
74
  executables: []
73
75
  extensions: []
74
76
  extra_rdoc_files: []
@@ -82,11 +84,12 @@ files:
82
84
  - lib/errbit_github_plugin.rb
83
85
  - lib/errbit_github_plugin/error.rb
84
86
  - lib/errbit_github_plugin/issue_tracker.rb
85
- - lib/errbit_github_plugin/rails.rb
86
87
  - lib/errbit_github_plugin/version.rb
88
+ - static/github_create.png
89
+ - static/github_goto.png
90
+ - static/github_inactive.png
87
91
  - vendor/assets/images/github_create.png
88
92
  - vendor/assets/images/github_inactive.png
89
- - views/github_issues_body.txt.erb
90
93
  homepage: https://github.com/brandedcrate/errbit_github_plugin
91
94
  licenses:
92
95
  - MIT
@@ -1,8 +0,0 @@
1
- if defined?(Rails)
2
- module ErrbitGithubPlugin
3
- module Rails
4
- class Engine < ::Rails::Engine
5
- end
6
- end
7
- end
8
- end
@@ -1,45 +0,0 @@
1
- [See this exception on Errbit](<%= problem.url %> "See this exception on Errbit")
2
- <% if notice = problem.notices.first %>
3
- # <%= notice.message %> #
4
- ## Summary ##
5
- <% if notice.request['url'].present? %>
6
- ### URL ###
7
- [<%= notice.request['url'] %>](<%= notice.request['url'] %>)"
8
- <% end %>
9
- ### Where ###
10
- <%= notice.where %>
11
-
12
- ### Occured ###
13
- <%= notice.created_at.to_s(:micro) %>
14
-
15
- ### Similar ###
16
- <%= (notice.problem.notices_count - 1).to_s %>
17
-
18
- ## Params ##
19
- ```
20
- <%= pretty_hash(notice.params) %>
21
- ```
22
-
23
- ## Session ##
24
- ```
25
- <%= pretty_hash(notice.session) %>
26
- ```
27
-
28
- ## Backtrace ##
29
- ```
30
- <% notice.backtrace_lines.each do |line| %><%= line.number %>: <%= line.file_relative %> -> **<%= line.method %>**
31
- <% end %>
32
- ```
33
-
34
- ## Environment ##
35
-
36
- <table>
37
- <% for key, val in notice.env_vars %>
38
- <tr>
39
- <td><%= key %>:</td>
40
- <td><%= val %></td>
41
- </tr>
42
- <% end %>
43
- </table>
44
- <% end %>
45
-