Class: Codeowners::ListOwners
- Inherits:
-
Object
- Object
- Codeowners::ListOwners
- Defined in:
- lib/codeowners/list_owners.rb
Instance Method Summary collapse
- #call(file) ⇒ Object
-
#initialize(base_directory, codeowners) ⇒ ListOwners
constructor
A new instance of ListOwners.
Constructor Details
#initialize(base_directory, codeowners) ⇒ ListOwners
Returns a new instance of ListOwners.
8 9 10 11 |
# File 'lib/codeowners/list_owners.rb', line 8 def initialize(base_directory, codeowners) @base_directory = Pathname.new(::File.(base_directory)) @codeowners = @base_directory.join(codeowners) end |
Instance Method Details
#call(file) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/codeowners/list_owners.rb', line 13 def call(file) result = Result.new ::File.open(@codeowners, "r").each_line do |line| line = line.chomp next if line.empty? || line.match?(/[[:space:]]*#/) pattern, *owners = line.split(/[[:space:]]+/) result = Result.new(pattern, owners) if match?(pattern, file) end result end |