Sha256: ec79cc26a557efabf27714342d92f65343e8201e8b0dd6ceb9a3c642aa93a5d2

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

module Hobo
  class << self
    attr_accessor :asset_applicators

    # Utility method to access (with initialization) the asset applicator registry.
    # This allows you to register new asset applicator methods on a per-project basis.
    # For example:
    #
    #     Hobo.asset_applicators.register /.*\.zip/ do |file|
    #       Dir.chdir File.dirname(file) do
    #         shell "unzip", file
    #       end
    #     end
    #
    # @see Hobo::AssetApplicatorRegistry
    # @return [Hobo::AssetApplicatorRegistry] Applicator registry cotnainer
    def asset_applicators
      @asset_applicators ||= AssetApplicatorRegistry.new
    end
  end

  private

  # Thin wrapper over a hash to provide a means to "register" asset applicators
  class AssetApplicatorRegistry < Hash
    # Register a new asset applicator
    # @param [Regexp] Pattern to match against asset filename.
    # @yield The block to be executed when an asset matches the pattern.
    def register pattern, &block
      self[pattern] = block
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hobo-inviqa-0.0.15 lib/hobo/asset_applicator.rb
hobo-inviqa-0.0.14 lib/hobo/asset_applicator.rb
hobo-inviqa-0.0.13 lib/hobo/asset_applicator.rb
hobo-inviqa-0.0.11 lib/hobo/asset_applicator.rb
hobo-inviqa-0.0.10 lib/hobo/asset_applicator.rb
hobo-inviqa-0.0.10.pre.rc11 lib/hobo/asset_applicator.rb
hobo-inviqa-0.0.10.pre.rc10 lib/hobo/asset_applicator.rb
hobo-inviqa-0.0.10.pre.rc9 lib/hobo/asset_applicator.rb