filebin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 dougsko
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ = filebin
2
+
3
+ filebin is a CLI to http://filebin.ca
4
+ Example: filebin -f <pic.png>
5
+
6
+ Options:
7
+ -f, --file <file> Path to file
8
+ -h, --help Show this message
9
+
10
+ == Copyright
11
+
12
+ Copyright (c) 2009 dougsko. See LICENSE for details.
@@ -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 = "filebin"
8
+ gem.summary = %Q{Command line interface to filebin.ca}
9
+ gem.email = "dougtko@gmail.com"
10
+ gem.homepage = "http://github.com/dougsko/filebin"
11
+ gem.authors = ["dougsko"]
12
+ gem.add_dependency 'httpclient'
13
+ gem.description = 'Command line interface to filebin.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 = "filebin #{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 ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ #
4
+ # CLI to filebin.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 'filebin'
25
+
26
+ options = {}
27
+
28
+ opts = OptionParser.new do |opts|
29
+ opts.banner = "filebin is a CLI to http://filebin.ca
30
+ Example: filebin -f <pic.png>"
31
+
32
+ opts.separator ""
33
+ opts.separator "Options:"
34
+
35
+ opts.on("-f <file>", "--file <file>", String, "Use a file for input") do |file|
36
+ options["path"] = file
37
+ end
38
+
39
+ opts.on_tail("-h", "--help", "Show this message") do
40
+ puts opts
41
+ exit
42
+ end
43
+ end
44
+
45
+ opts.parse(ARGV)
46
+
47
+ fbin = Filebin.new(options)
48
+ puts fbin.link
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # filebin.ca class
4
+ #
5
+
6
+ require 'rubygems'
7
+ require 'httpclient'
8
+ require 'hpricot'
9
+
10
+ class Filebin
11
+ attr_reader :link
12
+ # This method takes a hash containing the variables in the POST
13
+ # request.
14
+ #
15
+ # fbin = Filebin.new({ "path" => "file_path"})
16
+ #
17
+ def initialize(options)
18
+ options["MAX_FILE_SIZE"] = "82428800"
19
+
20
+ # Get UPLOAD_IDENTIFIER
21
+ clnt = HTTPClient.new
22
+ res = clnt.get('http://filebin.ca').content
23
+ doc = Hpricot(res)
24
+ options["UPLOAD_IDENTIFIER"] = doc.at("//div[@id='form']/fieldset/form/input[2]")['value']
25
+
26
+ # Upload file
27
+ File.open(options["path"]) do |file|
28
+ options["file"] = file
29
+ options.delete("path")
30
+ clnt = HTTPClient.new
31
+ res = clnt.post('http://filebin.ca/upload.php', options).content
32
+ doc = Hpricot(res)
33
+ end
34
+
35
+ doc.inner_html.match(/file is available at (.*)\n/)
36
+ @link = $1
37
+ end
38
+ end
@@ -0,0 +1,8 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Filebin" do
4
+ it "uploads a file" do
5
+ fbin = Filebin.new("path" => __FILE__)
6
+ fbin.link.should match(/filebin_spec.rb/)
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require 'filebin'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: filebin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - dougsko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-08 00:00:00 -05:00
13
+ default_executable: filebin
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 filebin.ca
46
+ email: dougtko@gmail.com
47
+ executables:
48
+ - filebin
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - README.rdoc
54
+ files:
55
+ - LICENSE
56
+ - README.rdoc
57
+ - Rakefile
58
+ - VERSION
59
+ - bin/filebin
60
+ - lib/filebin.rb
61
+ - spec/filebin_spec.rb
62
+ - spec/spec_helper.rb
63
+ has_rdoc: true
64
+ homepage: http://github.com/dougsko/filebin
65
+ licenses: []
66
+
67
+ post_install_message:
68
+ rdoc_options:
69
+ - --charset=UTF-8
70
+ require_paths:
71
+ - /bin
72
+ - /lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ requirements: []
86
+
87
+ rubyforge_project:
88
+ rubygems_version: 1.3.4
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Command line interface to filebin.ca
92
+ test_files:
93
+ - spec/filebin_spec.rb
94
+ - spec/spec_helper.rb