filebin 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
@@ -36,6 +36,11 @@ opts = OptionParser.new do |opts|
36
36
  options["path"] = file
37
37
  end
38
38
 
39
+ options["short"] = false
40
+ opts.on("-s", "--short", "Return a shortend URL") do |short|
41
+ options["short"] = true
42
+ end
43
+
39
44
  opts.on_tail("-h", "--help", "Show this message") do
40
45
  puts opts
41
46
  exit
@@ -44,5 +49,12 @@ end
44
49
 
45
50
  opts.parse(ARGV)
46
51
 
47
- fbin = Filebin.new(options)
48
- puts fbin.link
52
+ if options["short"]
53
+ options.delete("short")
54
+ fbin = Filebin.new(options)
55
+ puts fbin.short_link
56
+ else
57
+ options.delete("short")
58
+ fbin = Filebin.new(options)
59
+ puts fbin.link
60
+ end
@@ -5,6 +5,7 @@
5
5
 
6
6
  require 'rubygems'
7
7
  require 'httpclient'
8
+ require 'net/http'
8
9
  require 'hpricot'
9
10
 
10
11
  class Filebin
@@ -35,4 +36,14 @@ class Filebin
35
36
  doc.inner_html.match(/file is available at (.*)\n/)
36
37
  @link = $1
37
38
  end
39
+
40
+ def short_link
41
+ headers = {'Content-Type' => 'text/xml'}
42
+ xml = "<link><website_url>#{@link}</website_url></link>"
43
+ res = Net::HTTP.start('rubyurl.com') do |http|
44
+ http.post("/api/links", xml, headers)
45
+ end
46
+ doc = Hpricot(res.body)
47
+ doc.at('/permalink').inner_html
48
+ end
38
49
  end
@@ -1,8 +1,13 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Filebin" do
4
- it "uploads a file" do
4
+ it "uploads a file and returns a link" do
5
5
  fbin = Filebin.new("path" => __FILE__)
6
6
  fbin.link.should match(/filebin_spec.rb/)
7
7
  end
8
+
9
+ it "returns a shortened verison of the link" do
10
+ fbin = Filebin.new("path" => __FILE__)
11
+ fbin.short_link.should match(/rubyurl.com\/\w+/)
12
+ end
8
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filebin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dougsko
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-08 00:00:00 -05:00
12
+ date: 2009-12-20 00:00:00 -05:00
13
13
  default_executable: filebin
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  requirements: []
86
86
 
87
87
  rubyforge_project:
88
- rubygems_version: 1.3.4
88
+ rubygems_version: 1.3.5
89
89
  signing_key:
90
90
  specification_version: 3
91
91
  summary: Command line interface to filebin.ca