imgurr 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,15 +1,14 @@
1
- imgurr
1
+ imgurr [![Gem Version](https://badge.fury.io/rb/imgurr.svg)](http://badge.fury.io/rb/imgurr)
2
2
  =======
3
- Command line utility for Imgur in ruby.
4
- Imgurr lets you quickly upload images, get info about an image and delete your own images from Imgur.
5
-
3
+ Command line utility for Imgur in Ruby. Imgurr lets you quickly upload images, get info about an image and delete your own images from Imgur.
6
4
 
7
5
  ## Install
8
- **Warning:** This gem is still in early development and might not work on your system. Please report any bugs.
9
-
10
6
  gem install imgurr
11
7
 
12
8
  ## Usage
9
+
10
+ ![](http://i.imgur.com/baqLV1p.png)
11
+
13
12
  imgurr upload image.jpg
14
13
  Copied http://i.imgur.com/PLWGJlc.gif to clipboard
15
14
 
@@ -34,3 +33,14 @@ Imgurr lets you quickly upload images, get info about an image and delete your o
34
33
 
35
34
  ## How it works
36
35
  Imgurr stores the delete hash generated by Imgur locally when uploading an image using imgurr. Most of the time the delete hash gets lost if you don't have an account and you want to takedown an image you have to contact Imgur support which can take a while. With imgurr all your delete hashes are saved so you can delete your images later if needed.
36
+
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
45
+
46
+ Don't forget to add a test for any new feature.
data/imgurr.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'imgurr'
3
- s.version = '0.1.0'
3
+ s.version = '0.1.1'
4
4
  s.date = '2013-04-17'
5
5
  s.summary = "Imgurr lets you upload images to imgur from the command line"
6
6
  s.description = "Imgurr is a ruby gem that lets you upload images to Imgur and manage your account"
@@ -28,4 +28,4 @@ Gem::Specification.new do |s|
28
28
  s.files += Dir.glob("lib/**/*")
29
29
  s.files += Dir.glob("bin/**/*")
30
30
  s.files += Dir.glob("test/**/*")
31
- end
31
+ end
data/lib/imgurr.rb CHANGED
@@ -24,7 +24,7 @@ require 'imgurr/imgurErrors'
24
24
  require 'imgurr/command'
25
25
 
26
26
  module Imgurr
27
- VERSION = '0.1.0'
27
+ VERSION = '0.1.1'
28
28
  DEBUG = false
29
29
 
30
30
  def self.storage
@@ -34,4 +34,4 @@ module Imgurr
34
34
  def self.options
35
35
  @options ||= {}
36
36
  end
37
- end
37
+ end
@@ -36,6 +36,12 @@ module Imgurr
36
36
  opts.on('-m', '--markdown', 'Use Markdown Syntax') do
37
37
  options[:markdown] = true
38
38
  end
39
+ opts.on('-l', '--html', 'Use HTML Syntax') do
40
+ options[:html] = true
41
+ end
42
+ opts.on('-s', '--size PERCENTAGE', 'Image Size') do |value|
43
+ options[:size] = value
44
+ end
39
45
  opts.on('-t', '--title TITLE', 'Image Title') do |value|
40
46
  options[:title] = value
41
47
  end
@@ -88,8 +94,8 @@ module Imgurr
88
94
  #
89
95
  # Returns output based on method calls.
90
96
  def delegate(command, major, minor)
91
- return help unless command
92
- return no_internet unless self.internet_connection?
97
+ return help unless command
98
+ return no_internet unless self.internet_connection?
93
99
 
94
100
  # Get image ID from URL
95
101
  if major
@@ -110,22 +116,32 @@ module Imgurr
110
116
  end
111
117
 
112
118
  # Public: Upload an image to Imgur
113
- #
119
+ #
114
120
  # Returns nothing
115
121
  def upload(major)
116
122
  unless File.exist?(major)
117
123
  puts "File #{major} not found."
118
124
  return
119
125
  end
120
- response = ImgurAPI.upload(major)
121
- puts response if response.start_with?('Imgur Error')
122
- if response.start_with?('http')
126
+ response, success = ImgurAPI.upload(major)
127
+ puts response unless success
128
+ if success
123
129
  response = "![#{options[:title].nil? ? 'Screenshot' : options[:title]}](#{response})" if options[:markdown]
130
+ response = build_HTML_response(response) if options[:html]
124
131
  puts "Copied #{Platform.copy(response)} to clipboard"
125
132
  end
126
133
  storage.save
127
134
  end
128
135
 
136
+ # Public: build HTML image tag response
137
+ #
138
+ # Returns a properly formatted HTML <img> tag
139
+ def build_HTML_response(response)
140
+ return "<img src=\"#{response}\" alt=\"#{options[:title].nil? ? 'Screenshot' : options[:title]}\">" if options[:size].nil?
141
+
142
+ "<img src=\"#{response}\" alt=\"#{options[:title].nil? ? 'Screenshot' : options[:title]}\" width=\"#{options[:size]}%\">"
143
+ end
144
+
129
145
  # Public: Get image info
130
146
  #
131
147
  # Returns nothing
@@ -210,7 +226,9 @@ module Imgurr
210
226
  imgurr --version Print current version
211
227
 
212
228
  imgurr upload <image> Upload image and copy link to clipboard
213
- imgurr upload <image> [-m|--markdown ] Upload image and copy link to clipboard with markdown syntax
229
+ imgurr upload <image> [-m | --markdown] Upload image and copy link to clipboard with markdown syntax
230
+ [-l | --html] Upload image and copy link to clipboard with HTML syntax
231
+ [--size=SIZE] Set image size ratio
214
232
  [--tile="Title"] Set image title
215
233
  [--desc="Desc" ] Set image description
216
234
  imgurr info <id> Print image information
@@ -226,4 +244,4 @@ module Imgurr
226
244
 
227
245
  end
228
246
  end
229
- end
247
+ end
@@ -87,9 +87,9 @@ module Imgurr
87
87
  puts JSON.pretty_unparse(data) if Imgurr::DEBUG
88
88
  if data['success']
89
89
  storage.add_hash(data['data']['id'], data['data']['deletehash'])
90
- return data['data']['link']
90
+ return [data['data']['link'], true]
91
91
  end
92
- ImgurErrors.handle_error(response)
92
+ [ImgurErrors.handle_error(response), false]
93
93
  end
94
94
 
95
95
  # Public: Handle API Response: Get image Info
data/test/1-upload.sh CHANGED
@@ -17,6 +17,14 @@ it_uploads_image_with_markdown() {
17
17
  ${imgurr} upload ${image} --markdown | grep "Copied !\[Screenshot\](http://i.imgur.com"
18
18
  }
19
19
 
20
+ it_uploads_image_with_html() {
21
+ ${imgurr} upload ${image} --html | grep "Copied <img src=\"http://i.imgur.com/.*\" alt=\"Screenshot\">"
22
+ }
23
+
24
+ it_uploads_image_with_html_and_size() {
25
+ ${imgurr} upload ${image} --html --size 45 | grep "Copied <img src=\"http://i.imgur.com/.*\" alt=\"Screenshot\" width=\"45%\">"
26
+ }
27
+
20
28
  it_uploads_image_with_title_desc() {
21
29
  ${imgurr} upload ${image} --title "Test" --desc "Test" | grep "Copied http://i.imgur.com"
22
30
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgurr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: