ruby_imgur 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. metadata +9 -13
  3. data/lib/imgur-old.rb +0 -85
  4. data/lib/test +0 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7a18a487f27ce126b53a877f70a61788933d699c
4
+ data.tar.gz: b9c044523fa8c16c928b05bc3993e121413f95c3
5
+ SHA512:
6
+ metadata.gz: b7fd38c9461fa2f64e24e2aec91814d9c30bf6270e1408e9a2183c09316218a09e06d42863b6256f9e826917838e5b5a6f6832f3c7db4a7f2248ad00358ae81d
7
+ data.tar.gz: 5e5e61cf58506ce10e8fbac1a6f08716d3e13c0ac6ff4a4e82ce5bcda4fcf1eb55d47e50c5a2baa72d7df9f336912daf6fc85dbfc815c01ccb16739ccd9bb686
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_imgur
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Fraser Murray
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-20 00:00:00.000000000 Z
11
+ date: 2013-04-06 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description:
15
14
  email: fraser.m.murray@gmail.com
@@ -17,32 +16,29 @@ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
20
- - lib/imgur_rails.rb
21
- - lib/test
22
19
  - lib/imgur.rb
23
- - lib/imgur-old.rb
24
- homepage: ''
20
+ - lib/imgur_rails.rb
21
+ homepage:
25
22
  licenses: []
23
+ metadata: {}
26
24
  post_install_message:
27
25
  rdoc_options: []
28
26
  require_paths:
29
27
  - lib
30
28
  required_ruby_version: !ruby/object:Gem::Requirement
31
- none: false
32
29
  requirements:
33
- - - ! '>='
30
+ - - '>='
34
31
  - !ruby/object:Gem::Version
35
32
  version: '0'
36
33
  required_rubygems_version: !ruby/object:Gem::Requirement
37
- none: false
38
34
  requirements:
39
- - - ! '>='
35
+ - - '>='
40
36
  - !ruby/object:Gem::Version
41
37
  version: '0'
42
38
  requirements: []
43
39
  rubyforge_project:
44
- rubygems_version: 1.8.22
40
+ rubygems_version: 2.0.3
45
41
  signing_key:
46
- specification_version: 3
42
+ specification_version: 4
47
43
  summary: library for imgur api
48
44
  test_files: []
data/lib/imgur-old.rb DELETED
@@ -1,85 +0,0 @@
1
- require 'open-uri'
2
- require 'net/http'
3
- require 'json'
4
- require 'base64'
5
-
6
- class Imgur
7
-
8
- IMAGE_SIZES = { :small => :s, :large => :l }
9
-
10
- # add an API key to use for uploads
11
- def self.api_key=( api_key )
12
- @@api_key = api_key.to_s.chomp
13
- end
14
-
15
- def self.upload( options = {} )
16
- data = options[:data] ||
17
- options[:url] ||
18
- Base64.encode64 open(options[:filename]).read
19
- post_data = { :key => api_key, :image => data }
20
- post_url = generate_url :method => :upload
21
- post_uri = URI.parse post_url
22
- response = JSON (Net::HTTP.post_form post_uri, post_data).body
23
- { :hash => response["upload"]["image"]["hash"],
24
- :delete_hash => response["upload"]["image"]["deletehash"],
25
- :filetype => response["upload"]["image"]["type"].gsub("image\/","") }
26
- end
27
-
28
- def self.copy( url )
29
- upload :url => url
30
- end
31
-
32
- def self.upload_file( filename )
33
- upload :filename => filename
34
- end
35
-
36
- def self.get( hash, options = {} )
37
- open url_for hash, options
38
- end
39
-
40
- def self.stats
41
- json_get :method => :stats
42
- end
43
-
44
- def self.delete( delete_hash )
45
- json_get( :hash => delete_hash, :method => :delete )["delete"]["message"] == "Success"
46
- end
47
-
48
- def self.album( hash, options = {} )
49
- json_get :hash => hash, :method => :album
50
- end
51
-
52
- def self.url_for( hash, options = {} )
53
- size = IMAGE_SIZES[options[:size]]
54
- filetype = options[:filetype] || :png
55
- if filetype == :detect
56
- filetype = json_get( :hash => hash, :method => :image )["image"]["image"]["type"].gsub "image\/", ""
57
- end
58
- "http://i.imgur.com/#{hash}#{size}.#{filetype}"
59
- end
60
-
61
- class << self
62
- alias_method :[], :url_for
63
- end
64
-
65
- private
66
-
67
- def self.api_key
68
- @@api_key
69
- end
70
-
71
- def self.json_get( options = {} )
72
- JSON open(generate_url options).read
73
- end
74
-
75
- def self.generate_url( options = {} )
76
- hash = options[:hash]
77
- method = options[:method]
78
- url = "http://api.imgur.com/2/"
79
- url += method.to_s
80
- url += "/" + hash.to_s if hash
81
- url += ".json"
82
- url
83
- end
84
-
85
- end
data/lib/test DELETED
Binary file