<commit_before>module ComfortableMexicanSofa::Fixtures
  
  def self.sync(site)
    sync_layouts(site)
    sync_pages(site)
    sync_snippets(site)
  end
  
  def self.sync_layouts(site, path = nil, root = true, parent = nil, layout_ids = [])
    return unless path ||= find_path(site, 'layouts')
    
    Dir.glob("#{path}/*").select{|f| File.directory?(f)}.each do |path|
      slug = path.split('/').last
      layout = site.layouts.find_by_slug(slug) || site.layouts.new(:slug => slug)
      
      # updating attributes
      if File.exists?(file_path = File.join(path, "_#{slug}.yml"))
        if layout.new_record? || File.mtime(file_path) > layout.updated_at
          attributes = YAML.load_file(file_path).symbolize_keys!
          layout.label      = attributes[:label] || slug.titleize
          layout.app_layout = attributes[:app_layout] || parent.try(:app_layout) 
        end<commit_msg>site is not present, fixtures should shut up<commit_after>module ComfortableMexicanSofa::Fixtures
  
  def self.sync(site)
    return unless site
    sync_layouts(site)
    sync_pages(site)
    sync_snippets(site)
  end
  
  def self.sync_layouts(site, path = nil, root = true, parent = nil, layout_ids = [])
    return unless path ||= find_path(site, 'layouts')
    
    Dir.glob("#{path}/*").select{|f| File.directory?(f)}.each do |path|
      slug = path.split('/').last
      layout = site.layouts.find_by_slug(slug) || site.layouts.new(:slug => slug)
      
      # updating attributes
      if File.exists?(file_path = File.join(path, "_#{slug}.yml"))
        if layout.new_record? || File.mtime(file_path) > layout.updated_at
          attributes = YAML.load_file(file_path).symbolize_keys!
          layout.label      = attributes[:label] || slug.titleize
          layout.app_layout = attributes[:app_layout] || parent.try(:app_layout) 
        end
{'fraction_non_alphanumeric': 0.139247311827957, 'fraction_numerical': 0.0, 'mean_word_length': 3.1820224719101122, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '963083', 'n_tokens_mistral': 621, 'n_tokens_neox': 617, 'n_words': 111}