ownership 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +24 -1
- data/lib/ownership.rb +2 -1
- data/lib/ownership/global_methods.rb +8 -1
- data/lib/ownership/honeybadger.rb +47 -0
- data/lib/ownership/version.rb +1 -1
- metadata +39 -14
- data/.gitignore +0 -9
- data/Gemfile +0 -4
- data/Rakefile +0 -11
- data/ownership.gemspec +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8c4fe00bb65d52534a1f5483498c2e6ce1dfed27d335d013ed6bf50243e5aaed
|
4
|
+
data.tar.gz: 60b13c25af7be0d4ca8bc8dc0020e2920dbda2ad29a1feb9c4149096024ba56e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cef2c500453b391e10bbda547343ff0dc6a5dfdbf6c2d28e83b1695182db9d6372bd26c820f364e483ef3a56d54183557dccb30097b1097131ebd2657bc83c7
|
7
|
+
data.tar.gz: aec462d513f26d8adc0e04e44888aba368ab7d0f410e593869336766db83ad90a934c8816a8e38d6911f09a6c9db1d2f673a94859db224ac5a664cd75ee8a18a
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2017-2019 Andrew Kane
|
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
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Ownership
|
2
2
|
|
3
|
-
Code ownership for
|
3
|
+
Code ownership for Rails
|
4
4
|
|
5
5
|
:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
|
6
6
|
|
@@ -63,6 +63,29 @@ Ownership.default_owner = :logistics
|
|
63
63
|
|
64
64
|
There are a few built-in integrations with other gems.
|
65
65
|
|
66
|
+
- [Honeybadger](#honeybadger)
|
67
|
+
- [Marginalia](#marginalia)
|
68
|
+
- [Rollbar](#rollbar)
|
69
|
+
|
70
|
+
You can also add [custom integrations](#custom-integrations).
|
71
|
+
|
72
|
+
### Honeybadger
|
73
|
+
|
74
|
+
[Honeybadger](https://github.com/honeybadger-io/honeybadger-ruby) tracks exceptions. This integration makes it easy to send exceptions to different projects based on the owner. We recommend having a project for each team.
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
Ownership::Honeybadger.api_keys = {
|
78
|
+
logistics: "token1",
|
79
|
+
customers: "token2"
|
80
|
+
}
|
81
|
+
```
|
82
|
+
|
83
|
+
Also works with a proc
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
Ownership::Honeybadger.api_keys = -> (owner) { ENV["#{owner.to_s.upcase}_HONEYBADGER_API_KEY"] }
|
87
|
+
```
|
88
|
+
|
66
89
|
### Marginalia
|
67
90
|
|
68
91
|
[Marginalia](https://github.com/basecamp/marginalia) adds comments to ActiveRecord queries. If installed, the owner is added.
|
data/lib/ownership.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "ownership/global_methods"
|
2
|
+
require "ownership/honeybadger"
|
2
3
|
require "ownership/rollbar"
|
3
4
|
require "ownership/version"
|
4
5
|
|
@@ -13,7 +14,7 @@ module Ownership
|
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
|
-
Object.
|
17
|
+
Object.include Ownership::GlobalMethods
|
17
18
|
|
18
19
|
if defined?(ActiveSupport)
|
19
20
|
ActiveSupport.on_load(:action_controller) do
|
@@ -1,6 +1,13 @@
|
|
1
1
|
module Ownership
|
2
2
|
module GlobalMethods
|
3
|
-
|
3
|
+
private
|
4
|
+
|
5
|
+
def owner(*args, &block)
|
6
|
+
return super if is_a?(Method) # hack for pry
|
7
|
+
|
8
|
+
owner = args[0]
|
9
|
+
# same error message as Ruby
|
10
|
+
raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 1)" if args.size != 1
|
4
11
|
raise ArgumentError, "Missing block" unless block_given?
|
5
12
|
|
6
13
|
previous_value = Thread.current[:ownership_owner]
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Ownership
|
2
|
+
module Honeybadger
|
3
|
+
class << self
|
4
|
+
attr_reader :api_keys
|
5
|
+
|
6
|
+
def api_keys=(api_keys)
|
7
|
+
@api_keys = api_keys
|
8
|
+
@configuration ||= configure
|
9
|
+
api_keys
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def add_owner_as_tag(notice, current_owner)
|
15
|
+
return unless current_owner
|
16
|
+
|
17
|
+
notice.tags << current_owner.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure
|
21
|
+
::Honeybadger.configure do |config|
|
22
|
+
config.before_notify do |notice|
|
23
|
+
current_owner = notice.exception.owner if notice.exception.is_a?(Exception)
|
24
|
+
current_owner ||= Ownership.owner
|
25
|
+
|
26
|
+
add_owner_as_tag(notice, current_owner)
|
27
|
+
use_owner_api_key(notice, current_owner)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def owner_api_key(current_owner)
|
33
|
+
api_keys.respond_to?(:call) ? api_keys.call(current_owner) : api_keys[current_owner]
|
34
|
+
end
|
35
|
+
|
36
|
+
def use_owner_api_key(notice, current_owner)
|
37
|
+
return unless current_owner
|
38
|
+
|
39
|
+
if (api_key = owner_api_key(current_owner))
|
40
|
+
notice.api_key = api_key
|
41
|
+
else
|
42
|
+
warn "[ownership] Missing Honeybadger API key for owner: #{current_owner}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/ownership/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ownership
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,28 +80,54 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: honeybadger
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
description:
|
84
|
-
email:
|
85
|
-
- andrew@chartkick.com
|
112
|
+
email: andrew@chartkick.com
|
86
113
|
executables: []
|
87
114
|
extensions: []
|
88
115
|
extra_rdoc_files: []
|
89
116
|
files:
|
90
|
-
- ".gitignore"
|
91
117
|
- CHANGELOG.md
|
92
|
-
-
|
118
|
+
- LICENSE.txt
|
93
119
|
- README.md
|
94
|
-
- Rakefile
|
95
120
|
- lib/ownership.rb
|
96
121
|
- lib/ownership/controller_methods.rb
|
97
122
|
- lib/ownership/global_methods.rb
|
123
|
+
- lib/ownership/honeybadger.rb
|
98
124
|
- lib/ownership/job_methods.rb
|
99
125
|
- lib/ownership/marginalia.rb
|
100
126
|
- lib/ownership/rollbar.rb
|
101
127
|
- lib/ownership/version.rb
|
102
|
-
- ownership.gemspec
|
103
128
|
homepage: https://github.com/ankane/ownership
|
104
|
-
licenses:
|
129
|
+
licenses:
|
130
|
+
- MIT
|
105
131
|
metadata: {}
|
106
132
|
post_install_message:
|
107
133
|
rdoc_options: []
|
@@ -111,16 +137,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
137
|
requirements:
|
112
138
|
- - ">="
|
113
139
|
- !ruby/object:Gem::Version
|
114
|
-
version: '
|
140
|
+
version: '2.4'
|
115
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
142
|
requirements:
|
117
143
|
- - ">="
|
118
144
|
- !ruby/object:Gem::Version
|
119
145
|
version: '0'
|
120
146
|
requirements: []
|
121
|
-
|
122
|
-
rubygems_version: 2.6.13
|
147
|
+
rubygems_version: 3.0.3
|
123
148
|
signing_key:
|
124
149
|
specification_version: 4
|
125
|
-
summary: Code ownership for
|
150
|
+
summary: Code ownership for Rails
|
126
151
|
test_files: []
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/ownership.gemspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "ownership/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "ownership"
|
8
|
-
spec.version = Ownership::VERSION
|
9
|
-
spec.authors = ["Andrew Kane"]
|
10
|
-
spec.email = ["andrew@chartkick.com"]
|
11
|
-
|
12
|
-
spec.summary = "Code ownership for your Rails app"
|
13
|
-
spec.homepage = "https://github.com/ankane/ownership"
|
14
|
-
|
15
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
-
f.match(%r{^(test|spec|features)/})
|
17
|
-
end
|
18
|
-
spec.bindir = "exe"
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = ["lib"]
|
21
|
-
|
22
|
-
spec.add_development_dependency "bundler"
|
23
|
-
spec.add_development_dependency "rake"
|
24
|
-
spec.add_development_dependency "minitest"
|
25
|
-
spec.add_development_dependency "activejob"
|
26
|
-
spec.add_development_dependency "marginalia"
|
27
|
-
end
|