Class: CabezaDeTermo::AssetsPublisher::OneFilePerAssetBuilder
- Inherits:
-
CompilationJobsBuilder
- Object
- CompilationJobsBuilder
- CabezaDeTermo::AssetsPublisher::OneFilePerAssetBuilder
- Defined in:
- lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb
Instance Method Summary collapse
-
#add_timestamps? ⇒ Boolean
Answer if we must append a timestamp to the relative assets or not.
-
#asset ⇒ Object
Answer the current asset.
-
#asset_to_compile_to ⇒ Object
Answer the asset that will hold the compiled assets.
-
#assets_to_compile ⇒ Object
Answer the asset to compile.
- #compiled_filename ⇒ Object
-
#jobs_for(assets) ⇒ Object
Answer a collection of CompilationJob to send to a Compiler.
-
#new_compilation_job_for(asset) ⇒ Object
Answer a new CompilationJob for a single asset to send to a Compiler.
- #remove_last_extension_from_uri ⇒ Object
-
#timestamp_string ⇒ Object
Answer the timestamp string to add to this asset.
Methods inherited from CompilationJobsBuilder
#asset_to_publish, #asset_type, #compiled_assets_folder, #compiled_uri, #configuration, #initialize, jobs_for
Constructor Details
This class inherits a constructor from CabezaDeTermo::AssetsPublisher::CompilationJobsBuilder
Instance Method Details
#add_timestamps? ⇒ Boolean
Answer if we must append a timestamp to the relative assets or not
54 55 56 |
# File 'lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb', line 54 def () configuration. end |
#asset ⇒ Object
Answer the current asset
19 20 21 |
# File 'lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb', line 19 def asset() @asset end |
#asset_to_compile_to ⇒ Object
Answer the asset that will hold the compiled assets.
35 36 37 38 39 40 |
# File 'lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb', line 35 def asset_to_compile_to() return asset if asset.location.is_absolute? asset_to_publish .set_uri_parameters() end |
#assets_to_compile ⇒ Object
Answer the asset to compile. If the asset has an absolute location we won’t compile it
25 26 27 28 29 30 31 32 |
# File 'lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb', line 25 def assets_to_compile() if asset.location.is_absolute? asset.validate_real_path return [] end [asset] end |
#compiled_filename ⇒ Object
42 43 44 45 |
# File 'lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb', line 42 def compiled_filename return asset.uri if ['.css', '.js'].include?(asset.uri.extname) Pathname.new(remove_last_extension_from_uri) end |
#jobs_for(assets) ⇒ Object
Answer a collection of CompilationJob to send to a Compiler.
8 9 10 |
# File 'lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb', line 8 def jobs_for(assets) assets.collect { |asset| new_compilation_job_for asset } end |
#new_compilation_job_for(asset) ⇒ Object
Answer a new CompilationJob for a single asset to send to a Compiler
13 14 15 16 |
# File 'lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb', line 13 def new_compilation_job_for(asset) @asset = asset CompilationJob.new(assets: assets_to_compile, destination: asset_to_compile_to) end |
#remove_last_extension_from_uri ⇒ Object
47 48 49 |
# File 'lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb', line 47 def remove_last_extension_from_uri asset.uri.to_s.split('.')[0..-2].join('.') end |
#timestamp_string ⇒ Object
Answer the timestamp string to add to this asset.
59 60 61 62 63 |
# File 'lib/cabeza-de-termo/assets-publisher/compilation-jobs/one-file-per-asset-builder.rb', line 59 def () return nil unless Time.now.to_s end |