Module: Nwcopy

Defined in:
lib/nwcopy.rb,
lib/nwcopy/gist.rb,
lib/nwcopy/client.rb,
lib/nwcopy/dropbox.rb,
lib/nwcopy/version.rb

Defined Under Namespace

Classes: Client, Dropbox, Gist

Constant Summary collapse

VERSION =
"0.0.6"

Class Method Summary collapse

Class Method Details

.copyObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nwcopy.rb', line 15

def self.copy
  data = read_data
  unavailable = []
  plugins.each do |plugin|
    if plugin.available?
      return plugin.copy data
    else
      STDERR << plugin.unavailable_message
    end
  end
end

.pasteObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/nwcopy.rb', line 27

def self.paste
  unavailable = []
  plugins.each do |plugin|
    if plugin.available?
      if clipboard = plugin.paste
        `echo "#{clipboard}" | pbcopy` unless `which pbcopy`.empty?
        return clipboard
      end
    else
      STDERR << plugin.unavailable_message
    end
  end
end

.pluginsObject



11
12
13
# File 'lib/nwcopy.rb', line 11

def self.plugins
  [Nwcopy::Client, Nwcopy::Dropbox, Nwcopy::Gist]
end