codeclimate-services 0.3.0
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-version +1 -0
- data/.travis.yml +13 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +121 -0
- data/Rakefile +11 -0
- data/bin/bundler +16 -0
- data/bin/coderay +16 -0
- data/bin/nokogiri +16 -0
- data/bin/pry +16 -0
- data/bin/rake +16 -0
- data/codeclimate-services.gemspec +29 -0
- data/config/cacert.pem +4026 -0
- data/config/load.rb +4 -0
- data/lib/axiom/types/password.rb +7 -0
- data/lib/cc/formatters/linked_formatter.rb +60 -0
- data/lib/cc/formatters/plain_formatter.rb +36 -0
- data/lib/cc/formatters/snapshot_formatter.rb +101 -0
- data/lib/cc/formatters/ticket_formatter.rb +27 -0
- data/lib/cc/helpers/coverage_helper.rb +25 -0
- data/lib/cc/helpers/issue_helper.rb +9 -0
- data/lib/cc/helpers/quality_helper.rb +44 -0
- data/lib/cc/helpers/vulnerability_helper.rb +31 -0
- data/lib/cc/presenters/github_pull_requests_presenter.rb +54 -0
- data/lib/cc/service/config.rb +4 -0
- data/lib/cc/service/formatter.rb +34 -0
- data/lib/cc/service/helper.rb +54 -0
- data/lib/cc/service/http.rb +87 -0
- data/lib/cc/service/invocation/invocation_chain.rb +15 -0
- data/lib/cc/service/invocation/with_error_handling.rb +45 -0
- data/lib/cc/service/invocation/with_metrics.rb +37 -0
- data/lib/cc/service/invocation/with_retries.rb +17 -0
- data/lib/cc/service/invocation/with_return_values.rb +18 -0
- data/lib/cc/service/invocation.rb +57 -0
- data/lib/cc/service/response_check.rb +42 -0
- data/lib/cc/service.rb +127 -0
- data/lib/cc/services/asana.rb +90 -0
- data/lib/cc/services/campfire.rb +55 -0
- data/lib/cc/services/flowdock.rb +61 -0
- data/lib/cc/services/github_issues.rb +80 -0
- data/lib/cc/services/github_pull_requests.rb +210 -0
- data/lib/cc/services/hipchat.rb +57 -0
- data/lib/cc/services/jira.rb +93 -0
- data/lib/cc/services/lighthouse.rb +79 -0
- data/lib/cc/services/pivotal_tracker.rb +78 -0
- data/lib/cc/services/slack.rb +124 -0
- data/lib/cc/services/version.rb +5 -0
- data/lib/cc/services.rb +9 -0
- data/pull_request_test.rb +47 -0
- data/service_test.rb +86 -0
- data/test/asana_test.rb +85 -0
- data/test/axiom/types/password_test.rb +22 -0
- data/test/campfire_test.rb +144 -0
- data/test/fixtures.rb +68 -0
- data/test/flowdock_test.rb +148 -0
- data/test/formatters/snapshot_formatter_test.rb +47 -0
- data/test/github_issues_test.rb +96 -0
- data/test/github_pull_requests_test.rb +293 -0
- data/test/helper.rb +50 -0
- data/test/hipchat_test.rb +130 -0
- data/test/invocation_error_handling_test.rb +51 -0
- data/test/invocation_return_values_test.rb +21 -0
- data/test/invocation_test.rb +167 -0
- data/test/jira_test.rb +80 -0
- data/test/lighthouse_test.rb +74 -0
- data/test/pivotal_tracker_test.rb +73 -0
- data/test/presenters/github_pull_requests_presenter_test.rb +49 -0
- data/test/service_test.rb +63 -0
- data/test/slack_test.rb +222 -0
- data/test/support/fake_logger.rb +11 -0
- data/test/with_metrics_test.rb +19 -0
- metadata +263 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: be1d804a70349ad1e1b265055f2e2a72b5f9bc4b
|
4
|
+
data.tar.gz: 9a0c1811f8a1518d268fd25fdc6b703bbde5c552
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3aada36fb17278ee7093c5fc1e982150addf951d919539ed35a92332dda6888188f09e9e472331a6fb31914fa7cd0f9e0dce97b67393ae64346423cc61d455a9
|
7
|
+
data.tar.gz: f0ddd57b0da12d644aff62c076e9cf4ac0375589d4e8015b3bf2a031264697938bd160d520d8780b1b1ede11ab2684f53c786cdc87766958a26731b7ced701de
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p353
|
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
rvm:
|
4
|
+
- 1.9.3
|
5
|
+
- 2.0
|
6
|
+
- 2.1
|
7
|
+
- 2.2
|
8
|
+
sudo: false
|
9
|
+
env:
|
10
|
+
global:
|
11
|
+
- CODECLIMATE_REPO_TOKEN=5095391006b09e374e5d9232c41a09cfa6a3bdb1f9529c2485052416f743b4fe
|
12
|
+
notifications:
|
13
|
+
slack: codeclimate:XU4Q4aPrFuBk6n2kt8sy0DLb
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Bryan Helmkamp
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# Code Climate Services
|
2
|
+
|
3
|
+
[](https://codeclimate.com/github/codeclimate/codeclimate-services)
|
4
|
+
[](https://codeclimate.com/github/codeclimate/codeclimate-services)
|
5
|
+
|
6
|
+
A collection of classes, each responsible for integrating one external service
|
7
|
+
with the Code Climate system.
|
8
|
+
|
9
|
+
## Overview
|
10
|
+
|
11
|
+
Services define `#receive_<event>` methods for any events they are interested
|
12
|
+
in. These methods will be invoked with `@payload` set to a hash of data about
|
13
|
+
the event being handled.
|
14
|
+
|
15
|
+
The structure of this data is described below. Note that there may be additional
|
16
|
+
keys not listed here.
|
17
|
+
|
18
|
+
## Events
|
19
|
+
|
20
|
+
Attributes common to all event types:
|
21
|
+
|
22
|
+
```javascript
|
23
|
+
{
|
24
|
+
"repo_name": String,
|
25
|
+
"details_url": String
|
26
|
+
}
|
27
|
+
```
|
28
|
+
|
29
|
+
### Coverage
|
30
|
+
|
31
|
+
Event name: `coverage`
|
32
|
+
|
33
|
+
Event-specific attributes:
|
34
|
+
|
35
|
+
```javascript
|
36
|
+
{
|
37
|
+
"covered_percent": Float,
|
38
|
+
"previous_covered_percent": Float,
|
39
|
+
"covered_percent_delta": Float,
|
40
|
+
"compare_url": String
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
### Quality
|
45
|
+
|
46
|
+
Event name: `quality`
|
47
|
+
|
48
|
+
Event-specific attributes:
|
49
|
+
|
50
|
+
```javascript
|
51
|
+
{
|
52
|
+
"constant_name": String,
|
53
|
+
"rating": String, // "A", "B", "C", etc
|
54
|
+
"previous_rating": String,
|
55
|
+
"remediation_cost": Float,
|
56
|
+
"previous_remediation_cost": Float,
|
57
|
+
"compare_url": String
|
58
|
+
}
|
59
|
+
```
|
60
|
+
|
61
|
+
### Vulnerability
|
62
|
+
|
63
|
+
Event name: `vulnerability`
|
64
|
+
|
65
|
+
Event-specific attributes:
|
66
|
+
|
67
|
+
```javascript
|
68
|
+
{
|
69
|
+
"warning_type": String,
|
70
|
+
"vulnerabilities": [{
|
71
|
+
"warning_type": String,
|
72
|
+
"location": String
|
73
|
+
}, {
|
74
|
+
// ...
|
75
|
+
}]
|
76
|
+
}
|
77
|
+
```
|
78
|
+
|
79
|
+
*Note*: The reason for the top-level `warning_type` attribute is for when the
|
80
|
+
list of vulnerabilities are of mixed warning types. In this case, the top-level
|
81
|
+
attribute can be used in any messaging.
|
82
|
+
|
83
|
+
### Pull Request
|
84
|
+
|
85
|
+
Event name: `pull_request`
|
86
|
+
|
87
|
+
Event-specific attributes:
|
88
|
+
|
89
|
+
```javascript
|
90
|
+
{
|
91
|
+
"state": String, // "pending", or "success"
|
92
|
+
"github_slug": String, // user/repo
|
93
|
+
"number": String,
|
94
|
+
"commit_sha": String,
|
95
|
+
}
|
96
|
+
```
|
97
|
+
|
98
|
+
## Other Events
|
99
|
+
|
100
|
+
The following are not fully implemented yet.
|
101
|
+
|
102
|
+
* `snapshot`
|
103
|
+
|
104
|
+
## Contributing
|
105
|
+
|
106
|
+
To add a new integration, you'll need to create a new `Service` subclass. Please
|
107
|
+
use existing services as an example:
|
108
|
+
|
109
|
+
- Chat service examples: [hipchat](lib/cc/services/hipchat.rb), [campfire](lib/cc/services/campfire.rb)
|
110
|
+
- Issue tracker examples: [github_issues](lib/cc/services/github_issues.rb), [lighthouse](lib/cc/services/lighthouse.rb)
|
111
|
+
|
112
|
+
Ensure that your class implements `#receive_test`. It must handle any exceptions
|
113
|
+
and always return a hash of `{ ok: true|false, message: "String (HTML ok)" }`.
|
114
|
+
[Example](lib/cc/services/jira.rb#L31).
|
115
|
+
|
116
|
+
When you open your PR, please include an image for your service.
|
117
|
+
|
118
|
+
## License
|
119
|
+
|
120
|
+
See LICENSE.txt. This incorporates code from bugsnag-notification-plugins and
|
121
|
+
github-services, both MIT licensed.
|
data/Rakefile
ADDED
data/bin/bundler
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'bundler' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('codeclimate-services', 'bundler')
|
data/bin/coderay
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'coderay' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('coderay', 'coderay')
|
data/bin/nokogiri
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'nokogiri' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('nokogiri', 'nokogiri')
|
data/bin/pry
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'pry' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('pry', 'pry')
|
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('codeclimate-services', 'rake')
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cc/services/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "codeclimate-services"
|
8
|
+
spec.version = CC::Services::VERSION
|
9
|
+
spec.authors = ["Bryan Helmkamp"]
|
10
|
+
spec.email = ["bryan@brynary.com"]
|
11
|
+
spec.summary = %q{Service classes for Code Climate}
|
12
|
+
spec.description = %q{Service classes for Code Climate}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "faraday", "0.8.8"
|
21
|
+
spec.add_dependency "virtus", "1.0.0"
|
22
|
+
spec.add_dependency "nokogiri", "~> 1.6.0"
|
23
|
+
spec.add_dependency "activemodel", ">= 3.0"
|
24
|
+
spec.add_dependency "activesupport", ">= 3.0"
|
25
|
+
spec.add_development_dependency "bundler", ">= 1.6.2"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "test-unit"
|
28
|
+
spec.add_development_dependency "mocha"
|
29
|
+
end
|