Sha256: fab424858ee4361699d9802cf18b7c3bd73467f8107e95b3714e73b6d5e1c781

Contents?: true

Size: 620 Bytes

Versions: 6

Compression:

Stored size: 620 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(/\/samples\/\S*\.[a-zA-Z0-9]+/) do |match|
        url = __content_assets_pusher__.persist(match)
        url || match
      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

6 entries across 6 versions & 1 rubygems

Version Path
locomotivecms_wagon-2.2.0.beta1 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.1.1 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.1.0 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.1.0.rc5 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.1.0.rc4 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb
locomotivecms_wagon-2.1.0.rc3 lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb