Class: Bundler::Stats::Skiplist
- Inherits:
-
Object
- Object
- Bundler::Stats::Skiplist
- Defined in:
- lib/bundler/stats/skiplist.rb
Instance Attribute Summary collapse
-
#regex_list ⇒ Object
readonly
Returns the value of attribute regex_list.
Instance Method Summary collapse
- #filter(gem_list) ⇒ Object
- #include?(target) ⇒ Boolean
-
#initialize(list = '') ⇒ Skiplist
constructor
A new instance of Skiplist.
Constructor Details
#initialize(list = '') ⇒ Skiplist
Returns a new instance of Skiplist.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bundler/stats/skiplist.rb', line 4 def initialize(list = '') @regex_list = if list.respond_to?(:regex_list) list.regex_list elsif list.respond_to?(:split) list .gsub(/\s+/, '') .split(",") .map { |str| glob_to_regex(str) } else (list || []).map { |str| glob_to_regex(str) } end end |
Instance Attribute Details
#regex_list ⇒ Object (readonly)
Returns the value of attribute regex_list.
2 3 4 |
# File 'lib/bundler/stats/skiplist.rb', line 2 def regex_list @regex_list end |
Instance Method Details
#filter(gem_list) ⇒ Object
17 18 19 |
# File 'lib/bundler/stats/skiplist.rb', line 17 def filter(gem_list) gem_list.reject { |gem| self.include?(gem) } end |
#include?(target) ⇒ Boolean
21 22 23 |
# File 'lib/bundler/stats/skiplist.rb', line 21 def include?(target) @regex_list.any? { |pattern| pattern =~ target.name } end |