Class: WebpackerUploader::Instance
- Inherits:
-
Object
- Object
- WebpackerUploader::Instance
- Defined in:
- lib/webpacker_uploader/instance.rb
Instance Attribute Summary collapse
-
#config ⇒ WebpackerUploader::Configuration
Returns the global WebpackerUploader::Configuration object.
Instance Method Summary collapse
-
#configure {|config| ... } ⇒ Object
Yields the global configuration to a block.
-
#upload!(provider, prefix: nil, cache_control: nil)
Uploads assets using the supplied provider.
Instance Attribute Details
#config ⇒ WebpackerUploader::Configuration
Returns the global WebpackerUploader::Configuration object. Use this to set and retrieve specific configuration options.
23 24 25 |
# File 'lib/webpacker_uploader/instance.rb', line 23 def config @config ||= WebpackerUploader::Configuration.new end |
Instance Method Details
#configure {|config| ... } ⇒ Object
Yields the global configuration to a block. Use this to configure the base gem features.
39 40 41 |
# File 'lib/webpacker_uploader/instance.rb', line 39 def configure yield config end |
#upload!(provider, prefix: nil, cache_control: nil)
This method returns an undefined value.
Uploads assets using the supplied provider. Currently only AWS S3 is implemented.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/webpacker_uploader/instance.rb', line 49 def upload!(provider, prefix: nil, cache_control: nil) manifest.assets.each do |name, js_path| path = js_path[1..-1] remote_path = if prefix.nil? path else "#{prefix}/#{path}" end file_path = config.public_path.join(path) if name.end_with?(*config.ignored_extensions) config.logger.info("Skipping #{file_path}") if config.log_output? else content_type = WebpackerUploader::Mime.mime_type(path) config.logger.info("Processing #{file_path} as #{content_type}") if config.log_output? provider.upload!(remote_path, file_path, content_type, cache_control) end end end |