Sha256: 67d3521cfc1065184caa7b7c8a1a6bb16389c88de66de9ecdb0c07f53c9eb1b6

Contents?: true

Size: 814 Bytes

Versions: 23

Compression:

Stored size: 814 Bytes

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 =~ %r{^(https?\:)?/}
          rel_path
        else
          "#{Card.config.relative_url_root}/#{rel_path}"
        end
      end

      def card_url rel
        rel =~ /^https?\:/ ? rel : "#{protocol_and_host}#{card_path rel}"
      end

      def protocol_and_host
        Card.config.protocol_and_host || "#{Card::Env[:protocol]}#{Card::Env[:host]}"
      end

      extend Location # ??
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
card-1.99.5 lib/card/env/location.rb
card-1.99.4 lib/card/env/location.rb
card-1.99.3 lib/card/env/location.rb
card-1.99.2 lib/card/env/location.rb
card-1.99.1 lib/card/env/location.rb
card-1.99.0 lib/card/env/location.rb
card-1.98.3 lib/card/env/location.rb
card-1.98.2 lib/card/env/location.rb
card-1.98.1 lib/card/env/location.rb
card-1.98.0 lib/card/env/location.rb
card-1.97.0.1 lib/card/env/location.rb
card-1.97.0 lib/card/env/location.rb
card-1.96.8 lib/card/env/location.rb
card-1.96.7 lib/card/env/location.rb
card-1.96.6 lib/card/env/location.rb
card-1.96.5 lib/card/env/location.rb
card-1.96.4 lib/card/env/location.rb
card-1.96.3 lib/card/env/location.rb
card-1.96.2 lib/card/env/location.rb
card-1.96.1 lib/card/env/location.rb