imgurr 0.0.3 → 0.0.4

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- imgurr (0.0.2)
4
+ imgurr (0.0.4)
5
5
  json (~> 1.7.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  imgurr
2
2
  =======
3
-
4
- Command line utility for Imgur in ruby
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
5
 
6
6
 
7
7
  ## Install
@@ -17,10 +17,15 @@ Command line utility for Imgur in ruby
17
17
  Image ID : 2KxrTAK
18
18
  Views : 14717
19
19
  Bandwidth : 2.296 GiB
20
- Title :
21
- Desc :
20
+ Title : None
21
+ Desc : None
22
22
  Animated : false
23
23
  Width : 960 px
24
24
  Height : 540 px
25
25
  Link : http://i.imgur.com/2KxrTAK.jpg
26
-
26
+
27
+ imgurr delete 2KxrTAK
28
+ Successfully deleted image from Imgur
29
+
30
+ ## How it works
31
+ 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.
data/imgurr.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'imgurr'
3
- s.version = '0.0.3'
4
- s.date = '2013-04-07'
3
+ s.version = '0.0.4'
4
+ s.date = '2013-04-11'
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"
7
7
  s.authors = ["Christophe Naud-Dulude"]
data/lib/imgurr.rb CHANGED
@@ -17,11 +17,16 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
17
17
  require 'imgurr/color'
18
18
  require 'imgurr/numbers'
19
19
  require 'imgurr/imgurAPI'
20
+ require 'imgurr/storage'
20
21
  require 'imgurr/platform'
21
22
  require 'imgurr/imgurErrors'
22
23
  require 'imgurr/command'
23
24
 
24
25
  module Imgurr
25
- VERSION = '0.0.2'
26
+ VERSION = '0.0.4'
26
27
  DEBUG = false
28
+
29
+ def self.storage
30
+ @storage ||= Storage.new
31
+ end
27
32
  end
@@ -33,6 +33,13 @@ module Imgurr
33
33
  $stdin
34
34
  end
35
35
 
36
+ # Public: accesses the in-memory JSON representation.
37
+ #
38
+ # Returns a Storage instance.
39
+ def storage
40
+ Imgurr.storage
41
+ end
42
+
36
43
  # Public: allows main access to most commands.
37
44
  #
38
45
  # Returns output based on method calls.
@@ -40,11 +47,12 @@ module Imgurr
40
47
  return help unless command
41
48
  return no_internet unless self.internet_connection?
42
49
 
43
- return version if command == '--version'
44
- return help if command == 'help'
45
- return help if command[0] == 45 || command[0] == '-' # any - dash options are pleas for help
46
- return upload(major) if command == 'upload' || command == 'up' || command == 'u'
47
- return info(major) if command == 'info' || command == 'i'
50
+ return version if command == '--version' || command == '-v' || command == 'version'
51
+ return help if command == 'help'
52
+ return help if command[0] == 45 || command[0] == '-' # any - dash options are pleas for help
53
+ return upload(major) if command == 'upload' || command == 'up' || command == 'u'
54
+ return info(major) if command == 'info' || command == 'i'
55
+ return delete(major,minor) if command == 'delete' || command == 'd'
48
56
 
49
57
  end
50
58
 
@@ -59,6 +67,7 @@ module Imgurr
59
67
  response = ImgurAPI.upload(major)
60
68
  puts response if response.start_with?('Imgur Error')
61
69
  puts "Copied #{Platform.copy(response)} to clipboard" if response.start_with?('http')
70
+ storage.save
62
71
  end
63
72
 
64
73
  # Public: Get image info
@@ -69,6 +78,28 @@ module Imgurr
69
78
  puts response
70
79
  end
71
80
 
81
+ # Public: Delete image from imgur
82
+ #
83
+ # Returns nothing
84
+ def delete(major,minor)
85
+ if minor
86
+ delete_hash = minor
87
+ else
88
+ if storage.hash_exists?(major)
89
+ delete_hash = storage.find(major)
90
+ else
91
+ puts 'Delete hash not found in storage.'
92
+ puts 'Use: imgurr delete <id> <delete_hash>'
93
+ return
94
+ end
95
+ end
96
+ if ImgurAPI.delete(delete_hash)
97
+ puts 'Successfully deleted image from Imgur'
98
+ else
99
+ puts 'Unauthorized Access. Wrong delete hash?'
100
+ end
101
+ end
102
+
72
103
  # Public: the version of boom that you're currently running.
73
104
  #
74
105
  # Returns a String identifying the version number.
@@ -76,13 +107,6 @@ module Imgurr
76
107
  puts "You're running imgurr #{Imgurr::VERSION}."
77
108
  end
78
109
 
79
- # Public: launches preferences JSON file in an editor for you to edit manually.
80
- #
81
- # Returns nothing.
82
- def edit
83
- #Platform.edit(account.json_file)
84
- end
85
-
86
110
  # Public: Checks is there's an active internet connection
87
111
  #
88
112
  # Returns true or false
@@ -113,6 +137,8 @@ module Imgurr
113
137
 
114
138
  imgurr upload <image> Upload image and copy link to clipboard
115
139
  imgurr info <id> Print image information
140
+ imgurr delete <id> Deletes an image from imgur if the deletehash is found locally
141
+ imgurr delete <id> <deletehash> Deletes an image from imgur with the provided deletehash
116
142
 
117
143
  all other documentation is located at:
118
144
  https://github.com/Chris911/imgurr
@@ -15,6 +15,13 @@ module Imgurr
15
15
  :gallery => '/3/gallery/'
16
16
  }
17
17
 
18
+ # Public: accesses the in-memory JSON representation.
19
+ #
20
+ # Returns a Storage instance.
21
+ def storage
22
+ Imgurr.storage
23
+ end
24
+
18
25
  # HTTP Client used for API requests
19
26
  # TODO: Confirm SSL Certificate
20
27
  def web_client
@@ -50,7 +57,19 @@ module Imgurr
50
57
  handle_info_response(response.body)
51
58
  end
52
59
 
53
- # Public: Handle API Response
60
+ # Public: Upload an image
61
+ #
62
+ # args - The image path for the image to upload
63
+ #
64
+ def delete(delete_hash)
65
+ request = Net::HTTP::Delete.new(API_URI.request_uri + ENDPOINTS[:image] + delete_hash)
66
+ request.add_field('Authorization', API_PUBLIC_KEY)
67
+
68
+ response = web_client.request(request)
69
+ handle_delete_response(response.body)
70
+ end
71
+
72
+ # Public: Handle API Response: Uploaded Image
54
73
  #
55
74
  # args - Response data
56
75
  #
@@ -58,12 +77,13 @@ module Imgurr
58
77
  data = JSON.parse(response)
59
78
  puts JSON.pretty_unparse(data) if Imgurr::DEBUG
60
79
  if data['success']
80
+ storage.add_hash(data['data']['id'], data['data']['deletehash'])
61
81
  return data['data']['link']
62
82
  end
63
83
  ImgurErrors.handle_error(response)
64
84
  end
65
85
 
66
- # Public: Handle API Response
86
+ # Public: Handle API Response: Get image Info
67
87
  #
68
88
  # args - Response data
69
89
  #
@@ -75,8 +95,8 @@ module Imgurr
75
95
  Image ID : #{data['data']['id']}
76
96
  Views : #{data['data']['views']}
77
97
  Bandwidth : #{Numbers.to_human(data['data']['bandwidth'])}
78
- Title : #{data['data']['title']}
79
- Desc : #{data['data']['description']}
98
+ Title : #{'None' unless data['data']['title']}
99
+ Desc : #{'None' unless data['data']['description']}
80
100
  Animated : #{data['data']['animated']}
81
101
  Width : #{data['data']['width']} px
82
102
  Height : #{data['data']['height']} px
@@ -86,6 +106,16 @@ module Imgurr
86
106
  ImgurErrors.handle_error(response)
87
107
  end
88
108
 
109
+ # Public: Handle API Response: Delete Image
110
+ #
111
+ # args - Response data
112
+ #
113
+ def handle_delete_response(response)
114
+ data = JSON.parse(response)
115
+ puts JSON.pretty_unparse(data) if Imgurr::DEBUG
116
+ data['success']
117
+ end
118
+
89
119
  end
90
120
  end
91
121
  end
@@ -0,0 +1,122 @@
1
+ #
2
+ # Storage is the interface between multiple Backends. You can use Storage
3
+ # directly without having to worry about which Backend is in use.
4
+ #
5
+ module Imgurr
6
+ class Storage
7
+ JSON_FILE = "#{ENV['HOME']}/.imgurr"
8
+
9
+ # Public: the path to the Json file used by imgurr.
10
+ #
11
+ # ENV['IMGURRFILE'] is mostly used for tests
12
+ #
13
+ # Returns the String path of imgurr's Json representation.
14
+ def json_file
15
+ ENV['IMGURRFILE'] || JSON_FILE
16
+ end
17
+
18
+ # Public: initializes a Storage instance by loading in your persisted data from adapter.
19
+ #
20
+ # Returns the Storage instance.
21
+ def initialize
22
+ @hashes = []
23
+ bootstrap
24
+ populate
25
+ end
26
+
27
+ # Public: the in-memory collection of all Lists attached to this Storage
28
+ # instance.
29
+ #
30
+ # lists - an Array of individual List items
31
+ #
32
+ # Returns nothing.
33
+ attr_writer :hashes
34
+
35
+ # Public: Adds a deletehash to the hashes list
36
+ #
37
+ # id - Image ID
38
+ # hash - Delete hash
39
+ #
40
+ # Returns nothing
41
+ def add_hash(id, hash)
42
+ hash_item = {:id => id, :deletehash => hash}
43
+ @hashes.push(hash_item)
44
+ end
45
+
46
+ # Public: test whether out storage contains the delete hash for given id
47
+ #
48
+ # id - ID of the image
49
+ #
50
+ # Returns true if found, false if not.
51
+ def hash_exists?(id)
52
+ @hashes.detect { |hash| hash[:id] == id }
53
+ end
54
+
55
+ # Public: finds any given delete_hash by id.
56
+ #
57
+ # name - String name of the list to search for
58
+ #
59
+ # Returns the first instance of delete_hash that it finds.
60
+ def find(id)
61
+ hash = @hashes.find { |hash| hash[:id] == id }
62
+ hash[:deletehash]
63
+ end
64
+
65
+ # Public: all Items in storage.
66
+ #
67
+ # Returns an Array of all Items.
68
+ def items
69
+ @hashes.collect(&:items).flatten
70
+ end
71
+
72
+ # Public: creates a Hash of the representation of the in-memory data
73
+ # structure. This percolates down to Items by calling to_hash on the List,
74
+ # which in tern calls to_hash on individual Items.
75
+ #
76
+ # Returns a Hash of the entire data set.
77
+ def to_hash
78
+ { :hashes => @hashes.collect(&:to_hash) }
79
+ end
80
+
81
+ # Takes care of bootstrapping the Json file, both in terms of creating the
82
+ # file and in terms of creating a skeleton Json schema.
83
+ #
84
+ # Return true if successfully saved.
85
+ def bootstrap
86
+ return if File.exist?(json_file)
87
+ FileUtils.touch json_file
88
+ File.open(json_file, 'w') {|f| f.write(to_json) }
89
+ save
90
+ end
91
+
92
+ # Take a JSON representation of data and explode it out into the constituent
93
+ # Lists and Items for the given Storage instance.
94
+ #
95
+ # Returns nothing.
96
+ def populate
97
+ file = File.read(json_file)
98
+ storage = JSON.parse(file)
99
+
100
+ storage['hashes'].each do |hashes|
101
+ add_hash(hashes['id'], hashes['deletehash'])
102
+ end
103
+ end
104
+
105
+ # Public: persists your in-memory objects to disk in Json format.
106
+ #
107
+ # lists_Json - list in Json format
108
+ #
109
+ # Returns true if successful, false if unsuccessful.
110
+ def save
111
+ File.open(json_file, 'w') {|f| f.write(to_json) }
112
+ end
113
+
114
+ # Public: the Json representation of the current List and Item assortment
115
+ # attached to the Storage instance.
116
+ #
117
+ # Returns a String Json representation of its Lists and their Items.
118
+ def to_json
119
+ JSON.pretty_generate(to_hash)
120
+ end
121
+ end
122
+ end
data/test/1-upload.sh ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env roundup
2
+ export IMGURRFILE=test/files/imgurr.json
3
+ imgurr="./bin/imgurr"
4
+ image="test/files/habs.gif"
5
+ id_file="test/id"
6
+
7
+ describe "upload"
8
+
9
+ it_uploads_image() {
10
+ ${imgurr} upload ${image} | grep "Copied http://i.imgur.com" >> test/temp
11
+ cat test/temp | sed 's/.*imgur.com\/\(.*\)\..*/\1/' >> ${id_file}
12
+ chmod 777 ${id_file}
13
+ rm test/temp
14
+ }
data/test/2-info.sh ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env roundup
2
+ export IMGURRFILE=test/files/imgurr.json
3
+ imgurr="./bin/imgurr"
4
+ id_file="test/id"
5
+
6
+ describe "info"
7
+
8
+ it_gets_image_info() {
9
+ ${imgurr} info `cat ${id_file}` | grep "Width : 96 px"
10
+ }
data/test/3-delete.sh ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env roundup
2
+ export IMGURRFILE=test/files/imgurr.json
3
+ imgurr="./bin/imgurr"
4
+ id_file="test/id"
5
+
6
+ describe "delete"
7
+
8
+ it_shows_error_wrong_hash() {
9
+ ${imgurr} delete `cat ${id_file}` random | grep "Unauthorized Access"
10
+ }
11
+
12
+ it_deletes_from_storage() {
13
+ ${imgurr} delete `cat ${id_file}` | grep "Successfully deleted"
14
+ }
data/test/cli.sh ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env roundup
2
+ export IMGURRFILE=test/files/imgurr.json
3
+ imgurr="./bin/imgurr"
4
+
5
+ describe "cli"
6
+
7
+ it_shows_help() {
8
+ ${imgurr} help | grep "imgurr: help"
9
+ }
10
+
11
+ it_shows_a_version() {
12
+ ${imgurr} --version | grep "running imgurr"
13
+ }
Binary file
Binary file
@@ -0,0 +1,20 @@
1
+ {
2
+ "hashes": [
3
+ {
4
+ "id": "77kh0E9",
5
+ "deletehash": "zrlumL34gWAg1uv"
6
+ },
7
+ {
8
+ "id": "aWFr3dt",
9
+ "deletehash": "sx5cO3ghdf1xmit"
10
+ },
11
+ {
12
+ "id": "Xx5SF7N",
13
+ "deletehash": "jAZJSrRLvMmx4yw"
14
+ },
15
+ {
16
+ "id": "qknnpYa",
17
+ "deletehash": "luK2SQ6Wzt4KIow"
18
+ }
19
+ ]
20
+ }
data/test/roundup ADDED
@@ -0,0 +1,307 @@
1
+ #!/bin/sh
2
+ # [r5]: roundup.5.html
3
+ # [r1t]: roundup-1-test.sh.html
4
+ # [r5t]: roundup-5-test.sh.html
5
+ #
6
+ # _(c) 2010 Blake Mizerany - MIT License_
7
+ #
8
+ # Spray **roundup** on your shells to eliminate weeds and bugs. If your shells
9
+ # survive **roundup**'s deathly toxic properties, they are considered
10
+ # roundup-ready.
11
+ #
12
+ # **roundup** reads shell scripts to form test plans. Each
13
+ # test plan is sourced into a sandbox where each test is executed.
14
+ #
15
+ # See [roundup-1-test.sh.html][r1t] or [roundup-5-test.sh.html][r5t] for example
16
+ # test plans.
17
+ #
18
+ # __Install__
19
+ #
20
+ # git clone http://github.com/bmizerany/roundup.git
21
+ # cd roundup
22
+ # make
23
+ # sudo make install
24
+ # # Alternatively, copy `roundup` wherever you like.
25
+ #
26
+ # __NOTE__: Because test plans are sourced into roundup, roundup prefixes its
27
+ # variable and function names with `roundup_` to avoid name collisions. See
28
+ # "Sandbox Test Runs" below for more insight.
29
+
30
+ # Usage and Prerequisites
31
+ # -----------------------
32
+
33
+ # Exit if any following command exits with a non-zero status.
34
+ set -e
35
+
36
+ # The current version is set during `make version`. Do not modify this line in
37
+ # anyway unless you know what you're doing.
38
+ ROUNDUP_VERSION="0.0.5"
39
+ export ROUNDUP_VERSION
40
+
41
+ # Usage is defined in a specific comment syntax. It is `grep`ed out of this file
42
+ # when needed (i.e. The Tomayko Method). See
43
+ # [shocco](http://rtomayko.heroku.com/shocco) for more detail.
44
+ #/ usage: roundup [--help|-h] [--version|-v] [plan ...]
45
+
46
+ roundup_usage() {
47
+ grep '^#/' <"$0" | cut -c4-
48
+ }
49
+
50
+ while test "$#" -gt 0
51
+ do
52
+ case "$1" in
53
+ --help|-h)
54
+ roundup_usage
55
+ exit 0
56
+ ;;
57
+ --version|-v)
58
+ echo "roundup version $ROUNDUP_VERSION"
59
+ exit 0
60
+ ;;
61
+ --color)
62
+ color=always
63
+ shift
64
+ ;;
65
+ -)
66
+ echo >&2 "roundup: unknown switch $1"
67
+ exit 1
68
+ ;;
69
+ *)
70
+ break
71
+ ;;
72
+ esac
73
+ done
74
+
75
+ # Consider all scripts with names matching `*-test.sh` the plans to run unless
76
+ # otherwise specified as arguments.
77
+ if [ "$#" -gt "0" ]
78
+ then
79
+ roundup_plans="$@"
80
+ else
81
+ roundup_plans="$(ls *-test.sh)"
82
+ fi
83
+
84
+ : ${color:="auto"}
85
+
86
+ # Create a temporary storage place for test output to be retrieved for display
87
+ # after failing tests.
88
+ roundup_tmp="$PWD/.roundup.$$"
89
+ mkdir -p "$roundup_tmp"
90
+
91
+ trap "rm -rf \"$roundup_tmp\"" EXIT INT
92
+
93
+ # __Tracing failures__
94
+ roundup_trace() {
95
+ # Delete the first two lines that represent roundups execution of the
96
+ # test function. They are useless to the user.
97
+ sed '1d' |
98
+ # Delete the last line which is the "set +x" of the error trap
99
+ sed '$d' |
100
+ # Replace the rc=$? of the error trap with an verbose string appended
101
+ # to the failing command trace line.
102
+ sed '$s/.*rc=/exit code /' |
103
+ # Trim the two left most `+` signs. They represent the depth at which
104
+ # roundup executed the function. They also, are useless and confusing.
105
+ sed 's/^++//' |
106
+ # Indent the output by 4 spaces to align under the test name in the
107
+ # summary.
108
+ sed 's/^/ /' |
109
+ # Highlight the last line in front of the exit code to bring notice to
110
+ # where the error occurred.
111
+ #
112
+ # The sed magic puts every line into the hold buffer first, then
113
+ # substitutes in the previous hold buffer content, prints that and starts
114
+ # with the next cycle. At the end the last line (in the hold buffer)
115
+ # is printed without substitution.
116
+ sed -n "x;1!{ \$s/\(.*\)/$mag\1$clr/; };1!p;\$x;\$p"
117
+ }
118
+
119
+ # __Other helpers__
120
+
121
+ # Track the test stats while outputting a real-time report. This takes input on
122
+ # **stdin**. Each input line must come in the format of:
123
+ #
124
+ # # The plan description to be displayed
125
+ # d <plan description>
126
+ #
127
+ # # A passing test
128
+ # p <test name>
129
+ #
130
+ # # A failed test
131
+ # f <test name>
132
+ roundup_summarize() {
133
+ set -e
134
+
135
+ # __Colors for output__
136
+
137
+ # Use colors if we are writing to a tty device.
138
+ if (test -t 1) || (test $color = always)
139
+ then
140
+ red=$(printf "\033[31m")
141
+ grn=$(printf "\033[32m")
142
+ mag=$(printf "\033[35m")
143
+ clr=$(printf "\033[m")
144
+ cols=$(tput cols)
145
+ fi
146
+
147
+ # Make these available to `roundup_trace`.
148
+ export red grn mag clr
149
+
150
+ ntests=0
151
+ passed=0
152
+ failed=0
153
+
154
+ : ${cols:=10}
155
+
156
+ while read status name
157
+ do
158
+ case $status in
159
+ p)
160
+ ntests=$(expr $ntests + 1)
161
+ passed=$(expr $passed + 1)
162
+ printf " %-48s " "$name:"
163
+ printf "$grn[PASS]$clr\n"
164
+ ;;
165
+ f)
166
+ ntests=$(expr $ntests + 1)
167
+ failed=$(expr $failed + 1)
168
+ printf " %-48s " "$name:"
169
+ printf "$red[FAIL]$clr\n"
170
+ roundup_trace < "$roundup_tmp/$name"
171
+ ;;
172
+ d)
173
+ printf "%s\n" "$name"
174
+ ;;
175
+ esac
176
+ done
177
+ # __Test Summary__
178
+ #
179
+ # Display the summary now that all tests are finished.
180
+ yes = | head -n 57 | tr -d '\n'
181
+ printf "\n"
182
+ printf "Tests: %3d | " $ntests
183
+ printf "Passed: %3d | " $passed
184
+ printf "Failed: %3d" $failed
185
+ printf "\n"
186
+
187
+ # Exit with an error if any tests failed
188
+ test $failed -eq 0 || exit 2
189
+ }
190
+
191
+ # Sandbox Test Runs
192
+ # -----------------
193
+
194
+ # The above checks guarantee we have at least one test. We can now move through
195
+ # each specified test plan, determine its test plan, and administer each test
196
+ # listed in a isolated sandbox.
197
+ for roundup_p in $roundup_plans
198
+ do
199
+ # Create a sandbox, source the test plan, run the tests, then leave
200
+ # without a trace.
201
+ (
202
+ # Consider the description to be the `basename` of the plan minus the
203
+ # tailing -test.sh.
204
+ roundup_desc=$(basename "$roundup_p" -test.sh)
205
+
206
+ # Define functions for
207
+ # [roundup(5)][r5]
208
+
209
+ # A custom description is recommended, but optional. Use `describe` to
210
+ # set the description to something more meaningful.
211
+ # TODO: reimplement this.
212
+ describe() {
213
+ roundup_desc="$*"
214
+ }
215
+
216
+ # Provide default `before` and `after` functions that run only `:`, a
217
+ # no-op. They may or may not be redefined by the test plan.
218
+ before() { :; }
219
+ after() { :; }
220
+
221
+ # Seek test methods and aggregate their names, forming a test plan.
222
+ # This is done before populating the sandbox with tests to avoid odd
223
+ # conflicts.
224
+
225
+ # TODO: I want to do this with sed only. Please send a patch if you
226
+ # know a cleaner way.
227
+ roundup_plan=$(
228
+ grep "^it_.*()" $roundup_p |
229
+ sed "s/\(it_[a-zA-Z0-9_]*\).*$/\1/g"
230
+ )
231
+
232
+ # We have the test plan and are in our sandbox with [roundup(5)][r5]
233
+ # defined. Now we source the plan to bring its tests into scope.
234
+ . ./$roundup_p
235
+
236
+ # Output the description signal
237
+ printf "d %s" "$roundup_desc" | tr "\n" " "
238
+ printf "\n"
239
+
240
+ for roundup_test_name in $roundup_plan
241
+ do
242
+ # Any number of things are possible in `before`, `after`, and the
243
+ # test. Drop into an subshell to contain operations that may throw
244
+ # off roundup; such as `cd`.
245
+ (
246
+ # Output `before` trace to temporary file. If `before` runs cleanly,
247
+ # the trace will be overwritten by the actual test case below.
248
+ {
249
+ # redirect tracing output of `before` into file.
250
+ {
251
+ set -x
252
+ # If `before` wasn't redefined, then this is `:`.
253
+ before
254
+ } &>"$roundup_tmp/$roundup_test_name"
255
+ # disable tracing again. Its trace output goes to /dev/null.
256
+ set +x
257
+ } &>/dev/null
258
+
259
+ # exit subshell with return code of last failing command. This
260
+ # is needed to see the return code 253 on failed assumptions.
261
+ # But, only do this if the error handling is activated.
262
+ set -E
263
+ trap 'rc=$?; set +x; set -o | grep "errexit.*on" >/dev/null && exit $rc' ERR
264
+
265
+ # If `before` wasn't redefined, then this is `:`.
266
+ before
267
+
268
+ # Momentarily turn off auto-fail to give us access to the tests
269
+ # exit status in `$?` for capturing.
270
+ set +e
271
+ (
272
+ # Set `-xe` before the test in the subshell. We want the
273
+ # test to fail fast to allow for more accurate output of
274
+ # where things went wrong but not in _our_ process because a
275
+ # failed test should not immediately fail roundup. Each
276
+ # tests trace output is saved in temporary storage.
277
+ set -xe
278
+ $roundup_test_name
279
+ ) >"$roundup_tmp/$roundup_test_name" 2>&1
280
+
281
+ # We need to capture the exit status before returning the `set
282
+ # -e` mode. Returning with `set -e` before we capture the exit
283
+ # status will result in `$?` being set with `set`'s status
284
+ # instead.
285
+ roundup_result=$?
286
+
287
+ # It's safe to return to normal operation.
288
+ set -e
289
+
290
+ # If `after` wasn't redefined, then this runs `:`.
291
+ after
292
+
293
+ # This is the final step of a test. Print its pass/fail signal
294
+ # and name.
295
+ if [ "$roundup_result" -ne 0 ]
296
+ then printf "f"
297
+ else printf "p"
298
+ fi
299
+
300
+ printf " $roundup_test_name\n"
301
+ )
302
+ done
303
+ )
304
+ done |
305
+
306
+ # All signals are piped to this for summary.
307
+ roundup_summarize
data/test/run CHANGED
@@ -1 +1,8 @@
1
- # Test script will go here
1
+ #!/bin/sh
2
+ #
3
+ # A shim to run our tests in shell.
4
+
5
+ ./test/roundup test/*.sh
6
+ rm test/id
7
+
8
+ git checkout test/files/imgurr.json
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgurr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Christophe Naud-Dulude
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-04-07 00:00:00.000000000 Z
12
+ date: 2013-04-11 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: json
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -60,31 +65,41 @@ files:
60
65
  - lib/imgurr/imgurErrors.rb
61
66
  - lib/imgurr/numbers.rb
62
67
  - lib/imgurr/platform.rb
68
+ - lib/imgurr/storage.rb
63
69
  - lib/imgurr.rb
70
+ - test/1-upload.sh
71
+ - test/2-info.sh
72
+ - test/3-delete.sh
73
+ - test/cli.sh
74
+ - test/files/github-logo.png
75
+ - test/files/habs.gif
76
+ - test/files/imgurr.json
77
+ - test/roundup
64
78
  - test/run
65
79
  homepage: https://github.com/Chris911/imgurr
66
80
  licenses:
67
81
  - MIT
68
- metadata: {}
69
82
  post_install_message:
70
83
  rdoc_options:
71
84
  - --charset=UTF-8
72
85
  require_paths:
73
86
  - lib
74
87
  required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
75
89
  requirements:
76
- - - '>='
90
+ - - ! '>='
77
91
  - !ruby/object:Gem::Version
78
92
  version: '0'
79
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
80
95
  requirements:
81
- - - '>='
96
+ - - ! '>='
82
97
  - !ruby/object:Gem::Version
83
98
  version: '0'
84
99
  requirements: []
85
100
  rubyforge_project:
86
- rubygems_version: 2.0.3
101
+ rubygems_version: 1.8.25
87
102
  signing_key:
88
- specification_version: 4
103
+ specification_version: 3
89
104
  summary: Imgurr lets you upload images to imgur from the command line
90
105
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: dc5e24675f0306b5d0f9c1068599acc4ffd6de29
4
- data.tar.gz: 62ffec32123b2d2d9e306f98bcc5d0c2440e5780
5
- SHA512:
6
- metadata.gz: 5af7a7c4f701d72132e6aed3e8577420de2e7508d4efe3eec9b83573da91b07d325c843e9fad8f0023c3516626fb492ac64cae2dd0e4fbc2afa8c99b97b946b1
7
- data.tar.gz: ef8c4dd81a8bb18f6d259b966963235d4298a7b1377202bba889b59d44db9a8a06588d754476da6a261fac476e6559cc85e57eeb65e75618750bb029d38fa3c3