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_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) ⇒ Object
Update #source_mapping.
-
#update_test_mapping!(mapping) ⇒ Object
Update #test_mapping.
Constructor Details
#initialize(path:) ⇒ Marshal
Returns a new instance of Marshal.
136 137 138 139 140 141 142 |
# File 'lib/flutter/persistence.rb', line 136 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
184 185 186 |
# File 'lib/flutter/persistence.rb', line 184 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
145 146 147 148 149 150 151 |
# File 'lib/flutter/persistence.rb', line 145 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
189 190 |
# File 'lib/flutter/persistence.rb', line 189 def persist! end |
#source_mapping ⇒ Hash<String, Hash<String, String>>
Mapping of +source file -> callable_id -> signature+
161 162 163 164 165 |
# File 'lib/flutter/persistence.rb', line 161 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+
154 155 156 157 158 |
# File 'lib/flutter/persistence.rb', line 154 def test_mapping @state.transaction do return @state[:test_mapping] end end |
#to_s ⇒ String
193 194 195 |
# File 'lib/flutter/persistence.rb', line 193 def to_s "state: #{@full_path}" end |
#update_source_mapping!(mapping) ⇒ Object
Update #source_mapping
176 177 178 179 180 181 |
# File 'lib/flutter/persistence.rb', line 176 def update_source_mapping!(mapping) @state.transaction do @state[:source_mapping] ||= {} @state[:source_mapping].merge!(mapping) end end |
#update_test_mapping!(mapping) ⇒ Object
Update #test_mapping
168 169 170 171 172 173 |
# File 'lib/flutter/persistence.rb', line 168 def update_test_mapping!(mapping) @state.transaction do @state[:test_mapping] ||= {} @state[:test_mapping].merge!(mapping) end end |