Class: Kozeki::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/kozeki/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ Client

Returns a new instance of Client.

Parameters:



8
9
10
# File 'lib/kozeki/client.rb', line 8

def initialize(config:)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/kozeki/client.rb', line 12

def config
  @config
end

Instance Method Details

#build(incremental_build: true, events: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/kozeki/client.rb', line 14

def build(incremental_build: true, events: nil)
  begin
    state = State.open(path: config.state_path)
    build = Build.new(
      state: state,
      source_filesystem: @config.source_filesystem,
      destination_filesystem: @config.destination_filesystem,
      collection_list_included_prefix: @config.collection_list_included_prefix,
      collection_options: @config.collection_options,
      loader: @config.loader,
      incremental_build:,
      events:,
      logger: @config.logger,
    )
    build.perform
  ensure
    state&.close
  end

  @config.after_build_callbacks.each do |cb|
    cb.call(build)
  end
end

#watchObject



38
39
40
41
42
43
44
45
46
# File 'lib/kozeki/client.rb', line 38

def watch
  build(incremental_build: true, events: nil)
  stop = @config.source_filesystem.watch do |events|
    build(incremental_build: true, events: events)
  end
  sleep
ensure
  stop&.call
end