Class: Puma::Redeploy::BaseHandler

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/puma/redeploy/base_handler.rb

Overview

base redeploy handler

Direct Known Subclasses

FileHandler, S3Handler

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(watch_file:, deployer:, logger:) ⇒ BaseHandler

Returns a new instance of BaseHandler.



13
14
15
16
17
# File 'lib/puma/redeploy/base_handler.rb', line 13

def initialize(watch_file:, deployer:, logger:)
  @watch_file = watch_file
  @logger = logger
  @deployer = deployer
end

Instance Attribute Details

#watch_fileObject (readonly)

Returns the value of attribute watch_file.



11
12
13
# File 'lib/puma/redeploy/base_handler.rb', line 11

def watch_file
  @watch_file
end

Instance Method Details

#needs_redeploy?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
# File 'lib/puma/redeploy/base_handler.rb', line 19

def needs_redeploy?
  return false unless (mtime = touched_at) != @touched_at

  @touched_at = mtime
  true
end

#watch_file_dataObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/puma/redeploy/base_handler.rb', line 28

def watch_file_data
  watch_file_content = read_watch_object
  results = YAML.safe_load(watch_file_content, symbolize_names: true)
  return results if results.is_a?(Hash)

  # old style where the file contains only the archive location
  { commands: [], archive_location: results }
rescue StandardError
  {}
end