hansengel-grabnix 1.0
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/grabnix +5 -0
- data/lib/grabnix.rb +56 -0
- metadata +55 -0
data/bin/grabnix
ADDED
data/lib/grabnix.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'timeout'
|
3
|
+
|
4
|
+
class GrabNix
|
5
|
+
def initialize
|
6
|
+
check_binaries
|
7
|
+
@time = Time.now.to_i.to_s
|
8
|
+
@dir = get_tmp_path
|
9
|
+
kapow
|
10
|
+
exit 0
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def check_binaries
|
16
|
+
`which xclip`
|
17
|
+
if $?.exitstatus == 1
|
18
|
+
# xclip isn't in da haus
|
19
|
+
raise "xclip doesn't exist. try `sudo apt-get install xclip`."
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
`which import`
|
23
|
+
if $?.exitstatus == 1
|
24
|
+
raise "import doesn't exist. try `sudo apt-get install imagemagick`."
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_tmp_path
|
31
|
+
t = Tempfile.new 'grabnix'
|
32
|
+
tmpdir = File.dirname(t.path)
|
33
|
+
t.delete
|
34
|
+
tmpdir
|
35
|
+
end
|
36
|
+
|
37
|
+
def kapow
|
38
|
+
# this is the good stuff
|
39
|
+
img = @dir + '/' + @time + '.jpg'
|
40
|
+
`import -quality 100 #{img}`
|
41
|
+
req = `curl -si -F userfile=@#{img} -F app_upload=Upload http://www.grabup.com/app_upload.php`
|
42
|
+
File.delete(img)
|
43
|
+
url = /Location: (.+)/.match(req)
|
44
|
+
set_clipboard url[1]
|
45
|
+
end
|
46
|
+
|
47
|
+
def set_clipboard(value)
|
48
|
+
begin
|
49
|
+
Timeout::timeout(0.4) do
|
50
|
+
`echo -n #{value} | xclip -i -silent`
|
51
|
+
end
|
52
|
+
rescue Timeout::Error
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hansengel-grabnix
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "1.0"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hans Engel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-03 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: spam.me@engel.uk.to
|
18
|
+
executables:
|
19
|
+
- grabnix
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/grabnix.rb
|
26
|
+
- bin/grabnix
|
27
|
+
has_rdoc: false
|
28
|
+
homepage:
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
- bin
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: "0"
|
40
|
+
version:
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
requirements: []
|
48
|
+
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.2.0
|
51
|
+
signing_key:
|
52
|
+
specification_version: 2
|
53
|
+
summary: grabUp for Linux users!
|
54
|
+
test_files: []
|
55
|
+
|