Class: EventTimeline::Configuration
- Inherits:
-
Object
- Object
- EventTimeline::Configuration
- Defined in:
- lib/event_timeline/configuration.rb
Instance Attribute Summary collapse
-
#cleanup_threshold ⇒ Object
Returns the value of attribute cleanup_threshold.
-
#filtered_attributes ⇒ Object
Returns the value of attribute filtered_attributes.
-
#max_event_age ⇒ Object
Returns the value of attribute max_event_age.
-
#max_events_per_correlation ⇒ Object
Returns the value of attribute max_events_per_correlation.
-
#max_inspect_length ⇒ Object
Returns the value of attribute max_inspect_length.
-
#max_string_length ⇒ Object
Returns the value of attribute max_string_length.
-
#max_total_events ⇒ Object
Returns the value of attribute max_total_events.
-
#narrator_proc ⇒ Object
Returns the value of attribute narrator_proc.
-
#pii_filter_proc ⇒ Object
Returns the value of attribute pii_filter_proc.
-
#watched_paths ⇒ Object
Returns the value of attribute watched_paths.
Instance Method Summary collapse
- #add_filtered_attributes(*attrs) ⇒ Object
- #filter_pii(&block) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #narrator(&block) ⇒ Object
- #remove_filtered_attributes(*attrs) ⇒ Object
- #should_filter?(key, value, context = {}) ⇒ Boolean
- #watch(path) ⇒ Object
- #watched?(file_path) ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/event_timeline/configuration.rb', line 9 def initialize @watched_paths = [] @filtered_attributes = default_filtered_attributes @max_events_per_correlation = 500 # Max events per correlation_id @max_total_events = 10_000 # Max total events before cleanup @cleanup_threshold = 0.8 # Start cleanup at 80% of max @max_event_age = 1.month # Delete events older than this @max_string_length = 100 # Truncate strings longer than this @max_inspect_length = 200 # Truncate inspected values longer than this end |
Instance Attribute Details
#cleanup_threshold ⇒ Object
Returns the value of attribute cleanup_threshold.
5 6 7 |
# File 'lib/event_timeline/configuration.rb', line 5 def cleanup_threshold @cleanup_threshold end |
#filtered_attributes ⇒ Object
Returns the value of attribute filtered_attributes.
5 6 7 |
# File 'lib/event_timeline/configuration.rb', line 5 def filtered_attributes @filtered_attributes end |
#max_event_age ⇒ Object
Returns the value of attribute max_event_age.
5 6 7 |
# File 'lib/event_timeline/configuration.rb', line 5 def max_event_age @max_event_age end |
#max_events_per_correlation ⇒ Object
Returns the value of attribute max_events_per_correlation.
5 6 7 |
# File 'lib/event_timeline/configuration.rb', line 5 def max_events_per_correlation @max_events_per_correlation end |
#max_inspect_length ⇒ Object
Returns the value of attribute max_inspect_length.
5 6 7 |
# File 'lib/event_timeline/configuration.rb', line 5 def max_inspect_length @max_inspect_length end |
#max_string_length ⇒ Object
Returns the value of attribute max_string_length.
5 6 7 |
# File 'lib/event_timeline/configuration.rb', line 5 def max_string_length @max_string_length end |
#max_total_events ⇒ Object
Returns the value of attribute max_total_events.
5 6 7 |
# File 'lib/event_timeline/configuration.rb', line 5 def max_total_events @max_total_events end |
#narrator_proc ⇒ Object
Returns the value of attribute narrator_proc.
5 6 7 |
# File 'lib/event_timeline/configuration.rb', line 5 def narrator_proc @narrator_proc end |
#pii_filter_proc ⇒ Object
Returns the value of attribute pii_filter_proc.
5 6 7 |
# File 'lib/event_timeline/configuration.rb', line 5 def pii_filter_proc @pii_filter_proc end |
#watched_paths ⇒ Object
Returns the value of attribute watched_paths.
5 6 7 |
# File 'lib/event_timeline/configuration.rb', line 5 def watched_paths @watched_paths end |
Instance Method Details
#add_filtered_attributes(*attrs) ⇒ Object
40 41 42 |
# File 'lib/event_timeline/configuration.rb', line 40 def add_filtered_attributes(*attrs) @filtered_attributes.concat(attrs.map(&:to_s)) end |
#filter_pii(&block) ⇒ Object
36 37 38 |
# File 'lib/event_timeline/configuration.rb', line 36 def filter_pii(&block) @pii_filter_proc = block if block_given? end |
#narrator(&block) ⇒ Object
20 21 22 |
# File 'lib/event_timeline/configuration.rb', line 20 def narrator(&block) @narrator_proc = block if block_given? end |
#remove_filtered_attributes(*attrs) ⇒ Object
44 45 46 |
# File 'lib/event_timeline/configuration.rb', line 44 def remove_filtered_attributes(*attrs) attrs.each { |attr| @filtered_attributes.delete(attr.to_s) } end |
#should_filter?(key, value, context = {}) ⇒ Boolean
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/event_timeline/configuration.rb', line 48 def should_filter?(key, value, context = {}) key_str = key.to_s.downcase # Check custom filter first if @pii_filter_proc result = @pii_filter_proc.call(key, value, context) return result unless result.nil? end # Default filtering logic @filtered_attributes.any? { |attr| key_str.include?(attr) } end |
#watch(path) ⇒ Object
24 25 26 |
# File 'lib/event_timeline/configuration.rb', line 24 def watch(path) @watched_paths << normalize_path(path) end |
#watched?(file_path) ⇒ Boolean
28 29 30 31 32 33 34 |
# File 'lib/event_timeline/configuration.rb', line 28 def watched?(file_path) return false if @watched_paths.empty? @watched_paths.any? do |pattern| File.fnmatch?(pattern, file_path, File::FNM_PATHNAME) end end |