Class: Steep::Server::InlineSourceChangeDetector
- Defined in:
- lib/steep/server/inline_source_change_detector.rb
Defined Under Namespace
Classes: Source
Instance Attribute Summary collapse
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Instance Method Summary collapse
- #accumulate_change(file_path, changes) ⇒ Object
- #add_source(path, content) ⇒ Object
- #has_source?(path) ⇒ Boolean
-
#initialize ⇒ InlineSourceChangeDetector
constructor
A new instance of InlineSourceChangeDetector.
- #replace_source(path, content) ⇒ Object
- #reset ⇒ Object
- #type_updated_paths(paths) ⇒ Object
Constructor Details
#initialize ⇒ InlineSourceChangeDetector
Returns a new instance of InlineSourceChangeDetector.
57 58 59 |
# File 'lib/steep/server/inline_source_change_detector.rb', line 57 def initialize @sources = {} end |
Instance Attribute Details
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
55 56 57 |
# File 'lib/steep/server/inline_source_change_detector.rb', line 55 def sources @sources end |
Instance Method Details
#accumulate_change(file_path, changes) ⇒ Object
75 76 77 78 79 |
# File 'lib/steep/server/inline_source_change_detector.rb', line 75 def accumulate_change(file_path, changes) changes.each do |change| sources.fetch(file_path) << change end end |
#add_source(path, content) ⇒ Object
61 62 63 64 |
# File 'lib/steep/server/inline_source_change_detector.rb', line 61 def add_source(path, content) sources.key?(path) and raise "Source already exists for #{path}" sources[path] = Source.new(content) end |
#has_source?(path) ⇒ Boolean
85 86 87 |
# File 'lib/steep/server/inline_source_change_detector.rb', line 85 def has_source?(path) sources.key?(path) end |
#replace_source(path, content) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/steep/server/inline_source_change_detector.rb', line 66 def replace_source(path, content) source = sources.fetch(path) if source.content == content source.clear else source << Services::ContentChange.string(content) end end |
#reset ⇒ Object
89 90 91 |
# File 'lib/steep/server/inline_source_change_detector.rb', line 89 def reset sources.each_value { _1.updated? } end |
#type_updated_paths(paths) ⇒ Object
81 82 83 |
# File 'lib/steep/server/inline_source_change_detector.rb', line 81 def type_updated_paths(paths) paths.select { sources[_1]&.updated? }.to_set end |