Trim¶ ↑
Description¶ ↑
The trim gem is a wrapper for the tr.im URL shortening service, which can be found at tr.im/
This software is not affiliated with tr.im in any way. tr.im is a product of The Nambu Network: www.nambu.com/.
Installation¶ ↑
First, if you do not already have GitHub in your gem sources, execute the following command to add it:
sudo gem sources -a http://gems.github.com
Then you can install this gem with:
sudo gem install svenaas-trim
If you prefer not to add GitHub to your gem sources, install via:
sudo gem install svenaas-trim -s http://gems.github.com
Windows users should omit the sudo, of course.
Usage¶ ↑
require 'trim' Trim.trim('http://www.google.com') # Returns trimmed URL, or nil if any error occurs
If you want to use an account that tr.im knows about you can provide your valid username and password:
Trim.trim('http://www.google.com', 'username', 'password')
NOTE: as of this writing (3 Mar 2009) tr.im does not support SSL so this username and password will be sent over unencrypted HTTP.
Testing¶ ↑
The standard tests run via
rake test
use mock code to verify functionality instead of depending on online interaction with tr.im’s servers. This is done for several reasons, primarily because the service provider deserves this basic consideration, but also because tr.im limits the number of URLs which can be shortened during a particular amount of time.
If you need to verify online functionality you can run
rake test:online
for simple-case testing that the servers are reachable via the expected address and API. Please note that this test consumes online resources, and use it sparingly.
License¶ ↑
Copyright © 2009 Sven Aas
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.