Class: Bundler::Stats::Skiplist

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/stats/skiplist.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_listObject (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

Returns:

  • (Boolean)


21
22
23
# File 'lib/bundler/stats/skiplist.rb', line 21

def include?(target)
  @regex_list.any? { |pattern| pattern =~ target.name }
end