imgurruby 0.0.3 → 1.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/README.md CHANGED
@@ -6,7 +6,7 @@ Based on [Cubee's imgur-ruby](https://github.com/cubeee/imgur-ruby) script.
6
6
 
7
7
  Add this line to your application's Gemfile
8
8
 
9
- gem "imgurruby", "~> 0.0.2"
9
+ gem "imgurruby", "~> 0.0.3"
10
10
 
11
11
  For the latest version:
12
12
 
@@ -2,7 +2,7 @@ require "imgurruby/version"
2
2
  require 'net/http'
3
3
  require 'uri'
4
4
  require 'base64'
5
- require 'rexml/document'
5
+ require 'json'
6
6
 
7
7
  module Imgurruby
8
8
  attr_accessor :api_key, :host, :proxy_addr, :proxy_port, :url, :msg
@@ -32,25 +32,20 @@ module Imgurruby
32
32
 
33
33
  # Begin file upload
34
34
  Net::HTTP::Proxy(@proxy_addr, @proxy_port).start(@host,80) {|http|
35
- res = Net::HTTP.post_form(URI.parse('http://api.imgur.com/2/upload'), {'image' => imagedata, 'key' => @api_key})
36
- xml_data = res.body
37
- doc = REXML::Document.new(xml_data)
38
- doc.elements.each('*/message') do |element|
39
- @msg = element.text
40
- end
41
- doc.elements.each('upload/links/original') do |element|
42
- @url = element.text
35
+ res = Net::HTTP.post_form(URI.parse('http://api.imgur.com/2/upload.json'), {'image' => imagedata, 'key' => @api_key})
36
+ json_data = res.body
37
+ @result = JSON.parse(json_data)
38
+ if @result["error"].nil?
39
+ @msg = @result["upload"]["links"]["original"]
40
+ else
41
+ @msg = @result["error"]["message"]
43
42
  end
44
43
  }
45
44
  end
46
45
 
47
46
  # Return msg or url
48
47
  def url
49
- if @msg
50
- @msg
51
- else
52
- @url
53
- end
48
+ @msg
54
49
  end
55
50
  end
56
51
  end
@@ -1,3 +1,3 @@
1
1
  module Imgurruby
2
- VERSION = "0.0.3"
2
+ VERSION = "1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgurruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: '1.0'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-28 00:00:00.000000000 Z
12
+ date: 2014-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler