lib/bhook/directory.rb in bhook-0.1.3 vs lib/bhook/directory.rb in bhook-0.1.4

- old
+ new

@@ -6,15 +6,22 @@ extend T::Sig GIT_DIR = '.git' MD_EXT = '.md' - sig { params(src_path: Pathname, out_path: Pathname, git: Git::Base).void } - def initialize(src_path, out_path, git) + sig { params(src_path: Pathname, out_path: Pathname).returns(Bhook::Directory) } + def self.new_root_directory(src_path, out_path) + self.new(src_path, out_path, Git.open(src_path), Bhook::Config.new(src_path)) + end + + + sig { params(src_path: Pathname, out_path: Pathname, git: Git::Base, config: Bhook::Config).void } + def initialize(src_path, out_path, git, config) @src_path = src_path @out_path = T.let(out_path.join(src_path.basename), Pathname) @git = git + @config = config @sub_dirs = T.let([], T::Array[Directory]) @md_files = T.let([], T::Array[MdFile]) build_next_level_nodes end @@ -48,12 +55,12 @@ children.delete(@src_path.join(GIT_DIR)) file_threads = [] children.each do |child_path| if child_path.directory? - @sub_dirs << Directory.new(child_path, @out_path, @git) + @sub_dirs << Directory.new(child_path, @out_path, @git, @config) elsif child_path.extname == MD_EXT - file_threads << Thread.new { MdFile.new(child_path, @out_path, @git) } + file_threads << Thread.new { MdFile.new(child_path, @out_path, @git, @config) } end end file_threads.each { |thread| @md_files << thread.value } end end