cloudapp 2.0.0.beta.12 → 2.0.0.beta.13
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/bin/cloudapp +22 -4
- data/cloudapp.gemspec +2 -2
- data/lib/cloudapp.rb +1 -1
- data/lib/cloudapp/collection_json/item.rb +4 -3
- data/lib/cloudapp/service.rb +3 -3
- data/man/cloudapp.1 +19 -11
- data/man/cloudapp.1.html +13 -10
- data/man/cloudapp.1.ronn +18 -11
- data/spec/cloudapp/collection_json/item_spec.rb +15 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/bin/cloudapp
CHANGED
@@ -7,6 +7,11 @@ require 'cloudapp/cli/prompt'
|
|
7
7
|
require 'cloudapp/service'
|
8
8
|
require 'clipboard'
|
9
9
|
|
10
|
+
trap('SIGINT') do
|
11
|
+
puts
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
|
10
15
|
def service
|
11
16
|
CloudApp::Service.using_token(token)
|
12
17
|
.on_error(&method(:service_error_handler))
|
@@ -19,7 +24,12 @@ end
|
|
19
24
|
|
20
25
|
def service_error_handler representation
|
21
26
|
if representation.collection.error
|
22
|
-
|
27
|
+
message = representation.collection.error.message
|
28
|
+
if representation.collection.error.code == 'upgrade'
|
29
|
+
message << ' '
|
30
|
+
message << representation.link('upgrade').href
|
31
|
+
end
|
32
|
+
print_error message
|
23
33
|
end
|
24
34
|
end
|
25
35
|
|
@@ -49,7 +59,8 @@ end
|
|
49
59
|
|
50
60
|
def print_error message
|
51
61
|
$stderr.puts
|
52
|
-
$stderr.puts
|
62
|
+
$stderr.puts
|
63
|
+
$stderr.puts "! #{wrap(message, 78, ' ')}"
|
53
64
|
$stderr.puts
|
54
65
|
end
|
55
66
|
|
@@ -58,6 +69,10 @@ def error message
|
|
58
69
|
exit 1
|
59
70
|
end
|
60
71
|
|
72
|
+
def wrap message, width, padding
|
73
|
+
message.gsub(/(.{1,#{width}})(\s+|$)/, "\\1\n#{padding}").strip
|
74
|
+
end
|
75
|
+
|
61
76
|
def print_version
|
62
77
|
$stdout.puts CloudApp::VERSION
|
63
78
|
exit
|
@@ -65,9 +80,12 @@ end
|
|
65
80
|
|
66
81
|
def print_help io = $stdout
|
67
82
|
io.puts <<EOS
|
83
|
+
cloudapp, version #{CloudApp::VERSION}
|
84
|
+
|
68
85
|
Usage:
|
69
|
-
cloudapp bookmark
|
70
|
-
cloudapp upload
|
86
|
+
cloudapp bookmark [--direct] [--[no-]copy] <url> [<url>...]
|
87
|
+
cloudapp upload [--direct] [--[no-]copy] <file> [<file>...]
|
88
|
+
|
71
89
|
EOS
|
72
90
|
end
|
73
91
|
|
data/cloudapp.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'cloudapp'
|
16
|
-
s.version = '2.0.0.beta.
|
17
|
-
s.date = '
|
16
|
+
s.version = '2.0.0.beta.13'
|
17
|
+
s.date = '2013-01-06'
|
18
18
|
s.rubyforge_project = 'cloudapp'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/lib/cloudapp.rb
CHANGED
@@ -3,9 +3,10 @@ require 'delegate'
|
|
3
3
|
module CloudApp
|
4
4
|
module CollectionJson
|
5
5
|
class Item < SimpleDelegator
|
6
|
-
def href() fetch('href')
|
7
|
-
def rel() fetch('rel')
|
8
|
-
def
|
6
|
+
def href() fetch('href') end
|
7
|
+
def rel() fetch('rel') end
|
8
|
+
def code() fetch('code', nil) end
|
9
|
+
def message() fetch('message', nil) end
|
9
10
|
|
10
11
|
def links
|
11
12
|
fetch('links', []).map {|link| Item.new(link) }
|
data/lib/cloudapp/service.rb
CHANGED
@@ -60,11 +60,11 @@ module CloudApp
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def upload path
|
63
|
-
template = drops_template.template
|
64
|
-
fill('file_size', FileTest.size(path))
|
63
|
+
template = drops_template.template
|
64
|
+
.fill('file_size', FileTest.size(path))
|
65
|
+
.fill('name', File.basename(path))
|
65
66
|
post template.href, template.data do |representation|
|
66
67
|
# TODO: Test unauthorized
|
67
|
-
# TODO: Test uploading after free plan exhausted
|
68
68
|
return unless representation.__response__.success?
|
69
69
|
return upload_file(path, representation.template)
|
70
70
|
end
|
data/man/cloudapp.1
CHANGED
@@ -7,10 +7,10 @@
|
|
7
7
|
\fBcloudapp\fR \- all the pleasures of cloudapp in a cli
|
8
8
|
.
|
9
9
|
.SH "SYNOPSIS"
|
10
|
-
\fBcloudapp bookmark\fR [\fB\-\-direct\fR] [\fB\-\-no\-copy\fR] \fIurl\fR [\fIurl\fR\.\.\.]
|
10
|
+
\fBcloudapp bookmark\fR [\fB\-\-direct\fR] [\fB\-\-[no\-]copy\fR] \fIurl\fR [\fIurl\fR\.\.\.]
|
11
11
|
.
|
12
12
|
.br
|
13
|
-
\fBcloudapp upload\fR [\fB\-\-direct\fR] [\fB\-\-no\-copy\fR] \fIfile\fR [\fIfile\fR\.\.\.]
|
13
|
+
\fBcloudapp upload\fR [\fB\-\-direct\fR] [\fB\-\-[no\-]copy\fR] \fIfile\fR [\fIfile\fR\.\.\.]
|
14
14
|
.
|
15
15
|
.SH "DESCRIPTION"
|
16
16
|
Upload a file or share a bookmark with CloudApp\. The drop\'s share link will be printed to standard output and copied to the system clipboard\. Account credentials are stored in \fB~/\.netrc\fR as defined by \fBftp\fR(1)\.
|
@@ -25,8 +25,16 @@ Upload a file or share a bookmark with CloudApp\. The drop\'s share link will be
|
|
25
25
|
Print the drop\'s direct link after creation\. The direct link is suitable for use in places that expect a link to a file like an HTML IMG tag\.
|
26
26
|
.
|
27
27
|
.TP
|
28
|
-
\fB
|
29
|
-
|
28
|
+
\fB\-h\fR, \fB\-\-help\fR
|
29
|
+
Print a help message describing cloudapp\'s usage\.
|
30
|
+
.
|
31
|
+
.TP
|
32
|
+
\fB\-\-[no\-]copy\fR
|
33
|
+
Copy the new drop\'s link to the system clipboard\. The default option is copy\.
|
34
|
+
.
|
35
|
+
.TP
|
36
|
+
\fB\-\-version\fR
|
37
|
+
Display the version of cloudapp\.
|
30
38
|
.
|
31
39
|
.SH "EXAMPLE"
|
32
40
|
Upload a file:
|
@@ -36,7 +44,7 @@ Upload a file:
|
|
36
44
|
.nf
|
37
45
|
|
38
46
|
$ cloudapp upload screenshot\.png
|
39
|
-
http://cl\.ly/
|
47
|
+
Uploading screenshot\.png\.\.\. http://cl\.ly/image/3U2U2f3B1O0x
|
40
48
|
.
|
41
49
|
.fi
|
42
50
|
.
|
@@ -50,9 +58,9 @@ Upload several files:
|
|
50
58
|
.nf
|
51
59
|
|
52
60
|
$ cloudapp upload *\.png
|
53
|
-
http://cl\.ly/
|
54
|
-
http://cl\.ly/
|
55
|
-
http://cl\.ly/
|
61
|
+
Uploading screenshot\-1\.png\.\.\. http://cl\.ly/image/1E1F1k3Q3919
|
62
|
+
Uploading screenshot\-2\.png\.\.\. http://cl\.ly/image/3P1s3p0c3545
|
63
|
+
Uploading screenshot\-3\.png\.\.\. http://cl\.ly/image/0E3k0h353X0w
|
56
64
|
.
|
57
65
|
.fi
|
58
66
|
.
|
@@ -66,7 +74,7 @@ Bookmark a URL:
|
|
66
74
|
.nf
|
67
75
|
|
68
76
|
$ cloudapp bookmark http://getcloudapp\.com
|
69
|
-
http://cl\.ly/
|
77
|
+
Bookmarking http://getcloudapp\.com\.\.\. http://cl\.ly/352T3Z2G0G2S
|
70
78
|
.
|
71
79
|
.fi
|
72
80
|
.
|
@@ -80,7 +88,7 @@ Copy the drop\'s direct link:
|
|
80
88
|
.nf
|
81
89
|
|
82
90
|
$ cloudapp upload \-\-direct screenshot\.png
|
83
|
-
http://cl\.ly/
|
91
|
+
Uploading screenshot\.png\.\.\. http://cl\.ly/image/3U2U2f3B1O0x/screenshot\.png
|
84
92
|
.
|
85
93
|
.fi
|
86
94
|
.
|
@@ -94,7 +102,7 @@ Print but don\'t copy the drop\'s link:
|
|
94
102
|
.nf
|
95
103
|
|
96
104
|
$ cloudapp upload \-\-no\-copy screenshot\.png
|
97
|
-
http://cl\.ly/
|
105
|
+
Uploading screenshot\.png\.\.\. http://cl\.ly/image/3U2U2f3B1O0x
|
98
106
|
.
|
99
107
|
.fi
|
100
108
|
.
|
data/man/cloudapp.1.html
CHANGED
@@ -79,8 +79,8 @@
|
|
79
79
|
|
80
80
|
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
81
81
|
|
82
|
-
<p><code>cloudapp bookmark</code> [<code>--direct</code>] [<code>--no-copy</code>] <var>url</var> [<var>url</var>...]<br />
|
83
|
-
<code>cloudapp upload</code> [<code>--direct</code>] [<code>--no-copy</code>] <var>file</var> [<var>file</var>...]</p>
|
82
|
+
<p><code>cloudapp bookmark</code> [<code>--direct</code>] [<code>--[no-]copy</code>] <var>url</var> [<var>url</var>...]<br />
|
83
|
+
<code>cloudapp upload</code> [<code>--direct</code>] [<code>--[no-]copy</code>] <var>file</var> [<var>file</var>...]</p>
|
84
84
|
|
85
85
|
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
86
86
|
|
@@ -95,7 +95,10 @@ credentials are stored in <code>~/.netrc</code> as defined by <code>ftp</code>(1
|
|
95
95
|
<dl>
|
96
96
|
<dt><code>-d</code>, <code>--direct</code></dt><dd><p>Print the drop's direct link after creation. The direct link is suitable for
|
97
97
|
use in places that expect a link to a file like an HTML IMG tag.</p></dd>
|
98
|
-
<dt><code>--
|
98
|
+
<dt><code>-h</code>, <code>--help</code></dt><dd><p>Print a help message describing cloudapp's usage.</p></dd>
|
99
|
+
<dt><code>--[no-]copy</code></dt><dd><p>Copy the new drop's link to the system clipboard. The default option is
|
100
|
+
copy.</p></dd>
|
101
|
+
<dt><code>--version</code></dt><dd><p>Display the version of cloudapp.</p></dd>
|
99
102
|
</dl>
|
100
103
|
|
101
104
|
|
@@ -104,33 +107,33 @@ use in places that expect a link to a file like an HTML IMG tag.</p></dd>
|
|
104
107
|
<p>Upload a file:</p>
|
105
108
|
|
106
109
|
<pre><code>$ cloudapp upload screenshot.png
|
107
|
-
http://cl.ly/
|
110
|
+
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x
|
108
111
|
</code></pre>
|
109
112
|
|
110
113
|
<p>Upload several files:</p>
|
111
114
|
|
112
115
|
<pre><code>$ cloudapp upload *.png
|
113
|
-
http://cl.ly/
|
114
|
-
http://cl.ly/
|
115
|
-
http://cl.ly/
|
116
|
+
Uploading screenshot-1.png... http://cl.ly/image/1E1F1k3Q3919
|
117
|
+
Uploading screenshot-2.png... http://cl.ly/image/3P1s3p0c3545
|
118
|
+
Uploading screenshot-3.png... http://cl.ly/image/0E3k0h353X0w
|
116
119
|
</code></pre>
|
117
120
|
|
118
121
|
<p>Bookmark a URL:</p>
|
119
122
|
|
120
123
|
<pre><code>$ cloudapp bookmark http://getcloudapp.com
|
121
|
-
http://cl.ly/
|
124
|
+
Bookmarking http://getcloudapp.com... http://cl.ly/352T3Z2G0G2S
|
122
125
|
</code></pre>
|
123
126
|
|
124
127
|
<p>Copy the drop's direct link:</p>
|
125
128
|
|
126
129
|
<pre><code>$ cloudapp upload --direct screenshot.png
|
127
|
-
http://cl.ly/
|
130
|
+
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x/screenshot.png
|
128
131
|
</code></pre>
|
129
132
|
|
130
133
|
<p>Print but don't copy the drop's link:</p>
|
131
134
|
|
132
135
|
<pre><code>$ cloudapp upload --no-copy screenshot.png
|
133
|
-
http://cl.ly/
|
136
|
+
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x
|
134
137
|
</code></pre>
|
135
138
|
|
136
139
|
|
data/man/cloudapp.1.ronn
CHANGED
@@ -3,8 +3,8 @@ cloudapp(1) -- all the pleasures of cloudapp in a cli
|
|
3
3
|
|
4
4
|
## SYNOPSIS
|
5
5
|
|
6
|
-
`cloudapp bookmark` [`--direct`] [`--no-copy`] <url> [<url>...]<br>
|
7
|
-
`cloudapp upload` [`--direct`] [`--no-copy`] <file> [<file>...]
|
6
|
+
`cloudapp bookmark` [`--direct`] [`--[no-]copy`] <url> [<url>...]<br>
|
7
|
+
`cloudapp upload` [`--direct`] [`--[no-]copy`] <file> [<file>...]
|
8
8
|
|
9
9
|
## DESCRIPTION
|
10
10
|
|
@@ -20,34 +20,41 @@ credentials are stored in `~/.netrc` as defined by `ftp`(1).
|
|
20
20
|
Print the drop's direct link after creation. The direct link is suitable for
|
21
21
|
use in places that expect a link to a file like an HTML IMG tag.
|
22
22
|
|
23
|
-
- `--
|
24
|
-
|
23
|
+
- `-h`, `--help`:
|
24
|
+
Print a help message describing cloudapp's usage.
|
25
|
+
|
26
|
+
- `--[no-]copy`:
|
27
|
+
Copy the new drop's link to the system clipboard. The default option is
|
28
|
+
copy.
|
29
|
+
|
30
|
+
- `--version`:
|
31
|
+
Display the version of cloudapp.
|
25
32
|
|
26
33
|
## EXAMPLE
|
27
34
|
|
28
35
|
Upload a file:
|
29
36
|
|
30
37
|
$ cloudapp upload screenshot.png
|
31
|
-
http://cl.ly/
|
38
|
+
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x
|
32
39
|
|
33
40
|
Upload several files:
|
34
41
|
|
35
42
|
$ cloudapp upload *.png
|
36
|
-
http://cl.ly/
|
37
|
-
http://cl.ly/
|
38
|
-
http://cl.ly/
|
43
|
+
Uploading screenshot-1.png... http://cl.ly/image/1E1F1k3Q3919
|
44
|
+
Uploading screenshot-2.png... http://cl.ly/image/3P1s3p0c3545
|
45
|
+
Uploading screenshot-3.png... http://cl.ly/image/0E3k0h353X0w
|
39
46
|
|
40
47
|
Bookmark a URL:
|
41
48
|
|
42
49
|
$ cloudapp bookmark http://getcloudapp.com
|
43
|
-
http://cl.ly/
|
50
|
+
Bookmarking http://getcloudapp.com... http://cl.ly/352T3Z2G0G2S
|
44
51
|
|
45
52
|
Copy the drop's direct link:
|
46
53
|
|
47
54
|
$ cloudapp upload --direct screenshot.png
|
48
|
-
http://cl.ly/
|
55
|
+
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x/screenshot.png
|
49
56
|
|
50
57
|
Print but don't copy the drop's link:
|
51
58
|
|
52
59
|
$ cloudapp upload --no-copy screenshot.png
|
53
|
-
http://cl.ly/
|
60
|
+
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x
|
@@ -14,9 +14,24 @@ describe CloudApp::CollectionJson::Item do
|
|
14
14
|
its(:rel) { should eq 'relation' }
|
15
15
|
end
|
16
16
|
|
17
|
+
describe '#code' do
|
18
|
+
let(:data) {{ 'code' => 'ID10T' }}
|
19
|
+
its(:code) { should eq 'ID10T' }
|
20
|
+
|
21
|
+
context 'without a code' do
|
22
|
+
let(:data) { {} }
|
23
|
+
its(:code) { should be_nil }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
17
27
|
describe '#message' do
|
18
28
|
let(:data) {{ 'message' => 'error!' }}
|
19
29
|
its(:message) { should eq 'error!' }
|
30
|
+
|
31
|
+
context 'without a message' do
|
32
|
+
let(:data) { {} }
|
33
|
+
its(:message) { should be_nil }
|
34
|
+
end
|
20
35
|
end
|
21
36
|
|
22
37
|
describe '#links' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.beta.
|
4
|
+
version: 2.0.0.beta.13
|
5
5
|
prerelease: 6
|
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:
|
12
|
+
date: 2013-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clipboard
|
@@ -191,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
191
191
|
version: '0'
|
192
192
|
segments:
|
193
193
|
- 0
|
194
|
-
hash: -
|
194
|
+
hash: -547801259757017894
|
195
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
196
|
none: false
|
197
197
|
requirements:
|