imagebin 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION.yml +1 -1
  2. data/bin/take-screenshot +11 -3
  3. data/lib/imagebin.rb +12 -3
  4. metadata +1 -1
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 3
4
- :patch: 5
4
+ :patch: 6
@@ -5,6 +5,9 @@
5
5
  # Requires: imagemagick, xmessage, and the imagebin script
6
6
  #
7
7
 
8
+ require 'rubygems'
9
+ require 'imagebin'
10
+
8
11
  # Location to save files
9
12
  working_dir = "/tmp"
10
13
  # Default delay before taking screenshots
@@ -13,7 +16,6 @@ delay = 3
13
16
  prefix = "screenshot"
14
17
  import = `which import`.chomp
15
18
  xmess = `which xmessage`.chomp
16
- imagebin = `which imagebin`.chomp
17
19
 
18
20
  # Check if the dir to store the screenshots exists, else create it:
19
21
  Dir.mkdir(working_dir) if not File.exists?(working_dir)
@@ -21,8 +23,14 @@ Dir.mkdir(working_dir) if not File.exists?(working_dir)
21
23
  i = Dir.glob("#{working_dir}/#{prefix}.png").size + 1
22
24
 
23
25
  sleep delay
26
+
27
+ # Take the screenshot with the 'import' command.
24
28
  system("#{import}", "-window", "root", "#{working_dir}/#{prefix}-#{i}.png")
25
- link = `#{imagebin} -p -l -f #{working_dir}/#{prefix}-#{i}.png`
26
- system("#{xmess}", "-nearmouse", "#{link}")
29
+
30
+ ibin = Imagebin.new({ "f" => "#{working_dir}/#{prefix}-#{i}.png",
31
+ "adult" => "t",
32
+ })
33
+
34
+ system("#{xmess}", "-nearmouse", "#{ibin.pic_link}")
27
35
 
28
36
  File.delete("#{working_dir}/#{prefix}-#{i}.png")
@@ -20,10 +20,19 @@ class Imagebin
20
20
  # })
21
21
  #
22
22
  def initialize(options)
23
- File.open(options["f"]) do |file|
24
- options["f"] = file
23
+ @options = { "t" => "file",
24
+ "name" => "",
25
+ "tags" => "",
26
+ "description" => "",
27
+ "adult" => "f",
28
+ "direct_link" => "0",
29
+ "f" => "",
30
+ }
31
+ @options.merge!(options)
32
+ File.open(@options["f"]) do |file|
33
+ @options["f"] = file
25
34
  clnt = HTTPClient.new
26
- res = clnt.post('http://imagebin.ca/upload.php', options).content
35
+ res = clnt.post('http://imagebin.ca/upload.php', @options).content
27
36
  @doc = Hpricot(res)
28
37
  end
29
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imagebin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - dougsko