Class: Promptmenot::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/promptmenot/configuration.rb

Constant Summary collapse

VALID_SENSITIVITIES =
%i[low medium high paranoid].freeze
VALID_MODES =
%i[reject sanitize].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
18
19
# File 'lib/promptmenot/configuration.rb', line 11

def initialize
  @sensitivity = :medium
  @mode = :reject
  @replacement_text = "[removed]"
  @max_length = 50_000
  @custom_patterns_list = []
  @custom_patterns = nil
  @on_detect = nil
end

Instance Attribute Details

#max_lengthObject

Returns the value of attribute max_length.



9
10
11
# File 'lib/promptmenot/configuration.rb', line 9

def max_length
  @max_length
end

#modeObject

Returns the value of attribute mode.



8
9
10
# File 'lib/promptmenot/configuration.rb', line 8

def mode
  @mode
end

#on_detectObject

Returns the value of attribute on_detect.



9
10
11
# File 'lib/promptmenot/configuration.rb', line 9

def on_detect
  @on_detect
end

#replacement_textObject

Returns the value of attribute replacement_text.



9
10
11
# File 'lib/promptmenot/configuration.rb', line 9

def replacement_text
  @replacement_text
end

#sensitivityObject

Returns the value of attribute sensitivity.



8
9
10
# File 'lib/promptmenot/configuration.rb', line 8

def sensitivity
  @sensitivity
end

Instance Method Details

#add_pattern(name:, regex:, category: :custom, sensitivity: :medium, confidence: :medium) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/promptmenot/configuration.rb', line 43

def add_pattern(name:, regex:, category: :custom, sensitivity: :medium, confidence: :medium)
  @custom_patterns_list << Pattern.new(
    name: name,
    category: category,
    regex: regex,
    sensitivity: sensitivity,
    confidence: confidence
  )
  @custom_patterns = nil
end

#custom_patternsObject



39
40
41
# File 'lib/promptmenot/configuration.rb', line 39

def custom_patterns
  @custom_patterns ||= @custom_patterns_list.dup.freeze
end