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.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +13 -0
  5. data/Gemfile +7 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +121 -0
  8. data/Rakefile +11 -0
  9. data/bin/bundler +16 -0
  10. data/bin/coderay +16 -0
  11. data/bin/nokogiri +16 -0
  12. data/bin/pry +16 -0
  13. data/bin/rake +16 -0
  14. data/codeclimate-services.gemspec +29 -0
  15. data/config/cacert.pem +4026 -0
  16. data/config/load.rb +4 -0
  17. data/lib/axiom/types/password.rb +7 -0
  18. data/lib/cc/formatters/linked_formatter.rb +60 -0
  19. data/lib/cc/formatters/plain_formatter.rb +36 -0
  20. data/lib/cc/formatters/snapshot_formatter.rb +101 -0
  21. data/lib/cc/formatters/ticket_formatter.rb +27 -0
  22. data/lib/cc/helpers/coverage_helper.rb +25 -0
  23. data/lib/cc/helpers/issue_helper.rb +9 -0
  24. data/lib/cc/helpers/quality_helper.rb +44 -0
  25. data/lib/cc/helpers/vulnerability_helper.rb +31 -0
  26. data/lib/cc/presenters/github_pull_requests_presenter.rb +54 -0
  27. data/lib/cc/service/config.rb +4 -0
  28. data/lib/cc/service/formatter.rb +34 -0
  29. data/lib/cc/service/helper.rb +54 -0
  30. data/lib/cc/service/http.rb +87 -0
  31. data/lib/cc/service/invocation/invocation_chain.rb +15 -0
  32. data/lib/cc/service/invocation/with_error_handling.rb +45 -0
  33. data/lib/cc/service/invocation/with_metrics.rb +37 -0
  34. data/lib/cc/service/invocation/with_retries.rb +17 -0
  35. data/lib/cc/service/invocation/with_return_values.rb +18 -0
  36. data/lib/cc/service/invocation.rb +57 -0
  37. data/lib/cc/service/response_check.rb +42 -0
  38. data/lib/cc/service.rb +127 -0
  39. data/lib/cc/services/asana.rb +90 -0
  40. data/lib/cc/services/campfire.rb +55 -0
  41. data/lib/cc/services/flowdock.rb +61 -0
  42. data/lib/cc/services/github_issues.rb +80 -0
  43. data/lib/cc/services/github_pull_requests.rb +210 -0
  44. data/lib/cc/services/hipchat.rb +57 -0
  45. data/lib/cc/services/jira.rb +93 -0
  46. data/lib/cc/services/lighthouse.rb +79 -0
  47. data/lib/cc/services/pivotal_tracker.rb +78 -0
  48. data/lib/cc/services/slack.rb +124 -0
  49. data/lib/cc/services/version.rb +5 -0
  50. data/lib/cc/services.rb +9 -0
  51. data/pull_request_test.rb +47 -0
  52. data/service_test.rb +86 -0
  53. data/test/asana_test.rb +85 -0
  54. data/test/axiom/types/password_test.rb +22 -0
  55. data/test/campfire_test.rb +144 -0
  56. data/test/fixtures.rb +68 -0
  57. data/test/flowdock_test.rb +148 -0
  58. data/test/formatters/snapshot_formatter_test.rb +47 -0
  59. data/test/github_issues_test.rb +96 -0
  60. data/test/github_pull_requests_test.rb +293 -0
  61. data/test/helper.rb +50 -0
  62. data/test/hipchat_test.rb +130 -0
  63. data/test/invocation_error_handling_test.rb +51 -0
  64. data/test/invocation_return_values_test.rb +21 -0
  65. data/test/invocation_test.rb +167 -0
  66. data/test/jira_test.rb +80 -0
  67. data/test/lighthouse_test.rb +74 -0
  68. data/test/pivotal_tracker_test.rb +73 -0
  69. data/test/presenters/github_pull_requests_presenter_test.rb +49 -0
  70. data/test/service_test.rb +63 -0
  71. data/test/slack_test.rb +222 -0
  72. data/test/support/fake_logger.rb +11 -0
  73. data/test/with_metrics_test.rb +19 -0
  74. 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
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
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
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in codeclimate-services.gemspec
4
+ gemspec
5
+
6
+ gem "pry"
7
+ gem "codeclimate-test-reporter"
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
+ [![Code Climate](https://codeclimate.com/github/codeclimate/codeclimate-services/badges/gpa.svg)](https://codeclimate.com/github/codeclimate/codeclimate-services)
4
+ [![Test Coverage](https://codeclimate.com/github/codeclimate/codeclimate-services/badges/coverage.svg)](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
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs.push "lib"
6
+ t.libs.push "test"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ t.verbose = true
9
+ end
10
+
11
+ task :default => :test
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