Sha256: 7eb4870acb0bd9190db91b4e1b9653e4c98fe967830ea4aa75945a7ab50b8ac4
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
class Card module Env module Location # card_path makes a relative path site-absolute (if not already) # card_url makes it a full url (if not already) def card_path rel_path unless rel_path.is_a? String Rails.logger.warn "Pass only strings to card_path. "\ "(#{rel_path} = #{rel_path.class})" end if rel_path.match? %r{^(https?:)?/} rel_path else "#{relative_url_root}/#{rel_path}" end end def card_url rel rel.match?(/^https?:/) ? rel : "#{Env.origin}#{card_path rel}" end def cardname_from_url url return unless (cardname = cardname_from_url_regexp) m = url.match cardname m ? Card::Name[m[:mark]] : nil end def relative_url_root Cardio.config.relative_url_root end private def cardname_from_url_regexp return unless Env.origin %r{#{Regexp.escape Env.origin}/(?<mark>[^?]+)} end extend Location # allows calls on Location constant, eg Location.card_url end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
card-1.104.2 | lib/card/env/location.rb |