module Customers

Customers module to configure jekyll's bundle per website

Constants

JEKYLL_CONFIG

Public Instance Methods

activate() click to toggle source
# File lib/jekyll_theme_marketing/customers.rb, line 12
def activate
  delete_default_config
  activate_customers_config(customer_config_path)
end
customers_domains() click to toggle source
# File lib/jekyll_theme_marketing/customers.rb, line 26
def customers_domains
  domains = []
  customers_list.each do |customer|
    domain = customer
             .gsub('./_data/customers/', '')
             .gsub('.yml', '')
    domains << domain
  end
  domains
end
customers_list() click to toggle source
# File lib/jekyll_theme_marketing/customers.rb, line 37
def customers_list
  Dir.glob('./_data/customers/*.yml').to_a.sort
end
deploy_date(customer) click to toggle source
# File lib/jekyll_theme_marketing/customers.rb, line 41
def deploy_date(customer)
  page = Nokogiri::HTML(open("https://www.#{customer}"))
  last_deploy = page.css('img[data-last-deploy]')[0]
  last_deploy.nil? ? '' : last_deploy['data-last-deploy'].gsub(/ -0.00/, '')
end
show_last_deploys_dates() click to toggle source
# File lib/jekyll_theme_marketing/customers.rb, line 17
def show_last_deploys_dates
  last_deploys_dates = []
  customers_domains.each do |customer|
    puts "Testing #{customer}"
    last_deploys_dates << "#{deploy_date(customer)}: #{customer}"
  end
  puts last_deploys_dates.sort.reverse
end

Private Instance Methods

activate_customers_config(path) click to toggle source
# File lib/jekyll_theme_marketing/customers.rb, line 58
def activate_customers_config(path)
  File.rename(path, JEKYLL_CONFIG)
  puts "#{Time.now} | Actived customers config at #{path}"
end
customer_config_path() click to toggle source
# File lib/jekyll_theme_marketing/customers.rb, line 49
def customer_config_path
  customer_index = Dates.working_days_in_year % customers_list.count
  customers_list[customer_index - 1]
end
delete_default_config() click to toggle source
# File lib/jekyll_theme_marketing/customers.rb, line 54
def delete_default_config
  File.delete(JEKYLL_CONFIG) if File.exist?(JEKYLL_CONFIG)
end