Class: Octorule::Filters
- Inherits:
-
Object
- Object
- Octorule::Filters
- Defined in:
- lib/octorule/filters.rb
Instance Method Summary collapse
-
#initialize(client) ⇒ Filters
constructor
A new instance of Filters.
- #should_process?(repo, filters) ⇒ Boolean
Constructor Details
#initialize(client) ⇒ Filters
Returns a new instance of Filters.
5 6 7 |
# File 'lib/octorule/filters.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#should_process?(repo, filters) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/octorule/filters.rb', line 9 def should_process?(repo, filters) return true if filters.values.compact.empty? if repo[:archived] puts "Skipping #{repo[:name]} - repository is archived" return false end if filters[:name_pattern] pattern = Regexp.new(filters[:name_pattern]) unless pattern.match?(repo[:name]) puts "Skipping #{repo[:name]} - does not match name pattern #{filters[:name_pattern]}" return false end end if filters[:language] repo_language = repo[:language]&.downcase filter_language = filters[:language].downcase unless repo_language == filter_language puts "Skipping #{repo[:name]} - does not match language #{filters[:language]}" return false end end if filters[:label] labels = fetch_labels(repo[:owner][:login], repo[:name]) unless labels.include?(filters[:label]) puts "Skipping #{repo[:name]} - does not have label #{filters[:label]}" return false end end if !filters[:fork].nil? if filters[:fork] && !repo[:fork] puts "Skipping #{repo[:name]} - repository is not a fork" return false elsif !filters[:fork] && repo[:fork] puts "Skipping #{repo[:name]} - repository is a fork" return false end end true end |