Class: ThemeCheck::InMemoryStorage

Inherits:
Storage
  • Object
show all
Defined in:
lib/theme_check/in_memory_storage.rb

Instance Method Summary collapse

Constructor Details

#initialize(files = {}) ⇒ InMemoryStorage

Returns a new instance of InMemoryStorage.



9
10
11
# File 'lib/theme_check/in_memory_storage.rb', line 9

def initialize(files = {})
  @files = files
end

Instance Method Details

#directoriesObject



29
30
31
32
33
34
35
# File 'lib/theme_check/in_memory_storage.rb', line 29

def directories
  @directories ||= @files
    .keys
    .flat_map { |relative_path| Pathname.new(relative_path).ascend.to_a }
    .map(&:to_s)
    .uniq
end

#filesObject



25
26
27
# File 'lib/theme_check/in_memory_storage.rb', line 25

def files
  @values ||= @files.keys
end

#path(name) ⇒ Object



13
14
15
# File 'lib/theme_check/in_memory_storage.rb', line 13

def path(name)
  name
end

#read(name) ⇒ Object



17
18
19
# File 'lib/theme_check/in_memory_storage.rb', line 17

def read(name)
  @files[name]
end

#write(name, content) ⇒ Object



21
22
23
# File 'lib/theme_check/in_memory_storage.rb', line 21

def write(name, content)
  @files[name] = content
end