Class: Writefully::Workers::Handyman

Inherits:
BaseWorker show all
Includes:
Writefully::Workers::Helpers::Handyman::Builder
Defined in:
lib/writefully/workers/handyman.rb

Instance Attribute Summary collapse

Attributes inherited from BaseWorker

#message

Instance Method Summary collapse

Methods included from Writefully::Workers::Helpers::Handyman::Builder

#complete_site_setup, #initialize_sample_content

Methods inherited from BaseWorker

#actor_died, #close_db_connection!, #perform

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



6
7
8
# File 'lib/writefully/workers/handyman.rb', line 6

def site
  @site
end

Instance Method Details

#buildObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/writefully/workers/handyman.rb', line 8

def build
  @site      = Site.where(id: message[:site_id]).first
  @hammer    = Tools::Hammer.new_link(message.merge({ domain: site.domain }))
  # create the repository
  repo = @hammer.future.forge

  # add sample content
  @initializer = Tools::Initializer.new_link(message.merge({ ssh_url: repo.value.ssh_url }))
  initialize_sample_content

  # add web hook
  hook = @hammer.future.add_hook_for(repo.value.name)
  complete_site_setup(repo.value, hook.value)
ensure
  @hammer.terminate
  @initializer.terminate
  close_db_connection!
end

#synchronizeObject



27
28
29
30
31
32
33
# File 'lib/writefully/workers/handyman.rb', line 27

def synchronize
  @synchronizer = Tools::Synchronizer.new_link(message)
  synced = @synchronizer.future.sync
  Writefully.logger.info "Synchronized #{message[:site_slug]}" if synced.value
ensure
  @synchronizer.terminate
end