<commit_before>module Smithy
  class Asset < ActiveRecord::Base
    attr_accessible :name, :file, :file_name, :file_url, :retained_file, :uploaded_file_url

    validates_presence_of :file, :name

    file_accessor :file
    include Smithy::Dragonfly::AssetHelper

    before_validation :set_name

    def file
      # check for the jquery uploaded file first
      if self.uploaded_file_url?
        dragonfly_attachments[:file].app.datastore = self.class.dragonfly_remote_datastore
        self.file_url = self.uploaded_file_url
      elsif dragonfly_attachments[:file].to_value
        dragonfly_attachments[:file].app.datastore = self.class.dragonfly_datastore
      end
      dragonfly_attachments[:file].to_value
    end

    def to_liquid
      {
        'id' => self.id,
        'name' => self.name,
        'content_type' => self.content_type,
        'file' => self.file,
        'file_name' => self.file_name,
        'file_width' => self.file_width,
        'file_height' => self.file_height,
        'file_size' => self.file_size,
        'file_url' => self.file.url
      }
    end

    private
      def set_name
        if self.uploaded_file_url?
          self.name = File.basename(self.uploaded_file_url, '.*').titleize unless self.name?
        elsif self.file.present?
          self.name = File.basename(self.file.name, '.*').titleize unless self.name?
        end
     end
  end
end<commit_msg>changed file_url to url in to_liquid hash<commit_after>module Smithy
  class Asset < ActiveRecord::Base
    attr_accessible :name, :file, :file_name, :file_url, :retained_file, :uploaded_file_url

    validates_presence_of :file, :name

    file_accessor :file
    include Smithy::Dragonfly::AssetHelper

    before_validation :set_name

    def file
      # check for the jquery uploaded file first
      if self.uploaded_file_url?
        dragonfly_attachments[:file].app.datastore = self.class.dragonfly_remote_datastore
        self.file_url = self.uploaded_file_url
      elsif dragonfly_attachments[:file].to_value
        dragonfly_attachments[:file].app.datastore = self.class.dragonfly_datastore
      end
      dragonfly_attachments[:file].to_value
    end

    def to_liquid
      {
        'id' => self.id,
        'name' => self.name,
        'content_type' => self.content_type,
        'file' => self.file,
        'file_name' => self.file_name,
        'file_width' => self.file_width,
        'file_height' => self.file_height,
        'file_size' => self.file_size,
        'url' => self.file.url
      }
    end

    private
      def set_name
        if self.uploaded_file_url?
          self.name = File.basename(self.uploaded_file_url, '.*').titleize unless self.name?
        elsif self.file.present?
          self.name = File.basename(self.file.name, '.*').titleize unless self.name?
        end
     end
  end
end
{'fraction_non_alphanumeric': 0.10227670753064799, 'fraction_numerical': 0.0, 'mean_word_length': 2.6851612903225806, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '2196870', 'n_tokens_mistral': 947, 'n_tokens_neox': 926, 'n_words': 175}