imagebin 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +14 -0
- data/README.rdoc +17 -0
- data/Rakefile +60 -0
- data/VERSION.yml +4 -0
- data/bin/imagebin +81 -0
- data/bin/takeScreenshot.sh +18 -0
- data/lib/imagebin.rb +49 -0
- data/spec/ZGrass04.jpg +0 -0
- data/spec/imagebin_spec.rb +24 -0
- data/spec/spec_helper.rb +9 -0
- metadata +97 -0
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Copyright (C) 2009 dougsko
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= imagebin
|
2
|
+
|
3
|
+
imagebin is a CLI to http://imagebin.ca
|
4
|
+
Example: imagebin -f <pic.png>
|
5
|
+
|
6
|
+
Options:
|
7
|
+
-f, --file <file> Use a file for input
|
8
|
+
-n, --name [name] Name
|
9
|
+
-t, --tags [tags] Comma separated
|
10
|
+
-d, --description [description] Description
|
11
|
+
-p, --private Private
|
12
|
+
-l, --link Direct link to picture file
|
13
|
+
-h, --help Show this message
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2009 dougsko. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "imagebin"
|
8
|
+
gem.summary = %Q{Command line interface to imagebin.ca}
|
9
|
+
gem.email = "dougtko@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/dougsko/imagebin"
|
11
|
+
gem.authors = ["dougsko"]
|
12
|
+
gem.add_dependency 'httpclient'
|
13
|
+
gem.description = 'Command line interface to imagebin.ca'
|
14
|
+
gem.require_paths = ['/bin', '/lib']
|
15
|
+
gem.files = FileList["[A-Z]*", "{bin,generators,lib,spec}/**/*"]
|
16
|
+
gem.add_dependency "hpricot"
|
17
|
+
gem.add_dependency "httpclient"
|
18
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
|
+
end
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'spec/rake/spectask'
|
25
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
26
|
+
spec.libs << 'lib' << 'spec'
|
27
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
28
|
+
spec.spec_opts = ['--color']
|
29
|
+
end
|
30
|
+
|
31
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
32
|
+
spec.libs << 'lib' << 'spec'
|
33
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
34
|
+
spec.rcov = true
|
35
|
+
spec.spec_opts = ['--color']
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
require 'darkfish-rdoc'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
if File.exist?('VERSION.yml')
|
45
|
+
config = YAML.load(File.read('VERSION.yml'))
|
46
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
47
|
+
else
|
48
|
+
version = ""
|
49
|
+
end
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "imagebin #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
rdoc.options += [
|
56
|
+
'-N',
|
57
|
+
'-f', 'darkfish',
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
data/VERSION.yml
ADDED
data/bin/imagebin
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
#
|
4
|
+
# CLI to imagebin.ca
|
5
|
+
#
|
6
|
+
# Copyright (C) 2009 dougsko
|
7
|
+
#
|
8
|
+
# This program is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
#
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require 'optparse'
|
24
|
+
require 'imagebin'
|
25
|
+
|
26
|
+
options = { "t" => "file",
|
27
|
+
"name" => "",
|
28
|
+
"tags" => "",
|
29
|
+
"description" => "",
|
30
|
+
"adult" => "f",
|
31
|
+
"direct_link" => "0",
|
32
|
+
}
|
33
|
+
|
34
|
+
opts = OptionParser.new do |opts|
|
35
|
+
opts.banner = "imagebin is a CLI to http://imagebin.ca
|
36
|
+
Example: imagebin -f <pic.png>"
|
37
|
+
|
38
|
+
opts.separator ""
|
39
|
+
opts.separator "Options:"
|
40
|
+
|
41
|
+
opts.on("-f <file>", "--file <file>", String, "Use a file for input") do |file|
|
42
|
+
options["f"] = file
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("-n [name]", "--name [name]", String, "Name") do |n|
|
46
|
+
options["name"] = n
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on("-t [tags]", "--tags [tags]", String, "Comma separated") do |tags|
|
50
|
+
options["tags"] = tags
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on("-d [description]", "--description [description]", String, "Description") do |desc|
|
54
|
+
options["description"] = desc
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on("-p", "--private", "Private") do |priv|
|
58
|
+
options["adult"] = "t"
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.on("-l", "--link", "Direct link to picture file") do |direct_link|
|
62
|
+
options["direct_link"] = "1"
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
66
|
+
puts opts
|
67
|
+
exit
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
opts.parse(ARGV)
|
72
|
+
|
73
|
+
if options["direct_link"] == "0"
|
74
|
+
options.delete("direct_link")
|
75
|
+
ibin = Imagebin.new(options)
|
76
|
+
puts ibin.site_link
|
77
|
+
elsif options["direct_link"] == "1"
|
78
|
+
options.delete("direct_link")
|
79
|
+
ibin = Imagebin.new(options)
|
80
|
+
puts ibin.pic_link
|
81
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Location to save files
|
4
|
+
WORKINGDIR=$HOME/screenshots
|
5
|
+
# Default delay before taking screenshots
|
6
|
+
DELAY=3
|
7
|
+
#Prefix to use for images captured.
|
8
|
+
PREFIX=screenshot
|
9
|
+
|
10
|
+
# Check if the dir to store the screenshots exists, else create it:
|
11
|
+
if [ ! -d "${WORKINGDIR}" ]; then mkdir "${WORKINGDIR}"; fi
|
12
|
+
|
13
|
+
i=`ls -l $WORKINGDIR/$PREFIX*.png | wc -l`
|
14
|
+
((i = i+1))
|
15
|
+
|
16
|
+
sleep $DELAY
|
17
|
+
import -window root $WORKINGDIR/$PREFIX-$i.png
|
18
|
+
zenity --info --text=`imagebin -p -f $WORKINGDIR/$PREFIX-$i.png`
|
data/lib/imagebin.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# imagebin.ca class
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'httpclient'
|
8
|
+
require 'hpricot'
|
9
|
+
|
10
|
+
class Imagebin
|
11
|
+
# This method takes a hash containing the variables in the POST
|
12
|
+
# request.
|
13
|
+
#
|
14
|
+
# ibin = Imagebin.new( { "t" => "file",
|
15
|
+
# "name" => "",
|
16
|
+
# "tags" => "",
|
17
|
+
# "description" => "",
|
18
|
+
# "adult" => "f",
|
19
|
+
# "f" => "file_path",
|
20
|
+
# })
|
21
|
+
#
|
22
|
+
def initialize(options)
|
23
|
+
File.open(options["f"]) do |file|
|
24
|
+
options["f"] = file
|
25
|
+
clnt = HTTPClient.new
|
26
|
+
res = clnt.post('http://imagebin.ca/upload.php', options).content
|
27
|
+
@doc = Hpricot(res)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns the link to the HTML site of the post.
|
32
|
+
#
|
33
|
+
# ibin.site_link #=> "http://imagebin.ca/view/xxxxxxx.html"
|
34
|
+
#
|
35
|
+
def site_link
|
36
|
+
@doc.at("a").innerHTML
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns the direct link to the file posted.
|
40
|
+
#
|
41
|
+
# ibin.pic_link #=> "http://imagebin.ca/img/xxxxxxx.jpg"
|
42
|
+
#
|
43
|
+
def pic_link
|
44
|
+
clnt = HTTPClient.new
|
45
|
+
res = clnt.get(@doc.at("a").innerHTML).content
|
46
|
+
doc = Hpricot(res)
|
47
|
+
doc.at("#theimg")["src"]
|
48
|
+
end
|
49
|
+
end
|
data/spec/ZGrass04.jpg
ADDED
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Imagebin" do
|
4
|
+
before do
|
5
|
+
options = { "t" => "file",
|
6
|
+
"name" => "",
|
7
|
+
"tags" => "",
|
8
|
+
"description" => "",
|
9
|
+
"adult" => "t",
|
10
|
+
"f" => "spec/ZGrass04.jpg",
|
11
|
+
}
|
12
|
+
@ibin = Imagebin.new(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return a link to the paste's website" do
|
16
|
+
link = @ibin.site_link
|
17
|
+
link.should match(/html/)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return a link to the picture file" do
|
21
|
+
link = @ibin.pic_link
|
22
|
+
link.should match(/jpg/)
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: imagebin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dougsko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-11 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httpclient
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hpricot
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: httpclient
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
description: Command line interface to imagebin.ca
|
46
|
+
email: dougtko@gmail.com
|
47
|
+
executables:
|
48
|
+
- imagebin
|
49
|
+
- takeScreenshot.sh
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- LICENSE
|
54
|
+
- README.rdoc
|
55
|
+
files:
|
56
|
+
- LICENSE
|
57
|
+
- README.rdoc
|
58
|
+
- Rakefile
|
59
|
+
- VERSION.yml
|
60
|
+
- bin/imagebin
|
61
|
+
- bin/takeScreenshot.sh
|
62
|
+
- lib/imagebin.rb
|
63
|
+
- spec/ZGrass04.jpg
|
64
|
+
- spec/imagebin_spec.rb
|
65
|
+
- spec/spec_helper.rb
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: http://github.com/dougsko/imagebin
|
68
|
+
licenses: []
|
69
|
+
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options:
|
72
|
+
- --charset=UTF-8
|
73
|
+
require_paths:
|
74
|
+
- /bin
|
75
|
+
- /lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
81
|
+
version:
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: "0"
|
87
|
+
version:
|
88
|
+
requirements: []
|
89
|
+
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.3.5
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: Command line interface to imagebin.ca
|
95
|
+
test_files:
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
- spec/imagebin_spec.rb
|