<commit_before>require 'environment'

def obtain_class
  class_name = ENV['CLASS'] || ENV['class']
  @klass = Object.const_get(class_name)
end

def obtain_attachments
  name = ENV['ATTACHMENT'] || ENV['attachment']
  if !name.blank? && @klass.attachment_names.include?(name)
    [ name ]
  else
    @klass.attachment_definitions.keys
  end
end

namespace :paperclip do
  desc "Regenerates thumbnails for a given CLASS (and optional ATTACHMENT)"
  task :refresh do
    klass     = obtain_class
    instances = klass.find(:all)
    names     = obtain_attachments
    
    puts "Regenerating thumbnails for #{instances.length} instances of #{klass.name}:"
    instances.each do |instance|
      names.each do |name|<commit_msg>Removed the environment require at the top of paperclip_tasks.rake<commit_after>def obtain_class
  class_name = ENV['CLASS'] || ENV['class']
  @klass = Object.const_get(class_name)
end

def obtain_attachments
  name = ENV['ATTACHMENT'] || ENV['attachment']
  if !name.blank? && @klass.attachment_names.include?(name)
    [ name ]
  else
    @klass.attachment_definitions.keys
  end
end

namespace :paperclip do
  desc "Regenerates thumbnails for a given CLASS (and optional ATTACHMENT)"
  task :refresh => :environment do
    klass     = obtain_class
    instances = klass.find(:all)
    names     = obtain_attachments
    
    puts "Regenerating thumbnails for #{instances.length} instances of #{klass.name}:"
    instances.each do |instance|
      names.each do |name|
{'fraction_non_alphanumeric': 0.10575635876840696, 'fraction_numerical': 0.0, 'mean_word_length': 3.9667774086378738, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1177254', 'n_tokens_mistral': 468, 'n_tokens_neox': 482, 'n_words': 124}