owners 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 03249f63f81c9db5877a0f55d0562c78e725afc6
4
+ data.tar.gz: 4cc529092d6d620a6cc1c652c819f9d7b63d662f
5
+ SHA512:
6
+ metadata.gz: ff1c532d637a42f59b985764d90f686629ac3be3fefc8bca062eda6be54f141ca599f86c88aedc6b6e22d5ff940b9a6e20c7ac236bbfc3015150a3a2d50123e7
7
+ data.tar.gz: c6fe901e8fe7467cb8eda35f12d6d2d468e4c0b8a2999c935d8e092c57de18339926834202490fa6f2e191bdf1791a40b7a7e243caf6a953c57b812653b7e525
@@ -0,0 +1,2 @@
1
+ pkg
2
+ rdoc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://www.rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'codeclimate-test-reporter'
@@ -0,0 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ owners (0.0.0)
5
+
6
+ GEM
7
+ remote: https://www.rubygems.org/
8
+ specs:
9
+ codeclimate-test-reporter (0.4.7)
10
+ simplecov (>= 0.7.1, < 1.0.0)
11
+ diff-lcs (1.2.5)
12
+ docile (1.1.5)
13
+ multi_json (1.11.0)
14
+ rspec (3.2.0)
15
+ rspec-core (~> 3.2.0)
16
+ rspec-expectations (~> 3.2.0)
17
+ rspec-mocks (~> 3.2.0)
18
+ rspec-core (3.2.2)
19
+ rspec-support (~> 3.2.0)
20
+ rspec-expectations (3.2.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.2.0)
23
+ rspec-mocks (3.2.1)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.2.0)
26
+ rspec-support (3.2.2)
27
+ simplecov (0.9.2)
28
+ docile (~> 1.1.0)
29
+ multi_json (~> 1.0)
30
+ simplecov-html (~> 0.9.0)
31
+ simplecov-html (0.9.0)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ codeclimate-test-reporter
38
+ owners!
39
+ rspec
40
+
41
+ BUNDLED WITH
42
+ 1.10.6
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Sean Huber - github@shuber.io
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,70 @@
1
+ # [![Sean Huber](https://cloud.githubusercontent.com/assets/2419/6550752/832d9a64-c5ea-11e4-9717-6f9aa6e023b5.png)](https://github.com/shuber) owners
2
+
3
+ [![Build Status](https://secure.travis-ci.org/shuber/owners.svg)](http://travis-ci.org/shuber/owners) [![Code Climate](https://codeclimate.com/github/shuber/owners/badges/gpa.svg)](https://codeclimate.com/github/shuber/owners) [![Coverage](https://codeclimate.com/github/shuber/owners/badges/coverage.svg)](https://codeclimate.com/github/shuber/owners) [![Gem Version](https://badge.fury.io/rb/owners.svg)](http://badge.fury.io/rb/owners)
4
+
5
+ Take ownership of your code
6
+
7
+
8
+ ## Installation
9
+
10
+ ```
11
+ gem install owners
12
+ ```
13
+
14
+
15
+ ## Usage
16
+
17
+ Define an `OWNERS` file in any directory within your repository. This file should contain a newline separated list of subscribers to notify when files within the directory have changed. The `OWNERS` files are searched recursively up the tree to make organizing owners more convenient.
18
+
19
+ Subscribers can be anything that suits your needs e.g. emails, GitHub handles, or Slack channels.
20
+
21
+ ```
22
+ bob@your-org.com
23
+ jane@your-org.com
24
+ @some_github_handle
25
+ @your_github_org/group
26
+ #some_slack_channel
27
+ ```
28
+
29
+ The `OWNERS` file also supports limiting paths with regular expressions or exact matches. Any whitespace that separates the subscriber from the path limiters are ignored.
30
+
31
+ ```
32
+ @data app/models/.*
33
+ @ui \.(css|haml|js|scss)$
34
+ bob@demo.com lib/bobs_special_file.rb
35
+ ```
36
+
37
+ Once your `OWNERS` files are defined, you can search for a list of owners by calling `Owners.for` with a list of paths e.g. output from `git diff --name-only`
38
+
39
+ ```ruby
40
+ Owners.for(".env", "app/controllers/posts_controller.rb", "app/models/user.rb")
41
+ ```
42
+
43
+ This method returns a unique array of all the owners who have subscribed to changes for the specified files.
44
+
45
+ ## API
46
+
47
+ [YARD Documentation](http://www.rubydoc.info/github/shuber/owners)
48
+
49
+ * `Owners.for`
50
+
51
+
52
+ ## Testing
53
+
54
+ ```
55
+ bundle exec rspec
56
+ ```
57
+
58
+
59
+ ## Contributing
60
+
61
+ * Fork the project.
62
+ * Make your feature addition or bug fix.
63
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
64
+ * Commit, do not mess with the version or history.
65
+ * Send me a pull request. Bonus points for topic branches.
66
+
67
+
68
+ ## License
69
+
70
+ [MIT](https://github.com/shuber/owners/blob/master/LICENSE) - Copyright © 2015 Sean Huber
@@ -0,0 +1 @@
1
+ @org/blog
@@ -0,0 +1 @@
1
+ @org/auth user
@@ -0,0 +1,3 @@
1
+ data@example.com
2
+ @blogger ^blog\.rb$
3
+ @whitespace post.rb
File without changes
File without changes
File without changes
@@ -0,0 +1,10 @@
1
+ require 'owners/config'
2
+ require 'owners/path'
3
+ require 'owners/search'
4
+ require 'owners/version'
5
+
6
+ module Owners
7
+ def self.for(*paths)
8
+ Search.new(paths).owners
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ module Owners
2
+ class Config
3
+ attr_reader :root
4
+
5
+ def initialize(file)
6
+ @config = File.read(file)
7
+ @root = File.dirname(file)
8
+ end
9
+
10
+ def owners
11
+ subscriptions.each_with_object({}) do |line, hash|
12
+ owner, path = line.split(/\s+/, 2).push('.*')
13
+ hash[owner] ||= []
14
+ hash[owner] << Regexp.new(path)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def subscriptions
21
+ @config.split("\n").reject(&:empty?)
22
+ end
23
+ end
24
+ end
File without changes
@@ -0,0 +1,41 @@
1
+ module Owners
2
+ class Path
3
+ CONFIG = 'OWNERS'
4
+
5
+ def initialize(file)
6
+ @file = file
7
+ end
8
+
9
+ def owners
10
+ configs.each_with_object([]) do |config, owners|
11
+ path = @file.sub("#{config.root}/", '')
12
+
13
+ config.owners.each do |owner, regexes|
14
+ regexes.each do |regex|
15
+ if path =~ regex
16
+ owners << owner
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def configs
26
+ configs = []
27
+ file = @file
28
+
29
+ until ['.', '/'].include?(file)
30
+ file = File.dirname(file)
31
+ config = File.join(file, CONFIG)
32
+
33
+ if File.exists?(config) && !File.directory?(config)
34
+ configs << Config.new(config)
35
+ end
36
+ end
37
+
38
+ configs
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ module Owners
2
+ class Search
3
+ def initialize(paths)
4
+ @paths = paths
5
+ end
6
+
7
+ def owners
8
+ paths.flat_map(&:owners).flatten.uniq.sort
9
+ end
10
+
11
+ private
12
+
13
+ def paths
14
+ @paths.map { |path| Path.new(path) }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Owners
2
+ VERSION = '0.0.0'
3
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path('../lib/owners/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.author = 'Sean Huber'
5
+ s.email = 'github@shuber.io'
6
+ s.extra_rdoc_files = %w(LICENSE)
7
+ s.files = `git ls-files`.split("\n")
8
+ s.homepage = 'https://github.com/shuber/owners'
9
+ s.license = 'MIT'
10
+ s.name = 'owners'
11
+ s.rdoc_options = %w(--charset=UTF-8 --inline-source --line-numbers --main README.md)
12
+ s.require_paths = %w(lib)
13
+ s.required_ruby_version = '>= 2.0.0'
14
+ s.summary = 'Take ownership of your code'
15
+ s.test_files = `git ls-files -- spec/*`.split("\n")
16
+ s.version = Owners::VERSION
17
+
18
+ s.add_development_dependency 'rspec'
19
+ end
@@ -0,0 +1,48 @@
1
+ RSpec.describe Owners do
2
+ describe '.for' do
3
+ subject { described_class.for(*paths) }
4
+
5
+ context 'with one path' do
6
+ let(:paths) { ['example/app/controllers/users_controller.rb'] }
7
+
8
+ it 'parses owners correctly' do
9
+ expect(subject).to eq(['@org/auth', '@org/blog'])
10
+ end
11
+ end
12
+
13
+ context 'with multiple paths' do
14
+ let(:paths) {[
15
+ 'example/app/controllers/posts_controller.rb',
16
+ 'example/app/models/user.rb',
17
+ ]}
18
+
19
+ it 'parses owners correctly' do
20
+ expect(subject).to eq(['@org/auth', '@org/blog', 'data@example.com'])
21
+ end
22
+ end
23
+
24
+ context 'with no matches' do
25
+ let(:paths) { ['some-path-without-owners'] }
26
+
27
+ it 'parses owners correctly' do
28
+ expect(subject).to be_empty
29
+ end
30
+ end
31
+
32
+ context 'with a regex matcher' do
33
+ let(:paths) { ['example/app/models/blog.rb'] }
34
+
35
+ it 'parses owners correctly' do
36
+ expect(subject).to eq(['@blogger', '@org/blog', 'data@example.com'])
37
+ end
38
+ end
39
+
40
+ context 'with a rule containing whitespace' do
41
+ let(:paths) { ['example/app/models/post.rb'] }
42
+
43
+ it 'parses owners correctly' do
44
+ expect(subject).to eq(['@org/blog', '@whitespace', 'data@example.com'])
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,15 @@
1
+ if ENV['CODECLIMATE_REPO_TOKEN']
2
+ require 'codeclimate-test-reporter'
3
+ CodeClimate::TestReporter.start
4
+ else
5
+ require 'simplecov'
6
+ SimpleCov.start { add_filter('/vendor/bundle/') }
7
+ end
8
+
9
+ require File.expand_path('../../lib/owners', __FILE__)
10
+
11
+ RSpec.configure do |config|
12
+ config.filter_run :focus
13
+ config.raise_errors_for_deprecations!
14
+ config.run_all_when_everything_filtered = true
15
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: owners
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sean Huber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email: github@shuber.io
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - LICENSE
39
+ - README.md
40
+ - example/OWNERS
41
+ - example/app/OWNERS
42
+ - example/app/controllers/posts_controller.rb
43
+ - example/app/controllers/users_controller.rb
44
+ - example/app/models/OWNERS
45
+ - example/app/models/blog.rb
46
+ - example/app/models/post.rb
47
+ - example/app/models/user.rb
48
+ - lib/owners.rb
49
+ - lib/owners/config.rb
50
+ - lib/owners/core_ext
51
+ - lib/owners/path.rb
52
+ - lib/owners/search.rb
53
+ - lib/owners/version.rb
54
+ - owners.gemspec
55
+ - spec/owners_spec.rb
56
+ - spec/spec_helper.rb
57
+ homepage: https://github.com/shuber/owners
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options:
63
+ - "--charset=UTF-8"
64
+ - "--inline-source"
65
+ - "--line-numbers"
66
+ - "--main"
67
+ - README.md
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.0.0
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.5.1
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Take ownership of your code
86
+ test_files:
87
+ - spec/owners_spec.rb
88
+ - spec/spec_helper.rb