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.1.0"

Class Method Summary collapse

Class Method Details

.copyObject



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

def self.copy
  data = copy_data_from_options

  unavailable = []
  plugins.each do |plugin|
    if plugin.available?
      return plugin.copy data
    else
      STDERR << plugin.unavailable_message + "\n"
    end
  end
end

.pasteObject



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

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

.pluginsObject



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

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