<commit_before># Author::    <NAME>  (mailto: <EMAIL>)
# Copyright:: Copyright (c) 2008 Rocket Boys Ltd
# License::   BSD Licence, see application root.

class Theme
  attr_accessor :name
  
  def initialize(nm)
    @name = nm
  end
  
  def stylesheet
    "/themes/#{name}/stylesheets/master"
  end
  
  def self.active
    AppConfig.theme ? new(AppConfig.theme) : default
  end
  
  def self.admin
    new('admin')
  end
  
  def self.default
    new('default')
  end
  
  def self.all
    # TODO pick up directories only
    files = Dir.entries("#{RAILS_ROOT}/public/themes/")
    files = files.delete_if do |file|
      %w{ . .. admin }.include?(file)
    end
    files.sort.collect { |t| self.new(t) }
  end
  
end<commit_msg>Refactored Theme.all<commit_after># Author::    <NAME>  (mailto: <EMAIL>)
# Copyright:: Copyright (c) 2008 Rocket Boys Ltd
# License::   BSD Licence, see application root.

class Theme
  THEME_DIRECTORY = "#{RAILS_ROOT}/public/themes/"
  
  attr_accessor :name
  
  def initialize(nm)
    @name = nm
  end
  
  def stylesheet
    "/themes/#{name}/stylesheets/master"
  end
  
  def self.active
    AppConfig.theme ? new(AppConfig.theme) : default
  end
  
  def self.admin
    new('admin')
  end
  
  def self.default
    new('default')
  end
  
  def self.all
    files = Dir.entries(THEME_DIRECTORY)
    excludes = %w{ . .. admin }
    files.delete_if do |file|
      excludes.include?(file) || !File.directory?(THEME_DIRECTORY + file)
    end
    files.collect { |t| self.new(t) }
  end
  
end
{'fraction_non_alphanumeric': 0.12442698100851342, 'fraction_numerical': 0.005239030779305829, 'mean_word_length': 2.70873786407767, 'pattern_counts': {'":': 0, '<': 7, '<?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': '466704', 'n_tokens_mistral': 558, 'n_tokens_neox': 543, 'n_words': 133}