Project

media-path

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
MediaPath abstraction that provides easier interaction with paths and corresponding URLs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

About

Installation

  • Prerelease: gem install media-path --prerelease
  • Stable Version: gem install media-path

Setup

MediaMediaPath.media_root = "public"

Rewriting rules

MediaMediaPath.rewrite { |path| "http://media.domain.org/#{path}" }
MediaMediaPath.rewrite { |path| path.tr("_", "-") }

Usage

path = MediaMediaPath.new("public/javascripts/mootools-core.js")

path.relative
# => "public/javascripts/mootools-core.js"

path.absolute
# => "/Users/botanicus/projects/webs/myproject/public/javascripts/mootools-core.js"

path.server
# => "/javascripts/mootools-core.js"

Links

- Source Code
- RunCodeRun
- API Documentation