Sha256: 62a5ad938758bfe7c6e721880729bee4718f96e92d9a74df9c14ac18717dbdd4
Contents?: true
Size: 1.56 KB
Versions: 3
Compression:
Stored size: 1.56 KB
Contents
# coding: utf-8 # Platform is a centralized point to shell out platform specific functionality # like clipboard access or commands to open URLs. # # # Clipboard is a centralized point to shell out to each individual platform's # clipboard, pasteboard, or whatever they decide to call it. # module Boom class Platform class << self # Public: tests if currently running on darwin. # # Returns true if running on darwin (MacOS X), else false def darwin? !!(RUBY_PLATFORM =~ /darwin/) end # Public: returns the command used to open a file or URL # for the current platform. # # Currently only supports MacOS X and Linux with `xdg-open`. # # Returns a String with the bin def open_command darwin? ? 'open' : 'xdg-open' end # Public: opens a given Item's value in the browser. This # method is designed to handle multiple platforms. # # Returns a String explaining what was done def open(item) `#{open_command} '#{item.url.gsub("\'","\\'")}'` "Boom! We just opened #{item.value} for you." end # Public: copies a given Item's value to the clipboard. This method is # designed to handle multiple platforms. # # Returns a String explaining what was done def copy(item) copy_command = darwin? ? "pbcopy" : "xclip -selection clipboard" `echo '#{item.value.gsub("\'","\\'")}' | tr -d "\n" | #{copy_command}` "Boom! We just copied #{item.value} to your clipboard." end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
boom-0.1.1 | lib/boom/platform.rb |
boom-0.1.0 | lib/boom/platform.rb |
boom-0.0.10 | lib/boom/platform.rb |