Class: RosettAi::Policy::OptOutScanner
- Inherits:
-
Object
- Object
- RosettAi::Policy::OptOutScanner
- Defined in:
- lib/rosett_ai/policy/opt_out_scanner.rb
Overview
Scans files for AI-MODIFICATION opt-out markers.
Files containing +# AI-MODIFICATION: disabled+ are added to the protected files list during compilation.
Constant Summary collapse
- MARKER =
'AI-MODIFICATION: disabled'
Instance Method Summary collapse
-
#opted_out?(path) ⇒ Boolean
Scans a single file for opt-out markers.
-
#scan(paths) ⇒ Array<String>
Scans multiple files and returns those with opt-out markers.
Instance Method Details
#opted_out?(path) ⇒ Boolean
Scans a single file for opt-out markers.
19 20 21 22 23 24 25 26 |
# File 'lib/rosett_ai/policy/opt_out_scanner.rb', line 19 def opted_out?(path) return false unless File.exist?(path) return false unless File.readable?(path) File.foreach(path).any? { |line| line.include?(MARKER) } rescue StandardError false end |
#scan(paths) ⇒ Array<String>
Scans multiple files and returns those with opt-out markers.
32 33 34 |
# File 'lib/rosett_ai/policy/opt_out_scanner.rb', line 32 def scan(paths) paths.select { |path| opted_out?(path) } end |