class GitHooks::Repository::Limiter
Attributes
only[R]
to[R]
type[R]
Public Class Methods
new(type)
click to toggle source
# File lib/githooks/repository/limiter.rb, line 24 def initialize(type) @type = type @only = nil @inverted = false end
Public Instance Methods
except(*args)
click to toggle source
# File lib/githooks/repository/limiter.rb, line 44 def except(*args) only(*args).tap { invert! } end
limit(files)
click to toggle source
# File lib/githooks/repository/limiter.rb, line 48 def limit(files) files.select! do |file| match_file(file).tap do |result| if GitHooks.debug? result = (result ? 'success' : 'failure') STDERR.puts " #{file.path} (#{file.attribute_value(@type).inspect}) was a #{result}" end end end end
Private Instance Methods
invert!()
click to toggle source
# File lib/githooks/repository/limiter.rb, line 61 def invert! @inverted = true end
match_file(file)
click to toggle source
# File lib/githooks/repository/limiter.rb, line 65 def match_file(file) if @inverted Array(@only).none? { |value| file.match(@type, value) } else Array(@only).any? { |value| file.match(@type, value) } end end