Class: Appydave::Tools::Dam::S3Base
- Inherits:
-
Object
- Object
- Appydave::Tools::Dam::S3Base
- Defined in:
- lib/appydave/tools/dam/s3_base.rb
Overview
Shared infrastructure and helpers for S3 operations. All focused S3 operation classes inherit from this base.
Direct Known Subclasses
S3Archiver, S3Downloader, S3Operations, S3StatusChecker, S3Uploader
Constant Summary collapse
- EXCLUDE_PATTERNS =
Directory patterns to exclude from archive/upload (generated/installable content)
%w[ **/node_modules/** **/.git/** **/.next/** **/dist/** **/build/** **/out/** **/.cache/** **/coverage/** **/.turbo/** **/.vercel/** **/tmp/** **/.DS_Store **/*:Zone.Identifier ].freeze
Instance Attribute Summary collapse
-
#brand ⇒ Object
readonly
Returns the value of attribute brand.
-
#brand_info ⇒ Object
readonly
Returns the value of attribute brand_info.
-
#brand_path ⇒ Object
readonly
Returns the value of attribute brand_path.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
Instance Method Summary collapse
-
#build_s3_key(relative_path) ⇒ Object
Build S3 key for a file.
-
#extract_relative_path(s3_key) ⇒ Object
Extract relative path from S3 key.
-
#initialize(brand, project_id, brand_info: nil, brand_path: nil, s3_client: nil) ⇒ S3Base
constructor
A new instance of S3Base.
-
#s3_client ⇒ Object
Lazy-load S3 client (only create when actually needed, not for dry-run).
Constructor Details
#initialize(brand, project_id, brand_info: nil, brand_path: nil, s3_client: nil) ⇒ S3Base
Returns a new instance of S3Base.
33 34 35 36 37 38 39 40 41 |
# File 'lib/appydave/tools/dam/s3_base.rb', line 33 def initialize(brand, project_id, brand_info: nil, brand_path: nil, s3_client: nil) @project_id = project_id # Use injected dependencies or load from configuration @brand_info = brand_info || load_brand_info(brand) @brand = @brand_info.key # Use resolved brand key, not original input @brand_path = brand_path || Config.brand_path(@brand) @s3_client_override = s3_client # Store override but don't create client yet (lazy loading) end |
Instance Attribute Details
#brand ⇒ Object (readonly)
Returns the value of attribute brand.
14 15 16 |
# File 'lib/appydave/tools/dam/s3_base.rb', line 14 def brand @brand end |
#brand_info ⇒ Object (readonly)
Returns the value of attribute brand_info.
14 15 16 |
# File 'lib/appydave/tools/dam/s3_base.rb', line 14 def brand_info @brand_info end |
#brand_path ⇒ Object (readonly)
Returns the value of attribute brand_path.
14 15 16 |
# File 'lib/appydave/tools/dam/s3_base.rb', line 14 def brand_path @brand_path end |
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
14 15 16 |
# File 'lib/appydave/tools/dam/s3_base.rb', line 14 def project_id @project_id end |
Instance Method Details
#build_s3_key(relative_path) ⇒ Object
Build S3 key for a file
49 50 51 |
# File 'lib/appydave/tools/dam/s3_base.rb', line 49 def build_s3_key(relative_path) "#{brand_info.aws.s3_prefix}#{project_id}/#{relative_path}" end |
#extract_relative_path(s3_key) ⇒ Object
Extract relative path from S3 key
54 55 56 |
# File 'lib/appydave/tools/dam/s3_base.rb', line 54 def extract_relative_path(s3_key) s3_key.sub("#{brand_info.aws.s3_prefix}#{project_id}/", '') end |
#s3_client ⇒ Object
Lazy-load S3 client (only create when actually needed, not for dry-run)
44 45 46 |
# File 'lib/appydave/tools/dam/s3_base.rb', line 44 def s3_client @s3_client ||= @s3_client_override || create_s3_client(@brand_info) end |