module Card::Env::Location
shared methods for handling paths/urls
Public Instance Methods
Source
# File lib/card/env/location.rb, line 6 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
card_path
makes a relative path site-absolute (if not already)
Source
# File lib/card/env/location.rb, line 19 def card_url rel rel.match?(/^https?:/) ? rel : "#{Env.origin}#{card_path rel}" end
card_url
makes it a full url (if not already)
Source
# File lib/card/env/location.rb, line 23 def cardname_from_url url return unless (cardname = cardname_from_url_regexp) m = url.match cardname m ? Card::Name[m[:mark]] : nil end
Source
# File lib/card/env/location.rb, line 30 def relative_url_root Cardio.config.relative_url_root end
Private Instance Methods
Source
# File lib/card/env/location.rb, line 36 def cardname_from_url_regexp return unless Env.origin.present? %r{#{Regexp.escape Env.origin}/(?<mark>[^?]+)} end