lib/bhook/workspace.rb in bhook-0.1.1 vs lib/bhook/workspace.rb in bhook-0.1.2
- old
+ new
@@ -5,42 +5,41 @@
class Workspace
extend T::Sig
sig { params(src_path: String, out_path: String, theme_path: String).void }
def initialize(src_path, out_path, theme_path)
- @src_path = src_path
- @out_path = out_path
+ @src_path = T.let(Pathname.new(src_path).expand_path, Pathname)
+ @out_path = T.let(Pathname.new(out_path).expand_path, Pathname)
@theme = T.let(Theme.new(theme_path), Bhook::Theme)
end
sig { void }
- def process!
- root = root_dir
- root.write!(@out_path, @theme)
+ def process!
+ root_dir.write!(@theme)
+ L.info "Done!"
end
sig { void }
def watch!
process!
- puts
- puts "Watching #{@src_path} for changes..."
- listener = Listen.to(@src_path, File.join(@src_path, '.git')) do |_modified, _added, _removed|
+
+ L.info "Watching: #{@src_path} for changes..."
+ listener = Listen.to(@src_path.to_s, File.join(@src_path.to_s, '.git')) do |_modified, _added, _removed|
+ L.info "Detected changes..."
process!
- puts "-----\n"
end
listener.start
sleep
end
sig { returns(T::Array[MdFile]) }
def all_md_files
root_dir.all_md_files
end
-
- private
-
- sig { returns(Bhook::Directory) }
+
+ private
+ sig { returns(Bhook::RootDirectory) }
def root_dir
- Directory.new(Pathname.new(@src_path))
+ RootDirectory.new(@src_path, @out_path)
end
end
end