Class: RailsAssetslessContainer::Strategy::AssetServer

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_assetsless_container/strategy/asset_server.rb

Instance Method Summary collapse

Constructor Details

#initialize(asset_host: nil, suffix: ENV["SHA"], retry_count: 3, retry_wait: 1) ⇒ AssetServer

Returns a new instance of AssetServer.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rails_assetsless_container/strategy/asset_server.rb', line 6

def initialize(
  asset_host: nil,
  suffix: ENV["SHA"],
  retry_count: 3,
  retry_wait: 1
)
  @asset_host = asset_host
  @suffix = suffix
  @retry_count = retry_count
  @retry_wait = retry_wait
end

Instance Method Details

#after_sprockets(path) ⇒ Object



18
19
20
# File 'lib/rails_assetsless_container/strategy/asset_server.rb', line 18

def after_sprockets(path)
  FileUtils.copy(path, public_dir.join(sprockets_manifest_path))
end

#after_webpacker(path) ⇒ Object



22
23
24
# File 'lib/rails_assetsless_container/strategy/asset_server.rb', line 22

def after_webpacker(path)
  FileUtils.copy(path, public_dir.join(webpacker_manifest_path))
end

#write_sprockets_manifest(path) ⇒ Object



26
27
28
29
30
# File 'lib/rails_assetsless_container/strategy/asset_server.rb', line 26

def write_sprockets_manifest(path)
  uri = build_manifest_uri(sprockets_manifest_path)
  mkdir(path)
  File.write(path, download_with_retry(uri))
end

#write_webpacker_manifest(path) ⇒ Object



32
33
34
35
36
# File 'lib/rails_assetsless_container/strategy/asset_server.rb', line 32

def write_webpacker_manifest(path)
  uri = build_manifest_uri(webpacker_manifest_path)
  mkdir(path)
  File.write(path, download_with_retry(uri))
end