Module: Jekyll::Tasks::Related

Extended by:
Related
Included in:
Related
Defined in:
lib/jekyll/tasks/related.rb

Overview

Verify related API

Constant Summary collapse

5

Instance Method Summary collapse

Instance Method Details



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jekyll/tasks/related.rb', line 11

def all_products_with_related(api = api_data)
  errors = []
  Products.model_list.each do |product|
    if api[product]
      count = api[product].count
      errors << "Only has #{count} related products: #{product}" if count < MINIMUM_RELATED_PRODUCTS
    else
      errors << "Doesn't have related products: #{product}"
    end
  end
  errors.empty? ? 'OK' : errors
end


24
25
26
27
28
29
30
31
32
33
# File 'lib/jekyll/tasks/related.rb', line 24

def all_related_exist
  errors = []
  models = Products.model_list
  api_data.each do |key, related|
    next unless models.include? key

    errors += related_rules(key, related)
  end
  errors.empty? ? 'OK' : errors
end