<commit_before>class Library

  # The Feature class represents a single file within a library.
  #
  # This class had been called `Script` until it occured to me that
  # Ruby choose the name "feature" by it's use of tem in the global
  # variable `$LOADED_FEATURES`.
  #
  class Feature

    #
    # Create a new Feature instance.
    #
    # @param library [Library]
    #   The Library object to which the feature belongs.
    #
    # @param loadpath [String]
    #   The loadpath within the library in which the feature resides.
    #
    # @param filename [String]
    #   The file path of the feature relative to the loadpath.
    #
    # @param extension [Boolean]
    #   File extension to append to the feature filename.
    #
    def initialize(library, loadpath, filename, extension=nil)
      @library   = library
      @loadpath  = loadpath
      @filename  = filename
      @extension = extension
    end

    #
    # The Library object to which the file belongs.
    #
    attr_reader :library

    #
    # The loadpath within the library in which the feature resides.
    #
    # @return [Array] Load path relative to library location.
    #
    attr_reader :loadpath

    #
    # The file path of the feature relative to the loadpath.
    #
    attr_reader :filename

    #
    # Extension of feature file, e.g. `.rb`.
    #
    attr_reader :extension

    #
    # Name of the library to which the feature belongs.
    #
    # @return [String] name of the feature's library
    #
    def library_name
      Library === library ? library.name : nil
    end

    #
    #
    #
    def library_activate
      library.activate if Library === library
    end

    #
    # Library location.
    #
    # @return [String] location of library
    #
    def location
      Library===library ? library.location : library
    end

    #
    # Full path name of of feature.
    #
    # @return [String] expanded file path of feature 
    #
    def fullname
      @fullname ||= ::File.join(location, loadpath, filename + (extension || ''))
    end

    #
    # The path of the feature relative to the loadpath.
    #
    # @return [String] file path less location and loadpath
    #
    def localname
      @localname ||= ::File.join(filename + (extension || ''))
    end

    #
    # Acquire the feature --Roll's advanced require/load method.
    #
    # @return [true,false] true if loaded, false if it already has been loaded.
    #
    def acquire(options={})
      if options[:load] # TODO: .delete(:load) ?
        load(options)
      else
        require(options)
      end
    end

    #
    # Require feature.
    #
    # @return [true,false] true if loaded, false if it already has been loaded.
    #
    def require(options={})
      if library_name == 'ruby' or library_name == 'site_ruby'
        return false if $".include?(localname)  # ruby 1.8 does not use absolutes
        $" << localname # ruby 1.8 does not use absolutes
      end

      Library.load_stack << self #library
      begin
        library_activate unless options[:force]
        success = __require__(fullname)
      #rescue ::LoadError => load_error  # TODO: deativeate this if $DEBUG ?
      #  raise LoadError.new(localname, library_name)
      ensure
        Library.load_stack.pop
      end
      success
    end

    #
    # Load feature.
    #
    # @return [true,false] true if loaded, false if it already has been loaded.
    #
    def load(options={})
      if library_name == 'ruby' or library_name == 'site_ruby'
        $" << localname # ruby 1.8 does not use absolutes
      end<commit_msg>Separate library for site_ruby is no longer used. [bug]<commit_after>class Library

  # The Feature class represents a single file within a library.
  #
  # This class had been called `Script` until it occured to me that
  # Ruby choose the name "feature" by it's use of tem in the global
  # variable `$LOADED_FEATURES`.
  #
  class Feature

    #
    # Create a new Feature instance.
    #
    # @param library [Library]
    #   The Library object to which the feature belongs.
    #
    # @param loadpath [String]
    #   The loadpath within the library in which the feature resides.
    #
    # @param filename [String]
    #   The file path of the feature relative to the loadpath.
    #
    # @param extension [Boolean]
    #   File extension to append to the feature filename.
    #
    def initialize(library, loadpath, filename, extension=nil)
      @library   = library
      @loadpath  = loadpath
      @filename  = filename
      @extension = extension
    end

    #
    # The Library object to which the file belongs.
    #
    attr_reader :library

    #
    # The loadpath within the library in which the feature resides.
    #
    # @return [Array] Load path relative to library location.
    #
    attr_reader :loadpath

    #
    # The file path of the feature relative to the loadpath.
    #
    attr_reader :filename

    #
    # Extension of feature file, e.g. `.rb`.
    #
    attr_reader :extension

    #
    # Name of the library to which the feature belongs.
    #
    # @return [String] name of the feature's library
    #
    def library_name
      Library === library ? library.name : nil
    end

    #
    #
    #
    def library_activate
      library.activate if Library === library
    end

    #
    # Library location.
    #
    # @return [String] location of library
    #
    def location
      Library===library ? library.location : library
    end

    #
    # Full path name of of feature.
    #
    # @return [String] expanded file path of feature 
    #
    def fullname
      @fullname ||= ::File.join(location, loadpath, filename + (extension || ''))
    end

    #
    # The path of the feature relative to the loadpath.
    #
    # @return [String] file path less location and loadpath
    #
    def localname
      @localname ||= ::File.join(filename + (extension || ''))
    end

    #
    # Acquire the feature --Roll's advanced require/load method.
    #
    # @return [true,false] true if loaded, false if it already has been loaded.
    #
    def acquire(options={})
      if options[:load] # TODO: .delete(:load) ?
        load(options)
      else
        require(options)
      end
    end

    #
    # Require feature.
    #
    # @return [true,false] true if loaded, false if it already has been loaded.
    #
    def require(options={})
      if library_name == 'ruby' #or library_name == 'site_ruby'
        return false if $".include?(localname)  # ruby 1.8 does not use absolutes
        $" << localname # ruby 1.8 does not use absolutes
      end

      # TODO: return false if $".include(fullname) ? But Ruby should be handling this.

      Library.load_stack << self #library
      begin
        library_activate unless options[:force]
        success = __require__(fullname)
      #rescue ::LoadError => load_error  # TODO: deativeate this if $DEBUG ?
      #  raise LoadError.new(localname, library_name)
      ensure
        Library.load_stack.pop
      end
      success
    end

    #
    # Load feature.
    #
    # @return [true,false] true if loaded, false if it already has been loaded.
    #
    def load(options={})
      if library_name == 'ruby' #or library_name == 'site_ruby'
        $" << localname # ruby 1.8 does not use absolutes
      end
{'fraction_non_alphanumeric': 0.08887065901011758, 'fraction_numerical': 0.0016406890894175555, 'mean_word_length': 2.219630281690141, 'pattern_counts': {'":': 0, '<': 15, '<?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': '4083046', 'n_tokens_mistral': 2146, 'n_tokens_neox': 2080, 'n_words': 758}