owners 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ee93e4fe5cb329bf5df70608c572efa974963c4
4
- data.tar.gz: 578b7e1c7ece642fa707b8499756c1424e2e77b0
3
+ metadata.gz: 3b247236f150660b0597f6585ef18b9baaaf6d65
4
+ data.tar.gz: 1f4dec428c925c16a02e647748d34a60f99addb2
5
5
  SHA512:
6
- metadata.gz: 6f2c6ee735c8135a86454cf69e08888e18f102dfdc75546c64afcbc00caba068edf90d8e3a5c284378314b60bc0762c68d12ef9a7bf00deea1be24992954c780
7
- data.tar.gz: 6038c4e460cb1aa68ee140e6e464890fae548ea1e0c177ce9cda055826012da6fc002bf797d7a56385cdb65c9ae75be447d3c19da37c74f28e9faf06493ccd3a
6
+ metadata.gz: 28bf4ed8f9ad70007507faad897fd0e8a7af4e81d3a921ec1a039803521e449e5420a3e7d816018799b4867240312ab6e55b6906fb3a97c18352aa3cea838451
7
+ data.tar.gz: 3166205427b49ed54e99e302ac54f7707b189e25408f1750e4f8c83f7f3810a7740e35309e0f2f52310c23c3ef3511eff6bc55ebeb4353c177807085685355a4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- owners (0.1.0)
4
+ owners (0.1.1)
5
5
  thor
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -84,7 +84,7 @@ This returns an array of `Owner` objects which are simple wrappers around
84
84
  owners = Owners.for("db/schema.rb", ".env") #=> ["@data", "#internal"]
85
85
  ```
86
86
 
87
- The owner's `type` can be one of `%i(alert email group label mention path tag)`.
87
+ The owner's `type` can be one of `%i(alert email group label mention tag)`.
88
88
 
89
89
  ```ruby
90
90
  owners.first.type #=> :mention
@@ -14,12 +14,7 @@ module Owners
14
14
 
15
15
  desc "for [FILES...]", "List owners for a set of files"
16
16
  def for(*files)
17
- files = stdin_files unless files.any?
18
-
19
- Owners.file = options[:file] if options[:file]
20
- Owners.for(*files).each do |owner|
21
- output(owner)
22
- end
17
+ run(:for, files)
23
18
  end
24
19
 
25
20
  desc "for_diff REF [BASE_REF]", "List owners for a set of git changes"
@@ -32,12 +27,7 @@ module Owners
32
27
 
33
28
  desc "missing_for [FILES...]", "List files that don't have owners"
34
29
  def missing_for(*files)
35
- files = stdin_files unless files.any?
36
-
37
- Owners.file = options[:file] if options[:file]
38
- Owners.missing_for(*files).each do |owner|
39
- output(owner)
40
- end
30
+ run(:missing_for, files)
41
31
  end
42
32
 
43
33
  no_commands do
@@ -45,16 +35,31 @@ module Owners
45
35
  say owner
46
36
 
47
37
  if options[:debug]
48
- say owner.type, :yellow
38
+ last_sub = nil
49
39
 
50
40
  owner.subscriptions.each do |path, subscriptions|
51
41
  subscriptions.each do |sub|
52
- say " #{path}", :red
53
- say " #{sub.file}:#{sub.line} => #{sub.filter}", :blue
54
- end
42
+ if last_sub != sub
43
+ say if last_sub
44
+ say " #{sub}", :blue
45
+ end
55
46
 
56
- say
47
+ say " #{path}", :red unless path == sub.source
48
+ last_sub = sub
49
+ end
57
50
  end
51
+
52
+ say
53
+ end
54
+ end
55
+
56
+ def run(method, files)
57
+ files = stdin_files unless files.any?
58
+
59
+ Owners.file = options[:file] if options[:file]
60
+
61
+ Owners.send(method, *files).each do |owner|
62
+ output(owner)
58
63
  end
59
64
  end
60
65
 
@@ -26,8 +26,6 @@ module Owners
26
26
  :mention
27
27
  when /^#/
28
28
  :tag
29
- when /\//
30
- :path
31
29
  else
32
30
  :label
33
31
  end
@@ -7,6 +7,8 @@ module Owners
7
7
  #
8
8
  # @api public
9
9
  class Subscription
10
+ include Comparable
11
+
10
12
  COMMENT = /^\s*\/\//
11
13
  WILDCARD = /.*/
12
14
 
@@ -20,14 +22,26 @@ module Owners
20
22
  @root = config.root
21
23
  end
22
24
 
25
+ def <=>(other)
26
+ location <=> other.location
27
+ end
28
+
23
29
  def filter
24
30
  Regexp.new(@filter || WILDCARD)
25
31
  end
26
32
 
33
+ def location
34
+ [file, line].join(":")
35
+ end
36
+
27
37
  def metadata?
28
38
  comment? || empty?
29
39
  end
30
40
 
41
+ def source
42
+ filter.source
43
+ end
44
+
31
45
  def subscribed?(path)
32
46
  path =~ prefix && relative(path) =~ filter
33
47
  end
@@ -36,6 +50,10 @@ module Owners
36
50
  @subscribers.split(",").reject(&:empty?)
37
51
  end
38
52
 
53
+ def to_s
54
+ [source, location].join(" ")
55
+ end
56
+
39
57
  private
40
58
 
41
59
  def comment?
@@ -1,3 +1,3 @@
1
1
  module Owners
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -60,7 +60,7 @@ RSpec.describe Owners::Owner do
60
60
  let(:owner) { "/one/two" }
61
61
 
62
62
  it "parses type correctly" do
63
- expect(subject).to eq(:path)
63
+ expect(subject).to eq(:label)
64
64
  end
65
65
  end
66
66
 
@@ -42,14 +42,12 @@ RSpec.describe Owners::CLI do
42
42
  it "parses owners correctly" do
43
43
  expected = <<-OUTPUT
44
44
  @org/auth
45
- group
46
- example/app/controllers/users_controller.rb
47
- example/app/OWNERS:1 => (?-mix:user)
45
+ user example/app/OWNERS:1
46
+ example/app/controllers/users_controller.rb
48
47
 
49
48
  @org/blog
50
- group
51
- example/app/controllers/users_controller.rb
52
- example/OWNERS:2 => (?-mix:.*)
49
+ .* example/OWNERS:2
50
+ example/app/controllers/users_controller.rb
53
51
 
54
52
  OUTPUT
55
53
 
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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Huber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-04 00:00:00.000000000 Z
11
+ date: 2016-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec