owners 0.0.1 → 0.0.2

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
2
  SHA1:
3
- metadata.gz: 65952d9a4159c6a54c705d6a4d52a251a34eacb7
4
- data.tar.gz: d414a754b03b3549b017bbe3cff45ce511f69487
3
+ metadata.gz: d94ac158a395b3d6032f898cbd8bf71758cfe415
4
+ data.tar.gz: 1c2e72fe393c988b077028866b47c94f57804fc3
5
5
  SHA512:
6
- metadata.gz: 255d1ef9d4f7cf7c984d194e8224bc44c02ec72a26adaa2731955990d556bb111d306924675cd5b0a95cae364fb9738105474cc476774c93e675288a194bb719
7
- data.tar.gz: 64a897f374262fb422aef1ea8181ae28ac4c8181318fc05db1a41cee6015626b7c09a5b767bd7df89d1fe705c757eaf4989bceaca9f51d77cadcca7f2c92bb4e
6
+ metadata.gz: 79ca73ab78b0ab0503e2a78c17fb9d5a32607eef4c3cacfa33071669db8126f6f6a56c65b860610925812093e00fc31e2595b0755187db5b6650a7cd333fd92b
7
+ data.tar.gz: bca896ff7b7912e506e7460f5f530645e51d7c43eae4e418e66b3a0d1d1f9d39c94a922822bd60e36dd83d38e6faef6fdb2a607151161a2574b0acbc09582a36
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- owners (0.0.0)
4
+ owners (0.0.2)
5
+ thor
5
6
 
6
7
  GEM
7
8
  remote: https://www.rubygems.org/
@@ -29,6 +30,7 @@ GEM
29
30
  multi_json (~> 1.0)
30
31
  simplecov-html (~> 0.9.0)
31
32
  simplecov-html (0.9.0)
33
+ thor (0.19.1)
32
34
 
33
35
  PLATFORMS
34
36
  ruby
data/README.md CHANGED
@@ -4,6 +4,14 @@
4
4
 
5
5
  Take ownership of your code.
6
6
 
7
+ Knowing who owns a project or section of a code base is very helpful when asking questions or requesting feedback. This gem allows developers to define `OWNERS` files throughout their repository to provide a human and machine readable way to determine who the maintainers are for specific files of code.
8
+
9
+ These files can be used to:
10
+
11
+ * find the right people to ask when you have questions
12
+ * notify maintainers when changes occur in the files that they care about
13
+ * enforce approval from the appropriate people in pull requests
14
+
7
15
 
8
16
  ## Installation
9
17
 
@@ -26,7 +34,7 @@ jane@your-org.com
26
34
  #some_slack_channel
27
35
  ```
28
36
 
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.
37
+ The `OWNERS` file also supports limiting paths with regular expressions. Any whitespace that separates the subscriber from the path limiters is ignored.
30
38
 
31
39
  ```
32
40
  @data app/models/.*
@@ -34,14 +42,33 @@ The `OWNERS` file also supports limiting paths with regular expressions or exact
34
42
  bob@demo.com lib/bobs_special_file.rb
35
43
  ```
36
44
 
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`.
45
+ Find the owners for specific files by passing them to the `Owners.for` method.
38
46
 
39
47
  ```ruby
40
48
  Owners.for(".env", "app/controllers/posts_controller.rb", "app/models/user.rb")
41
49
  ```
42
50
 
51
+ This works well when comparing the files changed between `git` branches.
52
+
53
+ ```ruby
54
+ files = `git diff --name-only master`.split("\n")
55
+ Owners.for(*files)
56
+ ```
57
+
43
58
  This method returns a unique array of all the owners who have subscribed to changes for the specified files. These subscribers can then be notified however you see fit!
44
59
 
60
+
61
+ ## CLI
62
+
63
+ This gem also comes with a convenient `owners` command line interface. Each owner is printed out and separated by newlines.
64
+
65
+ ```bash
66
+ owners for .env app/controllers/posts_controller.rb app/models/user.rb
67
+ ```
68
+
69
+ See `owners help` for more information.
70
+
71
+
45
72
  ## API
46
73
 
47
74
  [YARD Documentation](http://www.rubydoc.info/github/shuber/owners)
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../lib/owners"
3
+ Owners::CLI.start
@@ -1,9 +1,11 @@
1
1
  require "pathname"
2
2
  require "set"
3
- require "owners/config"
4
- require "owners/search"
5
- require "owners/tree"
6
- require "owners/version"
3
+ require "thor"
4
+ require_relative "owners/cli"
5
+ require_relative "owners/config"
6
+ require_relative "owners/search"
7
+ require_relative "owners/tree"
8
+ require_relative "owners/version"
7
9
 
8
10
  module Owners
9
11
  class << self
@@ -0,0 +1,12 @@
1
+ module Owners
2
+ class CLI < Thor
3
+ desc "for [FILES...]", "List owners for a set of files"
4
+ method_option :file, desc: "The name of the OWNERS file"
5
+ def for(*files)
6
+ Owners.file = options[:file] if options[:file]
7
+ Owners.for(*files).each do |owner|
8
+ puts owner
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Owners
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -16,4 +16,5 @@ Gem::Specification.new do |s|
16
16
  s.version = Owners::VERSION
17
17
 
18
18
  s.add_development_dependency "rspec"
19
+ s.add_dependency "thor"
19
20
  end
@@ -0,0 +1,34 @@
1
+ RSpec.describe Owners::CLI do
2
+ describe "for" do
3
+ subject { capture { command } }
4
+ let(:command) { described_class.start(args) }
5
+ let(:args) { ["for", "example/app/controllers/users_controller.rb"] }
6
+
7
+ def capture
8
+ stdout = $stdout
9
+ $stdout = StringIO.new
10
+ yield
11
+ $stdout.string
12
+ ensure
13
+ $stdout = stdout
14
+ end
15
+
16
+ context "without a specified file" do
17
+ it "parses owners correctly" do
18
+ expect(subject).to eq("@org/auth\n@org/blog\n")
19
+ end
20
+ end
21
+
22
+ context "with a specified file" do
23
+ before { args << "--file" << "SOMETHING_ELSE" }
24
+
25
+ it "overrides the default OWNERS filename" do
26
+ begin
27
+ expect(subject).to eq("")
28
+ ensure
29
+ Owners.file = nil
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -21,6 +21,14 @@ RSpec.describe Owners do
21
21
  end
22
22
  end
23
23
 
24
+ context "with no paths" do
25
+ let(:paths) { [] }
26
+
27
+ it "parses owners correctly" do
28
+ expect(subject).to eq([])
29
+ end
30
+ end
31
+
24
32
  context "with no matches" do
25
33
  let(:paths) { ["some-path-without-owners"] }
26
34
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: owners
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Huber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-22 00:00:00.000000000 Z
11
+ date: 2015-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description:
28
42
  email: github@shuber.io
29
43
  executables: []
@@ -38,6 +52,7 @@ files:
38
52
  - Gemfile.lock
39
53
  - LICENSE
40
54
  - README.md
55
+ - bin/owners
41
56
  - example/OWNERS
42
57
  - example/app/OWNERS
43
58
  - example/app/controllers/posts_controller.rb
@@ -47,11 +62,13 @@ files:
47
62
  - example/app/models/post.rb
48
63
  - example/app/models/user.rb
49
64
  - lib/owners.rb
65
+ - lib/owners/cli.rb
50
66
  - lib/owners/config.rb
51
67
  - lib/owners/search.rb
52
68
  - lib/owners/tree.rb
53
69
  - lib/owners/version.rb
54
70
  - owners.gemspec
71
+ - spec/owners_cli_spec.rb
55
72
  - spec/owners_spec.rb
56
73
  - spec/spec_helper.rb
57
74
  homepage: https://github.com/shuber/owners
@@ -84,5 +101,6 @@ signing_key:
84
101
  specification_version: 4
85
102
  summary: Take ownership of your code
86
103
  test_files:
104
+ - spec/owners_cli_spec.rb
87
105
  - spec/owners_spec.rb
88
106
  - spec/spec_helper.rb