imgur2 1.0.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/.autotest ADDED
@@ -0,0 +1,8 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ Autotest.add_hook :initialize do |at|
6
+ at.testlib = 'minitest/autorun'
7
+ at.find_directories = ARGV unless ARGV.empty?
8
+ end
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2011-03-10
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ .autotest
2
+ CHANGELOG.rdoc
3
+ Manifest.txt
4
+ README.rdoc
5
+ Rakefile
6
+ bin/imgur2
7
+ lib/imgur2.rb
data/README.rdoc ADDED
@@ -0,0 +1,58 @@
1
+ = imgur2
2
+
3
+ * http://github.com/tenderlove/imgur2
4
+
5
+ == DESCRIPTION:
6
+
7
+ Upload stuff to imgur. Yay.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Only supports ruby 1.9
12
+
13
+ == SYNOPSIS:
14
+
15
+ In code:
16
+
17
+ client = Imgur2.new 'my imgur key'
18
+ p File.open(ARGV[0], 'rb') { |f|
19
+ client.upload f
20
+ }
21
+
22
+ From the command line:
23
+
24
+ $ imgur2 somefile.jpg
25
+ $ meme Y_U_NO 'keep images around?' | imgur2
26
+
27
+ == REQUIREMENTS:
28
+
29
+ * Ruby 1.9
30
+
31
+ == INSTALL:
32
+
33
+ * gem install imgur2
34
+
35
+ == LICENSE:
36
+
37
+ (The MIT License)
38
+
39
+ Copyright (c) 2011 Aaron Patterson
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining
42
+ a copy of this software and associated documentation files (the
43
+ 'Software'), to deal in the Software without restriction, including
44
+ without limitation the rights to use, copy, modify, merge, publish,
45
+ distribute, sublicense, and/or sell copies of the Software, and to
46
+ permit persons to whom the Software is furnished to do so, subject to
47
+ the following conditions:
48
+
49
+ The above copyright notice and this permission notice shall be
50
+ included in all copies or substantial portions of the Software.
51
+
52
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
53
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
54
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
55
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
56
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
57
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
58
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.plugin :git # `gem install hoe-git`
7
+
8
+ Hoe.spec 'imgur2' do
9
+ developer('Aaron Patterson', 'aaron@tenderlovemaking.com')
10
+ self.readme_file = 'README.rdoc'
11
+ self.history_file = 'CHANGELOG.rdoc'
12
+ self.extra_rdoc_files = FileList['*.rdoc']
13
+ required_ruby_version = '>= 1.9.2'
14
+ end
15
+
16
+ # vim: syntax=ruby
data/bin/imgur2 ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/local/bin/ruby19
2
+
3
+ require 'imgur2'
4
+
5
+ Imgur2.run ARGV
6
+
data/lib/imgur2.rb ADDED
@@ -0,0 +1,50 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ ###
5
+ # Stupid simple class for uploading to imgur.
6
+ #
7
+ # client = Imgur2.new 'my imgur key'
8
+ # p File.open(ARGV[0], 'rb') { |f|
9
+ # client.upload f
10
+ # }
11
+ class Imgur2 < Struct.new(:key)
12
+ VERSION = '1.0.0'
13
+
14
+ def self.run argv
15
+ client = Imgur2.new '65aea9a07b4f6110c90248ffa247d41a'
16
+ fh = argv[0] ? File.open(argv[0], 'rb') : $stdin
17
+ link = client.upload(fh)['upload']['links']['original']
18
+ client.paste link
19
+ puts link
20
+ ensure
21
+ fh.close
22
+ end
23
+
24
+ def upload io
25
+ url = URI.parse 'http://api.imgur.com/2/upload.json'
26
+
27
+ JSON.parse Net::HTTP.start(url.host) { |http|
28
+ post = Net::HTTP::Post.new url.path
29
+ post.set_form_data('key' => key,
30
+ 'image' => [io.read].pack('m'),
31
+ 'type' => 'base64')
32
+ http.request(post).body
33
+ }
34
+ end
35
+
36
+ ##
37
+ # Tries to find clipboard copy executable and if found puts +link+ in your
38
+ # clipboard.
39
+
40
+ def paste link
41
+ clipboard = %w{
42
+ /usr/bin/pbcopy
43
+ /usr/bin/xclip
44
+ }.find { |path| File.exist? path }
45
+
46
+ if clipboard
47
+ IO.popen clipboard, 'w' do |io| io.write link end
48
+ end
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: imgur2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aaron Patterson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-03-10 00:00:00.000000000 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ requirement: &2151870680 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 2.9.1
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *2151870680
26
+ description: Upload stuff to imgur. Yay.
27
+ email:
28
+ - aaron@tenderlovemaking.com
29
+ executables:
30
+ - imgur2
31
+ extensions: []
32
+ extra_rdoc_files:
33
+ - Manifest.txt
34
+ - CHANGELOG.rdoc
35
+ - README.rdoc
36
+ files:
37
+ - .autotest
38
+ - CHANGELOG.rdoc
39
+ - Manifest.txt
40
+ - README.rdoc
41
+ - Rakefile
42
+ - bin/imgur2
43
+ - lib/imgur2.rb
44
+ has_rdoc: true
45
+ homepage: http://github.com/tenderlove/imgur2
46
+ licenses: []
47
+ post_install_message:
48
+ rdoc_options:
49
+ - --main
50
+ - README.rdoc
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project: imgur2
67
+ rubygems_version: 1.6.1
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Upload stuff to imgur
71
+ test_files: []