<commit_before>module CrashLog
  class Configuration

    DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze

    DEFAULT_BACKTRACE_FILTERS = [
      lambda { |line|
        if defined?(CrashLog.configuration.project_root) &&
          CrashLog.configuration.project_root.to_s != ''
          line.sub(/#{CrashLog.configuration.project_root}/, "[PROJECT_ROOT]")
        else
          line
        end
      },
      lambda { |line| line.gsub(/^\.\//, "") },
      lambda { |line|
        if defined?(Gem)
          Gem.path.inject(line) do |line, path|
            line.gsub(/#{path}/, "[GEM_ROOT]")
          end
        end
      },
      lambda { |line| line if line !~ %r{lib/crash_log} }
    ].freeze

    ENVIRONMENT_FILTERS = []

    IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
                      'ActionController::RoutingError',
                      'ActionController::InvalidAuthenticityToken',
                      'CGI::Session::CookieStore::TamperedWithCookie',
                      'ActionController::UnknownAction',
                      'AbstractController::ActionNotFound',
                      'Mongoid::Errors::DocumentNotFound']

    # The default logging device
    #
    # This will be set to Rails.logger automatically if using Rails,
    # otherwise it defaults to STDOUT.
    attr_accessor :logger

    # The API key to authenticate this project with CrashLog
    #
    # Get this from your projects configuration page within http://CrashLog.io
    attr_accessor :api_key

    # Stages (environments) which we consider to be in a production environment
    # and thus you want to be sent notifications for.
    attr_accessor :release_stages

    # The name of the current stage
    attr_reader :stage

    # Project Root directory
    attr_accessor :project_root
    alias :root :project_root

    # If set, this will serialize the object returned by sending this key to
    # the controller context. You can use this to send user data CrashLog to
    # correlate errors with users to give you more advanced data about directly
    # who was affected.
    #
    # All user data is stored encrypted for security and always remains your
    # property.
    attr_accessor :user_context_key

    # Reporter configuration options
    #
    # Host to send exceptions to. Default: crashlog.io
    attr_accessor :host

    # Port to use for http connections. 80 or 443 by default.
    attr_writer :port

    def port
      if @port
        @port
      else
        secure? ? 443 : 80
      end
    end

    # HTTP transfer scheme, default: https
    attr_accessor :scheme

    # API endpoint to context for notifications. Default /notify
    attr_accessor :endpoint

    # Reader for Array of ignored error class names
    attr_reader :ignore

    attr_reader :announce_endpoint, :announce

    attr_accessor :context_lines

    attr_accessor :environment_filters

    def initialize
      @secure                   = true
      @use_system_ssl_cert_chain= false
      @host                     = 'crashlog.io'
      @http_open_timeout        = 2
      @http_read_timeout        = 5
      @params_filters           = DEFAULT_PARAMS_FILTERS.dup
      @backtrace_filters        = DEFAULT_BACKTRACE_FILTERS.dup
      @environment_filters      = ENVIRONMENT_FILTERS.dup
      @ignore_by_filters        = []
      @ignore                   = IGNORE_DEFAULT.dup
      @release_stages           = %w(production staging)
      @notifier_version         = CrashLog::VERSION
      @notifier_url             = 'https://github.com/ivanvanderbyl/crashlog'
      @framework                = 'Standalone'
      @stage                    = 'development'
      @host                     = 'stdin.crashlog.io'
      @port                     = nil
      @scheme                   = 'https'
      @endpoint                 = '/notify'
      @announce                 = true
      @announce_endpoint        = '/announce'
      @context_lines            = 5
    end

    def release_stage?
      @release_stages.include?(stage)
    end

    def stage=(name)
      @stage = name.downcase.strip
    end

    # Is this configuration valid for sending exceptions to CrashLog
    #
    # Returns true if all required keys are provided, otherwise false
    def valid?
      [:api_key, :host, :port].all? do |key|
        !__send__(key).nil?
      end
    end

    def ignored?(exception)
      ignore.include?(error_class(exception))
    end

    def secure?
      scheme == 'https'
    end

    # Hash like accessor
    def [](key)
      if self.respond_to?(key)
        self.__send__(key)
      end
    end

  private

    def error_class(exception)
      # The "Class" check is for some strange exceptions like Timeout::Error
      # which throw the error class instead of an instance
      (exception.is_a? Class) ? exception.name : exception.class.name
    end

  end
end
<commit_msg>Added framework to configuration<commit_after>module CrashLog
  class Configuration

    DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze

    DEFAULT_BACKTRACE_FILTERS = [
      lambda { |line|
        if defined?(CrashLog.configuration.project_root) &&
          CrashLog.configuration.project_root.to_s != ''
          line.sub(/#{CrashLog.configuration.project_root}/, "[PROJECT_ROOT]")
        else
          line
        end
      },
      lambda { |line| line.gsub(/^\.\//, "") },
      lambda { |line|
        if defined?(Gem)
          Gem.path.inject(line) do |line, path|
            line.gsub(/#{path}/, "[GEM_ROOT]")
          end
        end
      },
      lambda { |line| line if line !~ %r{lib/crash_log} }
    ].freeze

    ENVIRONMENT_FILTERS = []

    IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
                      'ActionController::RoutingError',
                      'ActionController::InvalidAuthenticityToken',
                      'CGI::Session::CookieStore::TamperedWithCookie',
                      'ActionController::UnknownAction',
                      'AbstractController::ActionNotFound',
                      'Mongoid::Errors::DocumentNotFound']

    # The default logging device
    #
    # This will be set to Rails.logger automatically if using Rails,
    # otherwise it defaults to STDOUT.
    attr_accessor :logger

    # The API key to authenticate this project with CrashLog
    #
    # Get this from your projects configuration page within http://CrashLog.io
    attr_accessor :api_key

    # Stages (environments) which we consider to be in a production environment
    # and thus you want to be sent notifications for.
    attr_accessor :release_stages

    # The name of the current stage
    attr_reader :stage

    # Project Root directory
    attr_accessor :project_root
    alias :root :project_root

    # If set, this will serialize the object returned by sending this key to
    # the controller context. You can use this to send user data CrashLog to
    # correlate errors with users to give you more advanced data about directly
    # who was affected.
    #
    # All user data is stored encrypted for security and always remains your
    # property.
    attr_accessor :user_context_key

    # Reporter configuration options
    #
    # Host to send exceptions to. Default: crashlog.io
    attr_accessor :host

    # Port to use for http connections. 80 or 443 by default.
    attr_writer :port

    def port
      if @port
        @port
      else
        secure? ? 443 : 80
      end
    end

    # HTTP transfer scheme, default: https
    attr_accessor :scheme

    # API endpoint to context for notifications. Default /notify
    attr_accessor :endpoint

    # Reader for Array of ignored error class names
    attr_reader :ignore

    attr_reader :announce_endpoint, :announce

    # Send context lines for backtrace.
    #
    # Takes an integer of the number of lines, set to false or nil to disable.
    attr_accessor :context_lines

    # Environment variables to discard from ENV.
    attr_accessor :environment_filters

    # Framework name
    attr_accessor :framework

    def initialize
      @secure                   = true
      @use_system_ssl_cert_chain= false
      @host                     = 'crashlog.io'
      @http_open_timeout        = 2
      @http_read_timeout        = 5
      @params_filters           = DEFAULT_PARAMS_FILTERS.dup
      @backtrace_filters        = DEFAULT_BACKTRACE_FILTERS.dup
      @environment_filters      = ENVIRONMENT_FILTERS.dup
      @ignore_by_filters        = []
      @ignore                   = IGNORE_DEFAULT.dup
      @release_stages           = %w(production staging)
      @notifier_version         = CrashLog::VERSION
      @notifier_url             = 'https://github.com/ivanvanderbyl/crashlog'
      @framework                = 'Standalone'
      @stage                    = 'development'
      @host                     = 'stdin.crashlog.io'
      @port                     = nil
      @scheme                   = 'https'
      @endpoint                 = '/notify'
      @announce                 = true
      @announce_endpoint        = '/announce'
      @context_lines            = 5
      @framework                = 'Standalone'
    end

    def release_stage?
      @release_stages.include?(stage)
    end

    def stage=(name)
      @stage = name.downcase.strip
    end

    # Is this configuration valid for sending exceptions to CrashLog
    #
    # Returns true if all required keys are provided, otherwise false
    def valid?
      [:api_key, :host, :port].all? do |key|
        !__send__(key).nil?
      end
    end

    def ignored?(exception)
      ignore.include?(error_class(exception))
    end

    def secure?
      scheme == 'https'
    end

    # Hash like accessor
    def [](key)
      if self.respond_to?(key)
        self.__send__(key)
      end
    end

  private

    def error_class(exception)
      # The "Class" check is for some strange exceptions like Timeout::Error
      # which throw the error class instead of an instance
      (exception.is_a? Class) ? exception.name : exception.class.name
    end

  end
end

{'fraction_non_alphanumeric': 0.07616974972796518, 'fraction_numerical': 0.0025719655752299933, 'mean_word_length': 2.0296673658975126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1439941', 'n_tokens_mistral': 2848, 'n_tokens_neox': 2720, 'n_words': 809}