ownership 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 38e0f9794b246e9f4d788f460db5aeb663f6f45e
4
- data.tar.gz: a7d3477d27cbd3aa0cddd55269246922d198a919
2
+ SHA256:
3
+ metadata.gz: 8c4fe00bb65d52534a1f5483498c2e6ce1dfed27d335d013ed6bf50243e5aaed
4
+ data.tar.gz: 60b13c25af7be0d4ca8bc8dc0020e2920dbda2ad29a1feb9c4149096024ba56e
5
5
  SHA512:
6
- metadata.gz: c57c183a32991967c30aba4a926d4c1ef2076b8100d4ae7aa09e32e3ea395214fe3d833209263fd399547105c3ab9484676eeba0f9ee5577889f1b60524b6146
7
- data.tar.gz: d3df7b1a97faacd87fb05248001358244466c656a2fc9fa2fb2638a670729f9cd60ac42468d207afe1f0c68f6ff9471bec0bb992559056bb1ee787ac9999218d
6
+ metadata.gz: 5cef2c500453b391e10bbda547343ff0dc6a5dfdbf6c2d28e83b1695182db9d6372bd26c820f364e483ef3a56d54183557dccb30097b1097131ebd2657bc83c7
7
+ data.tar.gz: aec462d513f26d8adc0e04e44888aba368ab7d0f410e593869336766db83ad90a934c8816a8e38d6911f09a6c9db1d2f673a94859db224ac5a664cd75ee8a18a
@@ -1,3 +1,9 @@
1
+ ## 0.1.1
2
+
3
+ - Added Honeybadger integration
4
+ - Made `owner` method private to behave like `Kernel` methods
5
+ - Fixed conflict with Pry
6
+
1
7
  ## 0.1.0
2
8
 
3
9
  - First release
@@ -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 your Rails app
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.
@@ -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.send :include, Ownership::GlobalMethods
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
- def owner(owner, &block)
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
@@ -1,3 +1,3 @@
1
1
  module Ownership
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-06 00:00:00.000000000 Z
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
- - Gemfile
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: '0'
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
- rubyforge_project:
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 your Rails app
150
+ summary: Code ownership for Rails
126
151
  test_files: []
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- *.lock
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in ownership.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,11 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- t.warning = false
9
- end
10
-
11
- task default: :test
@@ -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