Sha256: fca3835b84a5cfebd1f76f6e32887cfada248ce944f39863eb6c59fb0445284a

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

module Clipboard
  extend self

  VERSION = File.read( (File.dirname(__FILE__) + '/../VERSION') ).chomp

  class ClipboardLoadError < Exception
  end

  autoload :Linux,   'clipboard/linux'
  autoload :Mac,     'clipboard/mac'
  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|cygwin/  then :Linux
    when /mswin|mingw/       then :Windows
    # when /solaris|sunos/     then :Linux # needs testing..
    else
      raise ClipboardLoadError, "Your OS(#{ RbConfig::CONFIG['host_os'] }) is not supported, using file-based (fake) clipboard"
    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 # TODO remove this?

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
clipboard-0.9.8 lib/clipboard.rb
clipboard-0.9.7 lib/clipboard.rb
clipboard-0.9.6 lib/clipboard.rb
clipboard-0.9.5 lib/clipboard.rb