cloudapp 2.0.0 → 2.1.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/bin/cloudapp +38 -36
- data/cloudapp.gemspec +4 -4
- data/lib/cloudapp.rb +1 -1
- data/lib/cloudapp/cli/options.rb +5 -16
- data/lib/cloudapp/collection_json/item.rb +2 -1
- data/lib/cloudapp/credentials.rb +11 -9
- data/man/cloudapp.1 +42 -10
- data/man/cloudapp.1.html +26 -8
- data/man/cloudapp.1.ronn +23 -7
- data/spec/cloudapp/cli/options_spec.rb +9 -34
- data/spec/cloudapp/collection_json/item_spec.rb +5 -0
- data/spec/cloudapp/credentials_spec.rb +31 -13
- metadata +9 -8
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/bin/cloudapp
CHANGED
@@ -17,9 +17,9 @@ def service
|
|
17
17
|
.on_error(&method(:service_error_handler))
|
18
18
|
end
|
19
19
|
|
20
|
-
def token_for_account
|
20
|
+
def token_for_account email, password
|
21
21
|
CloudApp::Service
|
22
|
-
.token_for_account(
|
22
|
+
.token_for_account(email, password, &method(:service_error_handler))
|
23
23
|
end
|
24
24
|
|
25
25
|
def service_error_handler representation
|
@@ -29,7 +29,7 @@ def service_error_handler representation
|
|
29
29
|
message << ' '
|
30
30
|
message << representation.link('upgrade').href
|
31
31
|
end
|
32
|
-
|
32
|
+
service_error message
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -43,24 +43,29 @@ end
|
|
43
43
|
|
44
44
|
def authenticate
|
45
45
|
while not valid_token?
|
46
|
-
|
47
|
-
token = token_for_account
|
48
|
-
Credentials.
|
46
|
+
email, password = CloudApp::CLI::Prompt.new.ask_for_credentials
|
47
|
+
token = token_for_account email, password
|
48
|
+
Credentials.save email, token
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def fetch_link drop,
|
53
|
-
|
54
|
-
|
52
|
+
def fetch_link drop, options
|
53
|
+
link_rel = options.direct_link? ? :embed : :canonical
|
54
|
+
link = drop.link(link_rel) || drop.link(:canonical)
|
55
|
+
copy link if options.copy_link?
|
55
56
|
$stdout.puts link
|
56
57
|
$stderr.puts link unless $stdout.tty?
|
57
58
|
end
|
58
59
|
|
59
60
|
|
60
61
|
def print_error message
|
62
|
+
$stderr.puts "! #{wrap(message, 78, ' ')}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def service_error message
|
61
66
|
$stderr.puts
|
62
67
|
$stderr.puts
|
63
|
-
|
68
|
+
print_error message
|
64
69
|
$stderr.puts
|
65
70
|
end
|
66
71
|
|
@@ -83,8 +88,7 @@ def print_help io = $stdout
|
|
83
88
|
cloudapp, version #{CloudApp::VERSION}
|
84
89
|
|
85
90
|
Usage:
|
86
|
-
cloudapp
|
87
|
-
cloudapp upload [--direct] [--[no-]copy] <file> [<file>...]
|
91
|
+
cloudapp [--direct] [--[no-]copy] <file_or_url> [<file_or_url>...]
|
88
92
|
|
89
93
|
EOS
|
90
94
|
end
|
@@ -98,36 +102,34 @@ def invalid_command
|
|
98
102
|
exit 1
|
99
103
|
end
|
100
104
|
|
101
|
-
def
|
102
|
-
|
103
|
-
|
104
|
-
options.arguments.each do |arg|
|
105
|
-
$stderr.print "Bookmarking #{arg}... "
|
106
|
-
error "#{arg} doesn't look like a valid URL" unless arg =~ URI.regexp
|
107
|
-
bookmark = service.bookmark(arg)
|
108
|
-
exit 1 unless bookmark
|
109
|
-
fetch_link bookmark, options.link_type, options.copy_link?
|
110
|
-
end
|
105
|
+
def file_names options, input = $stdin
|
106
|
+
stdin_file_names = input.tty? ? [] : input.each_line.map(&:chomp)
|
107
|
+
stdin_file_names + options.arguments
|
111
108
|
end
|
112
109
|
|
113
|
-
def
|
114
|
-
|
110
|
+
def share file_names, options
|
111
|
+
invalid_command if file_names.empty?
|
115
112
|
authenticate
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
113
|
+
|
114
|
+
file_names.each do |arg|
|
115
|
+
if File.exists? arg
|
116
|
+
$stderr.print "Uploading #{File.basename(arg)}... "
|
117
|
+
drop = service.upload(arg)
|
118
|
+
elsif arg =~ URI.regexp
|
119
|
+
$stderr.print "Bookmarking #{arg}... "
|
120
|
+
drop = service.bookmark(arg)
|
121
|
+
else
|
122
|
+
error "#{arg.inspect} isn't a file that exists or a valid URL."
|
123
|
+
end
|
124
|
+
|
125
|
+
exit 1 unless drop
|
126
|
+
fetch_link drop, options
|
122
127
|
end
|
123
128
|
end
|
124
129
|
|
125
|
-
|
126
130
|
options = CloudApp::CLI::Options.parse ARGV
|
127
131
|
case options.action
|
128
|
-
when :help
|
129
|
-
when :version
|
130
|
-
when :
|
131
|
-
when :upload then upload options
|
132
|
-
else invalid_command
|
132
|
+
when :help then print_help
|
133
|
+
when :version then print_version
|
134
|
+
when :share then share file_names(options), options
|
133
135
|
end
|
data/cloudapp.gemspec
CHANGED
@@ -13,14 +13,14 @@ 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.
|
17
|
-
s.date = '2013-01-
|
16
|
+
s.version = '2.1.0.beta.1'
|
17
|
+
s.date = '2013-01-11'
|
18
18
|
s.rubyforge_project = 'cloudapp'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
21
21
|
## as you like.
|
22
|
-
s.summary = "CloudApp CLI"
|
23
|
-
s.description = "Experience all the pleasures of sharing with CloudApp now in your terminal."
|
22
|
+
s.summary = "CloudApp API wrapper and CLI"
|
23
|
+
s.description = "Experience all the pleasures of sharing with CloudApp now in your Ruby code and terminal."
|
24
24
|
|
25
25
|
## List the primary authors. If there are a bunch of authors, it's probably
|
26
26
|
## better to set the email to an email list or something. If you don't have
|
data/lib/cloudapp.rb
CHANGED
data/lib/cloudapp/cli/options.rb
CHANGED
@@ -9,41 +9,30 @@ module CloudApp
|
|
9
9
|
options[:copy_link] = true unless args.delete('--no-copy')
|
10
10
|
options[:help] = args.delete('--help') || args.delete('-h')
|
11
11
|
options[:version] = args.delete('--version')
|
12
|
-
options[:action] = args.shift unless args.empty?
|
13
12
|
options[:arguments] = args unless args.empty?
|
14
13
|
|
15
14
|
Options.new options
|
16
15
|
end
|
17
16
|
|
18
|
-
|
17
|
+
attr_reader :arguments
|
19
18
|
def initialize options
|
20
19
|
@copy_link = options.fetch :copy_link, false
|
21
20
|
@direct = options.fetch :direct, false
|
22
21
|
@help = options.fetch :help, false
|
23
22
|
@version = options.fetch :version, false
|
24
|
-
@action = options.fetch :action, nil
|
25
23
|
@arguments = options.fetch :arguments, []
|
26
24
|
end
|
27
25
|
|
28
|
-
def copy_link?
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def link_type
|
33
|
-
@direct && action != :bookmark ? :embed : :canonical
|
34
|
-
end
|
26
|
+
def copy_link?() @copy_link end
|
27
|
+
def direct_link?() @direct end
|
35
28
|
|
36
29
|
def action
|
37
|
-
if @help or @
|
30
|
+
if @help or @arguments.first == 'help'
|
38
31
|
:help
|
39
32
|
elsif @version
|
40
33
|
:version
|
41
|
-
elsif @action == 'bookmark'
|
42
|
-
:bookmark
|
43
|
-
elsif @action == 'upload'
|
44
|
-
:upload
|
45
34
|
else
|
46
|
-
:
|
35
|
+
:share
|
47
36
|
end
|
48
37
|
end
|
49
38
|
end
|
data/lib/cloudapp/credentials.rb
CHANGED
@@ -1,33 +1,35 @@
|
|
1
1
|
require 'netrc'
|
2
2
|
|
3
3
|
class Credentials
|
4
|
-
attr_reader :netrc
|
4
|
+
attr_reader :netrc, :label
|
5
5
|
|
6
|
-
def initialize netrc
|
6
|
+
def initialize netrc, label
|
7
7
|
@netrc = netrc
|
8
|
+
@label = label
|
8
9
|
end
|
9
10
|
|
10
|
-
def self.token netrc = Netrc.read
|
11
|
-
new(netrc).token
|
11
|
+
def self.token netrc = Netrc.read, label = CloudApp::Service.url.host
|
12
|
+
new(netrc, label).token
|
12
13
|
end
|
13
14
|
|
14
|
-
def self.
|
15
|
-
new(netrc).
|
15
|
+
def self.save login, token, netrc = Netrc.read, label = CloudApp::Service.url.host
|
16
|
+
new(netrc, label).save login, token
|
16
17
|
end
|
17
18
|
|
18
19
|
def token
|
19
20
|
credentials.last
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
+
def save login, token
|
24
|
+
return if login.nil? or login =~ /^\s*$/
|
23
25
|
return if token.nil? or token =~ /^\s*$/
|
24
|
-
netrc[
|
26
|
+
netrc[label] = [ login, token ]
|
25
27
|
netrc.save
|
26
28
|
end
|
27
29
|
|
28
30
|
private
|
29
31
|
|
30
32
|
def credentials
|
31
|
-
Array netrc[
|
33
|
+
Array netrc[label]
|
32
34
|
end
|
33
35
|
end
|
data/man/cloudapp.1
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
2
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "CLOUDAPP" "1" "
|
4
|
+
.TH "CLOUDAPP" "1" "January 2013" "" ""
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBcloudapp\fR \- all the pleasures of cloudapp in a cli
|
8
8
|
.
|
9
9
|
.SH "SYNOPSIS"
|
10
|
-
\fBcloudapp
|
11
|
-
.
|
12
|
-
.br
|
13
|
-
\fBcloudapp upload\fR [\fB\-\-direct\fR] [\fB\-\-[no\-]copy\fR] \fIfile\fR [\fIfile\fR\.\.\.]
|
10
|
+
\fBcloudapp [\fR\-\-direct\fB] [\fR\-\-[no\-]copy`] \fIfile_or_url\fR [\fIfile_or_url\fR\.\.\.]
|
14
11
|
.
|
15
12
|
.SH "DESCRIPTION"
|
16
13
|
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)\.
|
@@ -43,7 +40,7 @@ Upload a file:
|
|
43
40
|
.
|
44
41
|
.nf
|
45
42
|
|
46
|
-
$ cloudapp
|
43
|
+
$ cloudapp screenshot\.png
|
47
44
|
Uploading screenshot\.png\.\.\. http://cl\.ly/image/3U2U2f3B1O0x
|
48
45
|
.
|
49
46
|
.fi
|
@@ -57,7 +54,7 @@ Upload several files:
|
|
57
54
|
.
|
58
55
|
.nf
|
59
56
|
|
60
|
-
$ cloudapp
|
57
|
+
$ cloudapp *\.png
|
61
58
|
Uploading screenshot\-1\.png\.\.\. http://cl\.ly/image/1E1F1k3Q3919
|
62
59
|
Uploading screenshot\-2\.png\.\.\. http://cl\.ly/image/3P1s3p0c3545
|
63
60
|
Uploading screenshot\-3\.png\.\.\. http://cl\.ly/image/0E3k0h353X0w
|
@@ -67,13 +64,48 @@ Uploading screenshot\-3\.png\.\.\. http://cl\.ly/image/0E3k0h353X0w
|
|
67
64
|
.IP "" 0
|
68
65
|
.
|
69
66
|
.P
|
67
|
+
Upload file names and URLs from standard input:
|
68
|
+
.
|
69
|
+
.IP "" 4
|
70
|
+
.
|
71
|
+
.nf
|
72
|
+
|
73
|
+
$ ls *\.png | cloudapp
|
74
|
+
Uploading screenshot\-1\.png\.\.\. http://cl\.ly/image/1E1F1k3Q3919
|
75
|
+
Uploading screenshot\-2\.png\.\.\. http://cl\.ly/image/3P1s3p0c3545
|
76
|
+
Uploading screenshot\-3\.png\.\.\. http://cl\.ly/image/0E3k0h353X0w
|
77
|
+
|
78
|
+
$ gifme {1,2,3}\.png | cloudapp \-\-direct
|
79
|
+
You now have a handsome animation at /Users/Larry/Desktop/animated\-2013\-01\-11_15h\-59m\-49s\.gif
|
80
|
+
Uploading animated\-2013\-01\-11_15h\-59m\-49s\.gif\.\.\. http://cl\.ly/image/373I3q2g1p36
|
81
|
+
.
|
82
|
+
.fi
|
83
|
+
.
|
84
|
+
.IP "" 0
|
85
|
+
.
|
86
|
+
.P
|
70
87
|
Bookmark a URL:
|
71
88
|
.
|
72
89
|
.IP "" 4
|
73
90
|
.
|
74
91
|
.nf
|
75
92
|
|
76
|
-
$ cloudapp
|
93
|
+
$ cloudapp http://getcloudapp\.com
|
94
|
+
Bookmarking http://getcloudapp\.com\.\.\. http://cl\.ly/352T3Z2G0G2S
|
95
|
+
.
|
96
|
+
.fi
|
97
|
+
.
|
98
|
+
.IP "" 0
|
99
|
+
.
|
100
|
+
.P
|
101
|
+
Everything at once:
|
102
|
+
.
|
103
|
+
.IP "" 4
|
104
|
+
.
|
105
|
+
.nf
|
106
|
+
|
107
|
+
$ cloudapp screenshot\.png http://getcloudapp\.com
|
108
|
+
Uploading screenshot\.png\.\.\. http://cl\.ly/image/3U2U2f3B1O0x
|
77
109
|
Bookmarking http://getcloudapp\.com\.\.\. http://cl\.ly/352T3Z2G0G2S
|
78
110
|
.
|
79
111
|
.fi
|
@@ -87,7 +119,7 @@ Copy the drop\'s direct link:
|
|
87
119
|
.
|
88
120
|
.nf
|
89
121
|
|
90
|
-
$ cloudapp
|
122
|
+
$ cloudapp \-\-direct screenshot\.png
|
91
123
|
Uploading screenshot\.png\.\.\. http://cl\.ly/image/3U2U2f3B1O0x/screenshot\.png
|
92
124
|
.
|
93
125
|
.fi
|
@@ -101,7 +133,7 @@ Print but don\'t copy the drop\'s link:
|
|
101
133
|
.
|
102
134
|
.nf
|
103
135
|
|
104
|
-
$ cloudapp
|
136
|
+
$ cloudapp \-\-no\-copy screenshot\.png
|
105
137
|
Uploading screenshot\.png\.\.\. http://cl\.ly/image/3U2U2f3B1O0x
|
106
138
|
.
|
107
139
|
.fi
|
data/man/cloudapp.1.html
CHANGED
@@ -79,8 +79,7 @@
|
|
79
79
|
|
80
80
|
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
81
81
|
|
82
|
-
<p><code>cloudapp
|
83
|
-
<code>cloudapp upload</code> [<code>--direct</code>] [<code>--[no-]copy</code>] <var>file</var> [<var>file</var>...]</p>
|
82
|
+
<p><code>cloudapp [</code>--direct<code>] [</code>--[no-]copy`] <var>file_or_url</var> [<var>file_or_url</var>...]</p>
|
84
83
|
|
85
84
|
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
86
85
|
|
@@ -106,40 +105,59 @@ copy.</p></dd>
|
|
106
105
|
|
107
106
|
<p>Upload a file:</p>
|
108
107
|
|
109
|
-
<pre><code>$ cloudapp
|
108
|
+
<pre><code>$ cloudapp screenshot.png
|
110
109
|
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x
|
111
110
|
</code></pre>
|
112
111
|
|
113
112
|
<p>Upload several files:</p>
|
114
113
|
|
115
|
-
<pre><code>$ cloudapp
|
114
|
+
<pre><code>$ cloudapp *.png
|
116
115
|
Uploading screenshot-1.png... http://cl.ly/image/1E1F1k3Q3919
|
117
116
|
Uploading screenshot-2.png... http://cl.ly/image/3P1s3p0c3545
|
118
117
|
Uploading screenshot-3.png... http://cl.ly/image/0E3k0h353X0w
|
119
118
|
</code></pre>
|
120
119
|
|
120
|
+
<p>Upload file names and URLs from standard input:</p>
|
121
|
+
|
122
|
+
<pre><code>$ ls *.png | cloudapp
|
123
|
+
Uploading screenshot-1.png... http://cl.ly/image/1E1F1k3Q3919
|
124
|
+
Uploading screenshot-2.png... http://cl.ly/image/3P1s3p0c3545
|
125
|
+
Uploading screenshot-3.png... http://cl.ly/image/0E3k0h353X0w
|
126
|
+
|
127
|
+
$ gifme {1,2,3}.png | cloudapp --direct
|
128
|
+
You now have a handsome animation at /Users/Larry/Desktop/animated-2013-01-11_15h-59m-49s.gif
|
129
|
+
Uploading animated-2013-01-11_15h-59m-49s.gif... http://cl.ly/image/373I3q2g1p36
|
130
|
+
</code></pre>
|
131
|
+
|
121
132
|
<p>Bookmark a URL:</p>
|
122
133
|
|
123
|
-
<pre><code>$ cloudapp
|
134
|
+
<pre><code>$ cloudapp http://getcloudapp.com
|
135
|
+
Bookmarking http://getcloudapp.com... http://cl.ly/352T3Z2G0G2S
|
136
|
+
</code></pre>
|
137
|
+
|
138
|
+
<p>Everything at once:</p>
|
139
|
+
|
140
|
+
<pre><code>$ cloudapp screenshot.png http://getcloudapp.com
|
141
|
+
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x
|
124
142
|
Bookmarking http://getcloudapp.com... http://cl.ly/352T3Z2G0G2S
|
125
143
|
</code></pre>
|
126
144
|
|
127
145
|
<p>Copy the drop's direct link:</p>
|
128
146
|
|
129
|
-
<pre><code>$ cloudapp
|
147
|
+
<pre><code>$ cloudapp --direct screenshot.png
|
130
148
|
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x/screenshot.png
|
131
149
|
</code></pre>
|
132
150
|
|
133
151
|
<p>Print but don't copy the drop's link:</p>
|
134
152
|
|
135
|
-
<pre><code>$ cloudapp
|
153
|
+
<pre><code>$ cloudapp --no-copy screenshot.png
|
136
154
|
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x
|
137
155
|
</code></pre>
|
138
156
|
|
139
157
|
|
140
158
|
<ol class='man-decor man-foot man foot'>
|
141
159
|
<li class='tl'></li>
|
142
|
-
<li class='tc'>
|
160
|
+
<li class='tc'>January 2013</li>
|
143
161
|
<li class='tr'>cloudapp(1)</li>
|
144
162
|
</ol>
|
145
163
|
|
data/man/cloudapp.1.ronn
CHANGED
@@ -3,8 +3,7 @@ cloudapp(1) -- all the pleasures of cloudapp in a cli
|
|
3
3
|
|
4
4
|
## SYNOPSIS
|
5
5
|
|
6
|
-
`cloudapp
|
7
|
-
`cloudapp upload` [`--direct`] [`--[no-]copy`] <file> [<file>...]
|
6
|
+
`cloudapp [`--direct`] [`--[no-]copy`] <file_or_url> [<file_or_url>...]
|
8
7
|
|
9
8
|
## DESCRIPTION
|
10
9
|
|
@@ -34,27 +33,44 @@ credentials are stored in `~/.netrc` as defined by `ftp`(1).
|
|
34
33
|
|
35
34
|
Upload a file:
|
36
35
|
|
37
|
-
$ cloudapp
|
36
|
+
$ cloudapp screenshot.png
|
38
37
|
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x
|
39
38
|
|
40
39
|
Upload several files:
|
41
40
|
|
42
|
-
$ cloudapp
|
41
|
+
$ cloudapp *.png
|
43
42
|
Uploading screenshot-1.png... http://cl.ly/image/1E1F1k3Q3919
|
44
43
|
Uploading screenshot-2.png... http://cl.ly/image/3P1s3p0c3545
|
45
44
|
Uploading screenshot-3.png... http://cl.ly/image/0E3k0h353X0w
|
46
45
|
|
46
|
+
Upload file names and URLs from standard input:
|
47
|
+
|
48
|
+
$ ls *.png | cloudapp
|
49
|
+
Uploading screenshot-1.png... http://cl.ly/image/1E1F1k3Q3919
|
50
|
+
Uploading screenshot-2.png... http://cl.ly/image/3P1s3p0c3545
|
51
|
+
Uploading screenshot-3.png... http://cl.ly/image/0E3k0h353X0w
|
52
|
+
|
53
|
+
$ gifme {1,2,3}.png | cloudapp --direct
|
54
|
+
You now have a handsome animation at /Users/Larry/Desktop/animated-2013-01-11_15h-59m-49s.gif
|
55
|
+
Uploading animated-2013-01-11_15h-59m-49s.gif... http://cl.ly/image/373I3q2g1p36
|
56
|
+
|
47
57
|
Bookmark a URL:
|
48
58
|
|
49
|
-
$ cloudapp
|
59
|
+
$ cloudapp http://getcloudapp.com
|
60
|
+
Bookmarking http://getcloudapp.com... http://cl.ly/352T3Z2G0G2S
|
61
|
+
|
62
|
+
Everything at once:
|
63
|
+
|
64
|
+
$ cloudapp screenshot.png http://getcloudapp.com
|
65
|
+
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x
|
50
66
|
Bookmarking http://getcloudapp.com... http://cl.ly/352T3Z2G0G2S
|
51
67
|
|
52
68
|
Copy the drop's direct link:
|
53
69
|
|
54
|
-
$ cloudapp
|
70
|
+
$ cloudapp --direct screenshot.png
|
55
71
|
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x/screenshot.png
|
56
72
|
|
57
73
|
Print but don't copy the drop's link:
|
58
74
|
|
59
|
-
$ cloudapp
|
75
|
+
$ cloudapp --no-copy screenshot.png
|
60
76
|
Uploading screenshot.png... http://cl.ly/image/3U2U2f3B1O0x
|
@@ -21,43 +21,28 @@ describe CloudApp::CLI::Options do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe '#
|
25
|
-
subject { described_class.parse(args).
|
24
|
+
describe '#direct_link?' do
|
25
|
+
subject { described_class.parse(args).direct_link? }
|
26
26
|
|
27
27
|
context 'with no args' do
|
28
28
|
let(:args) {[ '' ]}
|
29
|
-
it { should eq(
|
29
|
+
it { should eq(false) }
|
30
30
|
end
|
31
31
|
|
32
32
|
context 'with --direct' do
|
33
33
|
let(:args) { %w(--direct) }
|
34
|
-
it { should eq(
|
34
|
+
it { should eq(true) }
|
35
35
|
end
|
36
36
|
|
37
37
|
context 'with -d' do
|
38
38
|
let(:args) { %w(-d) }
|
39
|
-
it { should eq(
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'with --direct when bookmarking' do
|
43
|
-
let(:args) { %w(bookmark --direct) }
|
44
|
-
it { should eq(:canonical) }
|
39
|
+
it { should eq(true) }
|
45
40
|
end
|
46
41
|
end
|
47
42
|
|
48
43
|
describe '#action' do
|
49
44
|
subject { described_class.parse(args).action }
|
50
45
|
|
51
|
-
context 'with bookmark' do
|
52
|
-
let(:args) { %w(bookmark) }
|
53
|
-
it { should eq(:bookmark) }
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'with upload' do
|
57
|
-
let(:args) { %w(upload) }
|
58
|
-
it { should eq(:upload) }
|
59
|
-
end
|
60
|
-
|
61
46
|
context 'with help' do
|
62
47
|
let(:args) { %w(help) }
|
63
48
|
it { should eq(:help) }
|
@@ -80,12 +65,7 @@ describe CloudApp::CLI::Options do
|
|
80
65
|
|
81
66
|
context 'with no args' do
|
82
67
|
let(:args) {[ '' ]}
|
83
|
-
it { should eq(:
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'with an invalid command' do
|
87
|
-
let(:args) {[ '' ]}
|
88
|
-
it { should eq(:invalid) }
|
68
|
+
it { should eq(:share) }
|
89
69
|
end
|
90
70
|
end
|
91
71
|
|
@@ -93,17 +73,12 @@ describe CloudApp::CLI::Options do
|
|
93
73
|
subject { described_class.parse(args).arguments }
|
94
74
|
|
95
75
|
context 'with no args' do
|
96
|
-
let(:args) {[
|
97
|
-
it { should be_empty }
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'with no args when bookmarking' do
|
101
|
-
let(:args) { %w(bookmark) }
|
76
|
+
let(:args) { [] }
|
102
77
|
it { should be_empty }
|
103
78
|
end
|
104
79
|
|
105
|
-
context 'with args
|
106
|
-
let(:args) { %w(
|
80
|
+
context 'with args' do
|
81
|
+
let(:args) { %w(one two) }
|
107
82
|
it { should eq(%w(one two)) }
|
108
83
|
end
|
109
84
|
end
|
@@ -66,6 +66,11 @@ describe CloudApp::CollectionJson::Item do
|
|
66
66
|
{ 'rel' => 'next', 'href' => 'http://next.com' }] }}
|
67
67
|
|
68
68
|
it { should eq 'http://next.com' }
|
69
|
+
|
70
|
+
context 'a nonexistent link' do
|
71
|
+
subject { described_class.new(data).link('nonexistent') }
|
72
|
+
it { should be_nil }
|
73
|
+
end
|
69
74
|
end
|
70
75
|
|
71
76
|
describe '#data' do
|
@@ -4,18 +4,20 @@ require 'cloudapp/credentials'
|
|
4
4
|
describe Credentials do
|
5
5
|
describe '.token' do
|
6
6
|
let(:netrc) { stub :netrc, :[] => %w( arthur@dent.com towel ) }
|
7
|
-
|
7
|
+
let(:label) { stub :label }
|
8
|
+
subject { Credentials.token(netrc, label) }
|
8
9
|
it { should eq 'towel' }
|
9
10
|
end
|
10
11
|
|
11
12
|
describe '#token' do
|
12
13
|
let(:netrc) { stub :netrc, :[] => %w( arthur@dent.com towel ) }
|
13
|
-
|
14
|
+
let(:label) { stub :label }
|
15
|
+
subject { Credentials.new(netrc, label).token }
|
14
16
|
|
15
17
|
it { should eq 'towel' }
|
16
18
|
|
17
19
|
it 'fetches token from netrc' do
|
18
|
-
netrc.should_receive(:[]).with(
|
20
|
+
netrc.should_receive(:[]).with(label).once
|
19
21
|
subject
|
20
22
|
end
|
21
23
|
|
@@ -25,38 +27,54 @@ describe Credentials do
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
|
-
describe '.
|
30
|
+
describe '.save' do
|
29
31
|
let(:netrc) { stub :netrc, :[]= => nil }
|
32
|
+
let(:label) { stub :label }
|
30
33
|
|
31
34
|
it 'saves the token' do
|
32
35
|
netrc.should_receive(:save).once.ordered
|
33
|
-
Credentials.
|
36
|
+
Credentials.save 'login', 'new token', netrc, label
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
37
|
-
describe '#
|
40
|
+
describe '#save' do
|
38
41
|
let(:netrc) { stub :netrc }
|
39
|
-
|
42
|
+
let(:label) { stub :label }
|
43
|
+
let(:login) { stub :login }
|
44
|
+
subject { Credentials.new(netrc, label) }
|
40
45
|
|
41
46
|
it 'saves the token' do
|
42
|
-
credentials = [ '
|
43
|
-
netrc.should_receive(:[]=).with(
|
47
|
+
credentials = [ 'arthur@dent.com', 'new token' ]
|
48
|
+
netrc.should_receive(:[]=).with(label, credentials)
|
44
49
|
.once.ordered
|
45
50
|
netrc.should_receive(:save).once.ordered
|
46
|
-
subject.
|
51
|
+
subject.save *credentials
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'ignores a nil login' do
|
55
|
+
netrc.should_not_receive(:[]=)
|
56
|
+
netrc.should_not_receive(:save)
|
57
|
+
subject.save nil, 'new token'
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'ignores an empty login' do
|
61
|
+
netrc.should_not_receive(:[]=)
|
62
|
+
netrc.should_not_receive(:save)
|
63
|
+
subject.save '', 'new token'
|
64
|
+
subject.save ' ', 'new token'
|
47
65
|
end
|
48
66
|
|
49
67
|
it 'ignores a nil token' do
|
50
68
|
netrc.should_not_receive(:[]=)
|
51
69
|
netrc.should_not_receive(:save)
|
52
|
-
subject.
|
70
|
+
subject.save login, nil
|
53
71
|
end
|
54
72
|
|
55
73
|
it 'ignores an empty token' do
|
56
74
|
netrc.should_not_receive(:[]=)
|
57
75
|
netrc.should_not_receive(:save)
|
58
|
-
subject.
|
59
|
-
subject.
|
76
|
+
subject.save login, ''
|
77
|
+
subject.save login, ' '
|
60
78
|
end
|
61
79
|
end
|
62
80
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
5
|
-
prerelease:
|
4
|
+
version: 2.1.0.beta.1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Larry Marburger
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clipboard
|
@@ -139,7 +139,8 @@ dependencies:
|
|
139
139
|
- - ! '>='
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
|
-
description: Experience all the pleasures of sharing with CloudApp now in your
|
142
|
+
description: Experience all the pleasures of sharing with CloudApp now in your Ruby
|
143
|
+
code and terminal.
|
143
144
|
email: larry@marburger.cc
|
144
145
|
executables:
|
145
146
|
- cloudapp
|
@@ -191,17 +192,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
191
192
|
version: '0'
|
192
193
|
segments:
|
193
194
|
- 0
|
194
|
-
hash:
|
195
|
+
hash: 186077293750345953
|
195
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
197
|
none: false
|
197
198
|
requirements:
|
198
|
-
- - ! '
|
199
|
+
- - ! '>'
|
199
200
|
- !ruby/object:Gem::Version
|
200
|
-
version:
|
201
|
+
version: 1.3.1
|
201
202
|
requirements: []
|
202
203
|
rubyforge_project: cloudapp
|
203
204
|
rubygems_version: 1.8.23
|
204
205
|
signing_key:
|
205
206
|
specification_version: 2
|
206
|
-
summary: CloudApp CLI
|
207
|
+
summary: CloudApp API wrapper and CLI
|
207
208
|
test_files: []
|