Sha256: ead0ab0d080d2d24955c5c751350ddd7edbe1d94f8c29f770127eaf51dc1cf83
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
require 'rbconfig' require File.dirname(__FILE__) + '/clipboard/version' module Clipboard extend self class ClipboardLoadError < Exception end unless defined? Ocra # see gh#9 autoload :Linux, 'clipboard/linux' autoload :Mac, 'clipboard/mac' autoload :Java, 'clipboard/java' autoload :Cygwin, 'clipboard/cygwin' autoload :Wsl, 'clipboard/wsl' end autoload :Windows, 'clipboard/windows' autoload :File, 'clipboard/file' def self.implementation return @implementation if @implementation os = case RbConfig::CONFIG['host_os'] when /mac|darwin/ then :Mac when /linux|bsd/ then :Linux when /mswin|mingw/ then :Windows when /cygwin/ then :Cygwin else raise ClipboardLoadError, "Your OS(#{ RbConfig::CONFIG['host_os'] }) is not supported, using file-based (fake) clipboard" end # Running additional check to detect if running in Microsoft WSL if os == :Linux require "etc" if Etc.uname[:release] =~ /Microsoft/ os = :Wsl end end @implementation = Clipboard.const_get(os) rescue ClipboardLoadError => e $stderr.puts e.message if $VERBOSE @implementation = Clipboard::File end def self.implementation=(val) @implementation = val end def paste(*args) Clipboard.implementation.paste(*args) end def clear(*args) Clipboard.implementation.clear(*args) end def copy(*args) Clipboard.implementation.copy(*args) end end Clipboard.implementation
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clipboard-1.2.1 | lib/clipboard.rb |