<commit_before>module Jsus
  #
  # Package is a (self-contained) unit with all the info required to build
  # a javascript package.
  #
  class Package
    attr_accessor :directory # directory which this package resides in (full path)
    attr_accessor :pool      # an instance of Pool
    # Constructors

    #
    # Creates a package from given directory.
    #
    # Accepts options:
    # * +:pool:+ -- which pool the package should belong to.
    #
    # Raises an error when the given directory doesn't contain a package.yml or package.json
    # file with meta info.
    #
    def initialize(directory, options = {})
      self.directory          = File.expand_path(directory)
      if File.exists?(File.join(directory, 'package.yml'))
        self.header           = YAML.load_file(File.join(directory, 'package.yml'))
      elsif File.exists?(File.join(directory, 'package.json'))
        self.header           = JSON.load(IO.read(File.join(directory, 'package.json')))
      else
        raise "Directory #{directory} does not contain a valid package.yml / package.json file!"
      end
      Dir.chdir(directory) do
        files.each do |source|
          source_file = SourceFile.from_file(source, :package => self)
          if source_file
            if source_file.extension?
              extensions << source_file
            else
              source_files << source_file
            end
          else
            puts "Warning: #{source} is not found for #{name}" if Jsus.verbose?
          end
        end
      end
      if options[:pool]
        self.pool = options[:pool]
        self.pool << self
      end
    end


    # Public API

    # Returns a package.yml header.
    def header
      @header ||= {}
    end

    # Returns a package name.
    def name
      header["name"] ||= ""
    end

    # Returns a package description.
    def description
      header["description"] ||= ""
    end

    # Returns a filename for compiled package.
    def filename
      header["filename"] ||= snake_case(name) + ".js"
    end

    # Returns a list of sources filenames.
    def files
      header["files"] = header["files"] || header["sources"] || []<commit_msg>Namespacing issue for default filename guessing on package<commit_after>module Jsus
  #
  # Package is a (self-contained) unit with all the info required to build
  # a javascript package.
  #
  class Package
    attr_accessor :directory # directory which this package resides in (full path)
    attr_accessor :pool      # an instance of Pool
    # Constructors

    #
    # Creates a package from given directory.
    #
    # Accepts options:
    # * +:pool:+ -- which pool the package should belong to.
    #
    # Raises an error when the given directory doesn't contain a package.yml or package.json
    # file with meta info.
    #
    def initialize(directory, options = {})
      self.directory          = File.expand_path(directory)
      if File.exists?(File.join(directory, 'package.yml'))
        self.header           = YAML.load_file(File.join(directory, 'package.yml'))
      elsif File.exists?(File.join(directory, 'package.json'))
        self.header           = JSON.load(IO.read(File.join(directory, 'package.json')))
      else
        raise "Directory #{directory} does not contain a valid package.yml / package.json file!"
      end
      Dir.chdir(directory) do
        files.each do |source|
          source_file = SourceFile.from_file(source, :package => self)
          if source_file
            if source_file.extension?
              extensions << source_file
            else
              source_files << source_file
            end
          else
            puts "Warning: #{source} is not found for #{name}" if Jsus.verbose?
          end
        end
      end
      if options[:pool]
        self.pool = options[:pool]
        self.pool << self
      end
    end


    # Public API

    # Returns a package.yml header.
    def header
      @header ||= {}
    end

    # Returns a package name.
    def name
      header["name"] ||= ""
    end

    # Returns a package description.
    def description
      header["description"] ||= ""
    end

    # Returns a filename for compiled package.
    def filename
      header["filename"] ||= Jsus::Util::Inflection.snake_case(name) + ".js"
    end

    # Returns a list of sources filenames.
    def files
      header["files"] = header["files"] || header["sources"] || []
{'fraction_non_alphanumeric': 0.10027039206849932, 'fraction_numerical': 0.0, 'mean_word_length': 2.137102473498233, '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': '4184041', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1206, 'n_words': 385}