Sha256: fb330bc263725110e4a199d16bae120cc64916152710e6a30b2c546e5f157d47

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

# frozen_string_literal: true

module Scrapbook
  # View helpers for the Scrapbook gem. Doesn't use standard Rail's helper
  # modules to avoid any conflicts with host app
  class HelperForView
    def initialize(view)
      self.view = view
    end

    def short_path_to(pathname, scrapbook = nil)
      scrapbook ||= Scrapbook.find_scrapbook_for(pathname)

      view.short_page_path(scrapbook.relative_page_path_for(pathname)).gsub(/%2F/i, '/')
    end

    def remove_handler_exts_from(pathname)
      pathname.dirname.join(
        pathname.basename.sub(/(?:.#{view.lookup_context.handlers.join('|.')})+\z/, '')
      )
    end

    private

    attr_accessor :view
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scrapbook-0.2.0 app/helpers/scrapbook/helper_for_view.rb