Class: Flutter::Persistence::Marshal
- Inherits:
-
AbstractStorage
- Object
- AbstractStorage
- Flutter::Persistence::Marshal
- Defined in:
- lib/flutter/persistence.rb
Instance Method Summary collapse
-
#clear! ⇒ void
Clear any saved state in the underlying storage.
-
#initialize(path:) ⇒ Marshal
constructor
A new instance of Marshal.
-
#load! ⇒ void
If the storage was already persisted load the current state.
-
#persist! ⇒ void
Save the state of test & source mapping to the underlying storage.
-
#source_hints ⇒ Hash<String, Set<String>]
Mapping of +source file -> class or module.
-
#source_mapping ⇒ Hash<String, Hash<String, String>>
Mapping of +source file -> callable_id -> signature+.
-
#test_mapping ⇒ Hash<String, Hash<String, Set<String>>>
Mapping of +test_id -> source file -> callable_id+.
- #to_s ⇒ String
-
#update_source_mapping!(mapping, hints) ⇒ Object
Update #source_mapping.
-
#update_test_mapping!(mapping) ⇒ Object
Update #test_mapping.
Constructor Details
#initialize(path:) ⇒ Marshal
Returns a new instance of Marshal.
150 151 152 153 154 155 156 |
# File 'lib/flutter/persistence.rb', line 150 def initialize(path:) @path = File.absolute_path(path) FileUtils.mkdir_p(@path) unless File.exist?(@path) @full_path = File.join(@path, "state.pstore") @state = nil super() end |
Instance Method Details
#clear! ⇒ void
This method returns an undefined value.
Clear any saved state in the underlying storage
207 208 209 |
# File 'lib/flutter/persistence.rb', line 207 def clear! FileUtils.rm(@full_path) if File.exist?(@full_path) end |
#load! ⇒ void
This method returns an undefined value.
If the storage was already persisted load the current state
159 160 161 162 163 164 165 |
# File 'lib/flutter/persistence.rb', line 159 def load! @state = PStore.new(@full_path) @state.transaction do @state[:test_mapping] ||= {} @state[:source_mapping] ||= {} end end |
#persist! ⇒ void
This method returns an undefined value.
Save the state of test & source mapping to the underlying storage
212 213 |
# File 'lib/flutter/persistence.rb', line 212 def persist! end |
#source_hints ⇒ Hash<String, Set<String>]
Mapping of +source file -> class or module
182 183 184 185 186 |
# File 'lib/flutter/persistence.rb', line 182 def source_hints @state.transaction do return @state[:source_hints] || {} end end |
#source_mapping ⇒ Hash<String, Hash<String, String>>
Mapping of +source file -> callable_id -> signature+
175 176 177 178 179 |
# File 'lib/flutter/persistence.rb', line 175 def source_mapping @state.transaction do return @state[:source_mapping] || {} end end |
#test_mapping ⇒ Hash<String, Hash<String, Set<String>>>
Mapping of +test_id -> source file -> callable_id+
168 169 170 171 172 |
# File 'lib/flutter/persistence.rb', line 168 def test_mapping @state.transaction do return @state[:test_mapping] || {} end end |
#to_s ⇒ String
216 217 218 |
# File 'lib/flutter/persistence.rb', line 216 def to_s "state: #{@full_path}" end |
#update_source_mapping!(mapping, hints) ⇒ Object
Update #source_mapping
197 198 199 200 201 202 203 204 |
# File 'lib/flutter/persistence.rb', line 197 def update_source_mapping!(mapping, hints) @state.transaction do @state[:source_mapping] ||= {} @state[:source_hints] ||= {} @state[:source_mapping].deep_merge!(mapping) @state[:source_hints].deep_merge!(hints) end end |
#update_test_mapping!(mapping) ⇒ Object
Update #test_mapping
189 190 191 192 193 194 |
# File 'lib/flutter/persistence.rb', line 189 def update_test_mapping!(mapping) @state.transaction do @state[:test_mapping] ||= {} @state[:test_mapping].merge!(mapping) end end |