Class: PlatformosCheck::InMemoryStorage
- Inherits:
-
Storage
- Object
- Storage
- PlatformosCheck::InMemoryStorage
show all
- Defined in:
- lib/platformos_check/in_memory_storage.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Storage
#platformos_app, #versioned?
Constructor Details
#initialize(files = {}, root = "/dev/null") ⇒ InMemoryStorage
Returns a new instance of InMemoryStorage.
11
12
13
14
|
# File 'lib/platformos_check/in_memory_storage.rb', line 11
def initialize(files = {}, root = "/dev/null")
@files = files @root = Pathname.new(root)
end
|
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
9
10
11
|
# File 'lib/platformos_check/in_memory_storage.rb', line 9
def root
@root
end
|
Instance Method Details
#files ⇒ Object
38
39
40
|
# File 'lib/platformos_check/in_memory_storage.rb', line 38
def files
@files.keys
end
|
#files_with_content ⇒ Object
42
43
44
|
# File 'lib/platformos_check/in_memory_storage.rb', line 42
def files_with_content
@files
end
|
#mkdir(relative_path) ⇒ Object
34
35
36
|
# File 'lib/platformos_check/in_memory_storage.rb', line 34
def mkdir(relative_path)
@files[relative_path] = nil
end
|
#path(relative_path) ⇒ Object
16
17
18
|
# File 'lib/platformos_check/in_memory_storage.rb', line 16
def path(relative_path)
@root.join(relative_path)
end
|
#read(relative_path) ⇒ Object
20
21
22
|
# File 'lib/platformos_check/in_memory_storage.rb', line 20
def read(relative_path)
@files[relative_path]
end
|
#relative_path(absolute_path) ⇒ Object
46
47
48
|
# File 'lib/platformos_check/in_memory_storage.rb', line 46
def relative_path(absolute_path)
Pathname.new(absolute_path).relative_path_from(@root).to_s
end
|
#remove(relative_path) ⇒ Object
29
30
31
32
|
# File 'lib/platformos_check/in_memory_storage.rb', line 29
def remove(relative_path)
@platformos_app&.update([relative_path], remove: true)
@files.delete(relative_path)
end
|
#write(relative_path, content) ⇒ Object
24
25
26
27
|
# File 'lib/platformos_check/in_memory_storage.rb', line 24
def write(relative_path, content)
@platformos_app&.update([relative_path])
@files[relative_path] = content
end
|