splat

small gem to provide an adapter for various platform specific features.

This is done by adding the following methods to String:

  • to_editor

  • to_browser

  • to_clipboard

  • to_speech

  • to_launcher

  • to_player

  • to_os_path

installation

gem install splat

load

require 'splat'

launch editor

'current content'.to_editor

browser automation

'http://www.google.com'.to_browser

Returns a watir compatible browser - uses safariwatir on mac os x and watir (ie) on windows.

clipboard

'some new content'.to_clipboard

Copies the string to the os clipboard

default application launcher

'http://google.com'.to_launcher
'textfile.txt'.to_launcher
'audiofile.mp3'.to_launcher

Launches the referenced content with the default system application

audio player

'audio.mp3'.to_player

Uses ‘afplay’ on mac os x and requires mpg123 on windows.

text to speech

"I'm afraid. I'm afraid, Dave. Dave, my mind is going.".to_speech

Uses ‘say’ on mac os x and win32 sapi on windows

path cleaning

'c:/a/path/that/might/upset/some/windows.application'.to_os_path

This will simply replace ‘/’ characters with ‘' on windows and otherwise leave the path as is.

Note that this is only necessary for passing a path to native windows applications

Future plans for world domination

  • detect remaining platforms

  • determine 1.9 compatibility