imgurruby 0.0.2 → 0.0.3

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/.gitignore CHANGED
@@ -1,17 +1,17 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in imgurruby.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in imgurruby.gemspec
4
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2014 Asitha de Silva
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2014 Asitha de Silva
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -4,9 +4,13 @@ Based on [Cubee's imgur-ruby](https://github.com/cubeee/imgur-ruby) script.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Add this line to your application's Gemfile
8
8
 
9
- gem 'imgurruby', :git => 'https://github.com/asithade/imgur-ruby'
9
+ gem "imgurruby", "~> 0.0.2"
10
+
11
+ For the latest version:
12
+
13
+ gem "imgurruby", :git => 'https://github.com/asithade/imgur-ruby'
10
14
 
11
15
  And then execute:
12
16
 
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require "bundler/gem_tasks"
data/imgurruby.gemspec CHANGED
@@ -1,21 +1,21 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'imgurruby/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "imgurruby"
8
- spec.version = Imgurruby::VERSION
9
- spec.authors = ["Asitha de Silva"]
10
- spec.email = ["asithade@gmail.com"]
11
- spec.summary = %q{Imgur image uploader via Imgur API}
12
- spec.homepage = "https://github.com/asithade/imgur-ruby"
13
-
14
- spec.files = `git ls-files -z`.split("\x0")
15
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
- spec.require_paths = ["lib"]
18
-
19
- spec.add_development_dependency "bundler", "~> 1.5"
20
- spec.add_development_dependency "rake"
21
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'imgurruby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "imgurruby"
8
+ spec.version = Imgurruby::VERSION
9
+ spec.authors = ["Asitha de Silva"]
10
+ spec.email = ["asithade@gmail.com"]
11
+ spec.summary = %q{Imgur image uploader via Imgur API}
12
+ spec.homepage = "https://github.com/asithade/imgur-ruby"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.5"
20
+ spec.add_development_dependency "rake"
21
+ end
data/lib/imgurruby.rb CHANGED
@@ -1,52 +1,56 @@
1
- require "imgurruby/version"
2
- require 'net/http'
3
- require 'uri'
4
- require 'base64'
5
- require 'rexml/document'
6
-
7
- module Imgurruby
8
- attr_accessor :api_key, :host, :proxy_addr, :proxy_port, :url, :msg
9
- class Imgur
10
- def initialize(key, addr = nil, port = nil)
11
- @api_key = key
12
- @host = 'api.imgur.com'
13
- @proxy_addr = addr
14
- @proxy_port = port
15
- end
16
-
17
- def upload(file)
18
- # Image Data Variable
19
- imagedata = nil
20
-
21
- # Temp File
22
- tmpfile = file
23
-
24
- # File Name
25
- file_name = tmpfile.original_filename
26
-
27
- # Read File Binary
28
- File.open(tmpfile.tempfile.path, "rb") do |file|
29
- # Base64 Encode Image Data
30
- imagedata = Base64.encode64 file.read
31
- end
32
-
33
- # Begin file upload
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
43
- end
44
- }
45
- end
46
-
47
- # Return msg or url
48
- def url
49
- if @msg ? @msg : @url
50
- end
51
- end
52
- end
1
+ require "imgurruby/version"
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'base64'
5
+ require 'rexml/document'
6
+
7
+ module Imgurruby
8
+ attr_accessor :api_key, :host, :proxy_addr, :proxy_port, :url, :msg
9
+ class Imgur
10
+ def initialize(key, addr = nil, port = nil)
11
+ @api_key = key
12
+ @host = 'api.imgur.com'
13
+ @proxy_addr = addr
14
+ @proxy_port = port
15
+ end
16
+
17
+ def upload(file)
18
+ # Image Data Variable
19
+ imagedata = nil
20
+
21
+ # Temp File
22
+ tmpfile = file
23
+
24
+ # File Name
25
+ file_name = tmpfile.original_filename
26
+
27
+ # Read File Binary
28
+ File.open(tmpfile.tempfile.path, "rb") do |file|
29
+ # Base64 Encode Image Data
30
+ imagedata = Base64.encode64 file.read
31
+ end
32
+
33
+ # Begin file upload
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
43
+ end
44
+ }
45
+ end
46
+
47
+ # Return msg or url
48
+ def url
49
+ if @msg
50
+ @msg
51
+ else
52
+ @url
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,3 +1,3 @@
1
- module Imgurruby
2
- VERSION = "0.0.2"
3
- end
1
+ module Imgurruby
2
+ VERSION = "0.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.2
4
+ version: 0.0.3
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-27 00:00:00.000000000 Z
12
+ date: 2014-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler