Sha256: 2c45a12517d8f0818cd656b918d80be5857257df8187e2573afd6730e12f763a

Contents?: true

Size: 627 Bytes

Versions: 10

Compression:

Stored size: 627 Bytes

Contents

require_relative '../../tools/yaml_ext.rb'

module Locomotive::Wagon

  module PersistAssetsConcern

    def replace_with_content_assets!(text)
      return text if text.blank?

      text.to_s.gsub(/([^a-zA-Z0-9])(\/samples\/\S*\.[a-zA-Z0-9]+)/) do
        url = __content_assets_pusher__.persist($2) || $2
        $1 + url
      end
    end

    def replace_with_content_assets_in_hash!(hash)
      Locomotive::Wagon::YamlExt.transform(hash) do |value|
        replace_with_content_assets!(value)
      end
    end

    def asset_io(local_path)
      __content_assets_pusher__.decorate(local_path).source
    end

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
locomotivecms_wagon-2.4.1 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.4.0 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.4.0.rc2 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.4.0.rc1 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.3.0 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.3.0.rc1 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.2.0 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.2.0.rc3 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.2.0.rc2 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.2.0.rc1 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb