<commit_before># Yogo Data Management Toolkit
# Copyright (c) 2010 Montana State University
#
# License -> see license.txt
#
# FILE: data_methods.rb
# 
module Yogo
  module DataMethods
    @@reserved_names = ["id", "iD", "Id", "ID"]
    # FIXME @return []
    # FIXME @api private, semipublic, or public
    def self.included(base)
      base.send(:extend, ClassMethods)
      base.class_eval do

        base.properties.each do |property|
          # Create carrierwave class for this property.
          if property.type == DataMapper::Types::YogoFile
            path = Rails.root / 'public' / 'files' 
            self.name.split('::').each{ |mod| path = path / mod }
            storage_dir = path.to_s
            anon_file_handler = Class.new(CarrierWave::Uploader::Base)
            anon_file_handler.instance_eval do 
              storage :file
              
              self.class_eval("def store_dir; '#{path}'; end")
              
            end
            
            named_class = Object.class_eval("#{self.name}::#{property.name.to_s.camelcase}File = anon_file_handler")
            mount_uploader property.name, named_class

          elsif property.type == DataMapper::Types::YogoImage
              path = Rails.root / 'public' / 'images' 
              self.name.split('::').each{ |mod| path = path / mod }
              storage_dir = path.to_s
              anon_file_handler = Class.new(CarrierWave::Uploader::Base)
              anon_file_handler.instance_eval do 
                storage :file
                self.class_eval("def store_dir; '#{path}'; end")
              end

              named_class = Object.class_eval("#{self.name}::#{property.name.to_s.camelcase}File = anon_file_handler")
              mount_uploader property.name, named_class
            
          end
        end
      end
    end
    
    # @return [String] makes "yogo___" for variable name
    # FIXME @api private, semipublic, or public
    def self.map_attribute(name)
      # @@reserved_names.include?(name) ? "yogo___"+name : name
      name
    end
    
    module ClassMethods
      # FIXME @return []
      # FIXME @api private, semipublic, or public
      end
      
      def usable_properties
        properties.select{|p| p.name != :yogo_id }
      end
    end
  end
end<commit_msg>removed extra end in data_methods.rb<commit_after># Yogo Data Management Toolkit
# Copyright (c) 2010 Montana State University
#
# License -> see license.txt
#
# FILE: data_methods.rb
# 
module Yogo
  module DataMethods
    @@reserved_names = ["id", "iD", "Id", "ID"]
    # FIXME @return []
    # FIXME @api private, semipublic, or public
    def self.included(base)
      base.send(:extend, ClassMethods)
      base.class_eval do

        base.properties.each do |property|
          # Create carrierwave class for this property.
          if property.type == DataMapper::Types::YogoFile
            path = Rails.root / 'public' / 'files' 
            self.name.split('::').each{ |mod| path = path / mod }
            storage_dir = path.to_s
            anon_file_handler = Class.new(CarrierWave::Uploader::Base)
            anon_file_handler.instance_eval do 
              storage :file

              self.class_eval("def store_dir; '#{path}'; end")

            end

            named_class = Object.class_eval("#{self.name}::#{property.name.to_s.camelcase}File = anon_file_handler")
            mount_uploader property.name, named_class

          elsif property.type == DataMapper::Types::YogoImage
            path = Rails.root / 'public' / 'images' 
            self.name.split('::').each{ |mod| path = path / mod }
            storage_dir = path.to_s
            anon_file_handler = Class.new(CarrierWave::Uploader::Base)
            anon_file_handler.instance_eval do 
              storage :file
              self.class_eval("def store_dir; '#{path}'; end")
            end

            named_class = Object.class_eval("#{self.name}::#{property.name.to_s.camelcase}File = anon_file_handler")
            mount_uploader property.name, named_class

          end
        end
      end
    end

    # @return [String] makes "yogo___" for variable name
    # FIXME @api private, semipublic, or public
    def self.map_attribute(name)
      # @@reserved_names.include?(name) ? "yogo___"+name : name
      name
    end

    module ClassMethods
      # FIXME @return []
      # FIXME @api private, semipublic, or public
    end

    def usable_properties
      properties.select{|p| p.name != :yogo_id }
    end
  end
end
{'fraction_non_alphanumeric': 0.10964041473637767, 'fraction_numerical': 0.0017648356496801235, 'mean_word_length': 2.1464260929909784, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4789598', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1330, 'n_words': 310}