Class: S3AssetDeploy::RemoteAssetCollector
- Inherits:
-
Object
- Object
- S3AssetDeploy::RemoteAssetCollector
- Defined in:
- lib/s3_asset_deploy/remote_asset_collector.rb
Instance Attribute Summary collapse
-
#bucket_name ⇒ Object
readonly
Returns the value of attribute bucket_name.
Instance Method Summary collapse
- #asset_paths ⇒ Object
- #assets ⇒ Object
- #clear_cache ⇒ Object
- #grouped_assets ⇒ Object
-
#initialize(bucket_name, s3_client_options: {}, remove_fingerprint: nil) ⇒ RemoteAssetCollector
constructor
A new instance of RemoteAssetCollector.
- #inspect ⇒ Object
- #s3 ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(bucket_name, s3_client_options: {}, remove_fingerprint: nil) ⇒ RemoteAssetCollector
Returns a new instance of RemoteAssetCollector.
10 11 12 13 14 15 16 17 |
# File 'lib/s3_asset_deploy/remote_asset_collector.rb', line 10 def initialize(bucket_name, s3_client_options: {}, remove_fingerprint: nil) @bucket_name = bucket_name @remove_fingerprint = remove_fingerprint @s3_client_options = { region: "us-east-1", logger: @logger }.merge() end |
Instance Attribute Details
#bucket_name ⇒ Object (readonly)
Returns the value of attribute bucket_name.
8 9 10 |
# File 'lib/s3_asset_deploy/remote_asset_collector.rb', line 8 def bucket_name @bucket_name end |
Instance Method Details
#asset_paths ⇒ Object
40 41 42 |
# File 'lib/s3_asset_deploy/remote_asset_collector.rb', line 40 def asset_paths assets.map(&:path) end |
#assets ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/s3_asset_deploy/remote_asset_collector.rb', line 23 def assets @assets ||= s3.list_objects_v2(bucket: bucket_name).each_with_object([]) do |response, array| remote_assets = response .contents .reject { |obj| obj.key == S3AssetDeploy::RemovalManifest::PATH } .map do |obj| S3AssetDeploy::RemoteAsset.new(obj, remove_fingerprint: @remove_fingerprint) end array.concat(remote_assets) end end |
#clear_cache ⇒ Object
36 37 38 |
# File 'lib/s3_asset_deploy/remote_asset_collector.rb', line 36 def clear_cache @assets = nil end |
#grouped_assets ⇒ Object
44 45 46 |
# File 'lib/s3_asset_deploy/remote_asset_collector.rb', line 44 def grouped_assets assets.group_by(&:original_path) end |
#inspect ⇒ Object
52 53 54 |
# File 'lib/s3_asset_deploy/remote_asset_collector.rb', line 52 def inspect to_s end |
#s3 ⇒ Object
19 20 21 |
# File 'lib/s3_asset_deploy/remote_asset_collector.rb', line 19 def s3 @s3 ||= Aws::S3::Client.new(@s3_client_options) end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/s3_asset_deploy/remote_asset_collector.rb', line 48 def to_s "#<#{self.class.name}:#{"0x0000%x" % (object_id << 1)} @bucket_name='#{bucket_name}'>" end |