jist 1.1.1.pre.2 → 1.1.1.pre.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/jist +1 -1
- data/lib/jist.rb +2 -29
- data/spec/clipboard_spec.rb +2 -2
- metadata +1 -1
data/bin/jist
CHANGED
@@ -99,7 +99,7 @@ opts.parse!
|
|
99
99
|
|
100
100
|
begin
|
101
101
|
if options[:paste]
|
102
|
-
puts Jist.gist(
|
102
|
+
puts Jist.gist(Clippy.paste, options)['html_url']
|
103
103
|
elsif ARGV.size == 0
|
104
104
|
$stderr.puts "(type a gist. <ctrl-c> to cancel, <ctrl-d> when done)" if $stdin.tty?
|
105
105
|
puts Jist.gist(ARGF.read, options)['html_url']
|
data/lib/jist.rb
CHANGED
@@ -7,15 +7,7 @@ require 'clippy'
|
|
7
7
|
module Jist
|
8
8
|
extend self
|
9
9
|
|
10
|
-
VERSION = '1.1.1.pre.
|
11
|
-
|
12
|
-
# A list of clipboard commands with copy and paste support.
|
13
|
-
CLIPBOARD_COMMANDS = {
|
14
|
-
'xclip' => 'xclip -o',
|
15
|
-
'xsel' => 'xsel -o',
|
16
|
-
'pbcopy' => 'pbpaste',
|
17
|
-
'putclip' => 'getclip'
|
18
|
-
}
|
10
|
+
VERSION = '1.1.1.pre.3'
|
19
11
|
|
20
12
|
# Exception tag for errors raised while gisting.
|
21
13
|
module Error; end
|
@@ -189,31 +181,12 @@ module Jist
|
|
189
181
|
def on_success(body, options={})
|
190
182
|
json = JSON.parse(body)
|
191
183
|
|
192
|
-
|
184
|
+
Clippy.copy(json['html_url']) if options[:copy]
|
193
185
|
Jist.open(json['html_url']) if options[:open]
|
194
186
|
|
195
187
|
json
|
196
188
|
end
|
197
189
|
|
198
|
-
# Copy a string to the clipboard.
|
199
|
-
#
|
200
|
-
# @param [String] content
|
201
|
-
# @raise [RuntimeError] if no clipboard integration could be found
|
202
|
-
#
|
203
|
-
# This method was heavily inspired by defunkt's Gist#copy,
|
204
|
-
# @see https://github.com/defunkt/gist/blob/bca9b29/lib/gist.rb#L178
|
205
|
-
def copy(content)
|
206
|
-
Clippy.copy(content)
|
207
|
-
end
|
208
|
-
|
209
|
-
# Get a string from the clipboard.
|
210
|
-
#
|
211
|
-
# @param [String] content
|
212
|
-
# @raise [RuntimeError] if no clipboard integration could be found
|
213
|
-
def paste
|
214
|
-
Clippy.paste(content)
|
215
|
-
end
|
216
|
-
|
217
190
|
# Find command from PATH environment.
|
218
191
|
#
|
219
192
|
# @param [String] cmd command name to find
|
data/spec/clipboard_spec.rb
CHANGED
@@ -16,7 +16,7 @@ describe '...' do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should try to copy the url when the clipboard option is passed' do
|
19
|
-
|
19
|
+
Clippy.should_receive(:copy).with(@bobo_url)
|
20
20
|
ask_for_copy
|
21
21
|
end
|
22
22
|
|
@@ -29,6 +29,6 @@ describe '...' do
|
|
29
29
|
ENV['PATH'] = ''
|
30
30
|
lambda{
|
31
31
|
ask_for_copy
|
32
|
-
}.should raise_error(/
|
32
|
+
}.should raise_error(/Clippy/)
|
33
33
|
end
|
34
34
|
end
|