class CabezaDeTermo::AssetsPublisher::Publisher
The collector and publisher of the stylesheets and javascripts from the current view.
Constants
- VERSION
Public Class Methods
clock_card_machine()
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 35 def clock_card_machine() @clock_card_machine end
configuration()
click to toggle source
Answer the Publihser configuration
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 26 def configuration() configurations_per_thread[::Thread.current] end
configuration_prototype()
click to toggle source
Answer the Publihser configuration
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 44 def configuration_prototype() @configuration_prototype ||= default_configuration end
configurations_per_thread()
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 39 def configurations_per_thread() @configurations_per_thread end
configure(&block)
click to toggle source
Pass the config to the block to allow the app to configure the Publisher
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 31 def configure(&block) CdT.bind_block_evaluation_to configuration_prototype, &block end
default_configuration()
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 52 def default_configuration() CdT.bind_block_evaluation_to(Configuration.new) do add_timestamps_to_published_assets true stylesheets_compiler { TiltCompiler.new } javascripts_compiler { TiltCompiler.new } use_rendering_scope_assets_collector CabezaDeTermo::Assets::HanamiRenderingScope self end end
reset_configuration_prototype()
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 48 def reset_configuration_prototype() @configuration_prototype = nil end
Public Instance Methods
javascripts_for(rendering_scope)
click to toggle source
Collect and publish the javascripts from the rendering_scope. Answer the html to include in your template.
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 78 def javascripts_for(rendering_scope) with_configuration_copy do compile_and_build_html_for(JavascriptType.new, rendering_scope) end end
stylesheets_for(rendering_scope)
click to toggle source
Collect and publish the stylesheets from the rendering_scope. Answer the html to include in your template.
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 70 def stylesheets_for(rendering_scope) with_configuration_copy do compile_and_build_html_for(StylesheetType.new, rendering_scope) end end
Protected Instance Methods
assets_for(asset_type, rendering_scope)
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 122 def assets_for(asset_type, rendering_scope) asset_type.collect_assets_from(rendering_scope) end
clock_card_machine()
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 126 def clock_card_machine() self.class.clock_card_machine end
compilation_jobs_for(asset_type, assets)
click to toggle source
Create and answer a new comopilation job
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 118 def compilation_jobs_for(asset_type, assets) OneFilePerAssetBuilder.jobs_for asset_type, assets end
compile(compilation_job, asset_type)
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 103 def compile(compilation_job, asset_type) return unless clock_card_machine.is_outdated? compilation_job compilation_job.compile_with(asset_type.compiler) clock_card_machine.register_modifications_on compilation_job end
compile_and_build_html_for(asset_type, rendering_scope)
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 86 def compile_and_build_html_for(asset_type, rendering_scope) compile_assets_and_build_html_for asset_type, assets_for(asset_type, rendering_scope) end
compile_assets_and_build_html_for(asset_type, assets)
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 90 def compile_assets_and_build_html_for(asset_type, assets) jobs = compilation_jobs_for(asset_type, assets) compile_jobs(asset_type, jobs) jobs_html(jobs) end
compile_jobs(asset_type, compilation_jobs)
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 97 def compile_jobs(asset_type, compilation_jobs) compilation_jobs.each do |job| compile(job, asset_type) end end
jobs_html(compilation_jobs)
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 111 def jobs_html(compilation_jobs) compilation_jobs.inject('') do |html, compilation_job| html += compilation_job.html end end
with_configuration_copy(&block)
click to toggle source
# File lib/cabeza-de-termo/assets-publisher/publisher.rb, line 130 def with_configuration_copy(&block) begin self.class.configurations_per_thread[::Thread.current] = self.class.configuration_prototype.dup block.call ensure self.class.configurations_per_thread.delete(::Thread.current) end end