Class: Bhook::Directory
- Inherits:
-
Object
- Object
- Bhook::Directory
- Extended by:
- T::Sig
- Defined in:
- lib/bhook/directory.rb
Direct Known Subclasses
Constant Summary collapse
- GIT_DIR =
'.git'
- MD_EXT =
'.md'
Class Method Summary collapse
Instance Method Summary collapse
- #all_md_files ⇒ Object
-
#initialize(src_path, out_path, git, config) ⇒ Directory
constructor
A new instance of Directory.
- #to_s ⇒ Object
- #write!(theme) ⇒ Object
Constructor Details
#initialize(src_path, out_path, git, config) ⇒ Directory
Returns a new instance of Directory.
17 18 19 20 21 22 23 24 25 |
# File 'lib/bhook/directory.rb', line 17 def initialize(src_path, out_path, git, config) @src_path = src_path @out_path = T.let(build_out_path(src_path, out_path), Pathname) @git = git @config = config @sub_dirs = T.let([], T::Array[Directory]) @md_files = T.let([], T::Array[MdFile]) build_next_level_nodes end |
Class Method Details
.new_root_directory(src_path, out_path) ⇒ Object
12 13 14 |
# File 'lib/bhook/directory.rb', line 12 def self.new_root_directory(src_path, out_path) RootDirectory.new(src_path, out_path) end |
Instance Method Details
#all_md_files ⇒ Object
38 39 40 |
# File 'lib/bhook/directory.rb', line 38 def all_md_files @md_files + @sub_dirs.map(&:all_md_files).flatten end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/bhook/directory.rb', line 43 def to_s @src_path.to_s end |
#write!(theme) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/bhook/directory.rb', line 28 def write!(theme) FileUtils.mkdir_p(@out_path) L.debug("mkdir: #{@out_path}") @sub_dirs.each { |dir| dir.write!(theme) } @md_files.map do |file| Thread.new { file.write!(theme) } end.each(&:join) end |