Class: GitHooks::Repository::Limiter
- Defined in:
- lib/githooks/repository/limiter.rb
Instance Attribute Summary collapse
-
#only(*args) ⇒ Object
(also: #to)
readonly
Returns the value of attribute only.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, options = {}) ⇒ Limiter
constructor
A new instance of Limiter.
- #inverted ⇒ Object (also: #invert)
- #limit(files) ⇒ Object
Constructor Details
#initialize(type, options = {}) ⇒ Limiter
Returns a new instance of Limiter.
24 25 26 27 28 |
# File 'lib/githooks/repository/limiter.rb', line 24 def initialize(type, = {}) @type = type @only = .delete(:only) || .delete(:to) @inverted = false end |
Instance Attribute Details
#only(*args) ⇒ Object (readonly) Also known as: to
Returns the value of attribute only.
22 23 24 |
# File 'lib/githooks/repository/limiter.rb', line 22 def only @only end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
22 23 24 |
# File 'lib/githooks/repository/limiter.rb', line 22 def type @type end |
Instance Method Details
#inverted ⇒ Object Also known as: invert
37 38 39 |
# File 'lib/githooks/repository/limiter.rb', line 37 def inverted @inverted = true end |
#limit(files) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/githooks/repository/limiter.rb', line 42 def limit(files) files.select! do |file| match_file(file, @only).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 |