vanntastic-imgur 0.2.0 → 0.3.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.
Files changed (3) hide show
  1. data/.gitignore +1 -0
  2. data/README.rdoc +35 -12
  3. metadata +2 -2
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ coverage
4
4
  rdoc
5
5
  pkg
6
6
  *.gemspec
7
+ *.gem
data/README.rdoc CHANGED
@@ -8,19 +8,42 @@ A simple ruby interface to the imgur image hosting service (http://imgur.com). T
8
8
 
9
9
  == Examples
10
10
 
11
- # Uploading an image to imgur from the filesystem
11
+ # Uploading an image to imgur from the filesystem
12
+
13
+ img = Imgur::API.new 'YOURAPIKEY'
14
+ uploaded_img = img.upload_file '/path/to/your/test.jpg'
15
+ # should return a hash like:
16
+ # => {"small_thumbnail"=>"http://imgur.com/NfuKFs.png",
17
+ "original_image"=>"http://imgur.com/NfuKF.png",
18
+ "large_thumbnail"=>"http://imgur.com/NfuKFl.png",
19
+ "delete_hash"=>"VAiPkk5NoQ", "imgur_page"=>"http://imgur.com/NfuKF",
20
+ "delete_page"=>"http://imgur.com/delete/VAiPkk5NoQ",
21
+ "image_hash"=>"NfuKF"}
22
+ # now you can do something like (if you're using rails):
23
+ <%= image_tag uploaded_img["small_thumbnail"] %>
24
+
25
+ # Here's an example using Sinatra and Sequel, requires sinatra-more
26
+
27
+ # Everything's included into one action for brevity, although you can probably extract the file functions to a helper for organizational purposes
28
+
29
+ post '/upload_photo' do
30
+ # let's assume we have this is in our form
31
+ # <%= file_field_tag :photo %>
32
+ file_name = params[:photo][:filename].split(".").first.gsub!(/[^a-z0-9]+/i, '_')
33
+ file_type = params[:photo][:filename].split(".").last
34
+ tmp_file_path = File.join(APP_ROOT,"public/images/tmp/#{file_name}.#{file_type}")
35
+ FileUtils.mv params[:photo][:tempfile].path, tmp_file_path
12
36
 
13
- img = Imgur::API.new 'YOURAPIKEY'
14
- uploaded_img = img.upload_file '/path/to/your/test.jpg'
15
- # should return a hash like:
16
- # => {"small_thumbnail"=>"http://imgur.com/NfuKFs.png",
17
- "original_image"=>"http://imgur.com/NfuKF.png",
18
- "large_thumbnail"=>"http://imgur.com/NfuKFl.png",
19
- "delete_hash"=>"VAiPkk5NoQ", "imgur_page"=>"http://imgur.com/NfuKF",
20
- "delete_page"=>"http://imgur.com/delete/VAiPkk5NoQ",
21
- "image_hash"=>"NfuKF"}
22
- # now you can do something like (if you're using rails):
23
- <%= image_tag uploaded_img["small_thumbnail"] %>
37
+ unless params["photo"].blank? || params["photo"].nil?
38
+ @uploaded_img = IMGUR.upload_file tmp_file_path
39
+ end
40
+
41
+ @photo = Photo.new(:photo => @uploaded_img)
42
+ @photo.save
43
+
44
+ redirect '/results'
45
+ end
46
+
24
47
 
25
48
  == Note on Patches/Pull Requests
26
49
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanntastic-imgur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Poliey
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-12-10 00:00:00 -06:00
13
+ date: 2009-12-11 00:00:00 -06:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency