Class: Bhook::Workspace

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/bhook/workspace.rb

Instance Method Summary collapse

Constructor Details

#initialize(src_path, out_path, theme_path) ⇒ Workspace

Returns a new instance of Workspace.



9
10
11
12
13
# File 'lib/bhook/workspace.rb', line 9

def initialize(src_path, out_path, theme_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

Instance Method Details

#process!Object



16
17
18
19
# File 'lib/bhook/workspace.rb', line 16

def process!
  root_dir.write!(@theme)
  L.info 'Done!'
end

#watch!Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/bhook/workspace.rb', line 22

def watch!
  process!

  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!
  end
  listener.start
end