Class: ThemeCheck::FileSystemStorage
- Defined in:
- lib/theme_check/file_system_storage.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #directories ⇒ Object
- #files ⇒ Object
-
#initialize(root, ignored_patterns: []) ⇒ FileSystemStorage
constructor
A new instance of FileSystemStorage.
- #path(relative_path) ⇒ Object
- #read(relative_path) ⇒ Object
- #write(relative_path, content) ⇒ Object
Constructor Details
#initialize(root, ignored_patterns: []) ⇒ FileSystemStorage
Returns a new instance of FileSystemStorage.
8 9 10 11 12 |
# File 'lib/theme_check/file_system_storage.rb', line 8 def initialize(root, ignored_patterns: []) @root = Pathname.new(root) @ignored_patterns = ignored_patterns @files = {} end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
6 7 8 |
# File 'lib/theme_check/file_system_storage.rb', line 6 def root @root end |
Instance Method Details
#directories ⇒ Object
31 32 33 34 35 |
# File 'lib/theme_check/file_system_storage.rb', line 31 def directories @directories ||= glob('*') .select { |f| File.directory?(f) } .map { |f| f.relative_path_from(@root).to_s } end |
#files ⇒ Object
26 27 28 29 |
# File 'lib/theme_check/file_system_storage.rb', line 26 def files @file_array ||= glob("**/*") .map { |path| path.relative_path_from(@root).to_s } end |
#path(relative_path) ⇒ Object
14 15 16 |
# File 'lib/theme_check/file_system_storage.rb', line 14 def path(relative_path) @root.join(relative_path) end |
#read(relative_path) ⇒ Object
18 19 20 |
# File 'lib/theme_check/file_system_storage.rb', line 18 def read(relative_path) file(relative_path).read end |
#write(relative_path, content) ⇒ Object
22 23 24 |
# File 'lib/theme_check/file_system_storage.rb', line 22 def write(relative_path, content) file(relative_path).write(content) end |