cloudapp 2.0.0.beta.10 → 2.0.0.beta.11

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudapp (2.0.0.beta.10)
4
+ cloudapp (2.0.0.beta.11)
5
5
  clipboard (~> 1.0.1)
6
6
  leadlight (~> 0.1.0)
7
7
  mime-types (~> 1.19)
data/bin/cloudapp CHANGED
@@ -28,6 +28,11 @@ def print_error message
28
28
  $stderr.puts
29
29
  end
30
30
 
31
+ def print_link link
32
+ $stdout.puts link
33
+ $stderr.puts link unless $stdout.tty?
34
+ end
35
+
31
36
  def error message
32
37
  print_error message
33
38
  exit 1
@@ -41,22 +46,6 @@ def valid_token?
41
46
  !token.nil? and service.root.authorized?
42
47
  end
43
48
 
44
- def valid_url? url
45
- error 'URL missing' if url.nil?
46
- error "#{ url } doesn't look like a valid URL" unless url =~ URI.regexp
47
- true
48
- end
49
-
50
- def valid_file? file
51
- error "File doesn't exist" if file.is_a? Errno::ENOENT
52
- error 'File missing' if file.nil? or file == STDIN
53
- not file.closed?
54
- end
55
-
56
- def next_file
57
- ARGF.file rescue $!
58
- end
59
-
60
49
  def print_version
61
50
  $stdout.puts CloudApp::VERSION
62
51
  exit
@@ -66,6 +55,14 @@ def copy content
66
55
  Clipboard.copy content
67
56
  end
68
57
 
58
+ def validate_url url
59
+ error "#{url} doesn't look like a valid URL" unless url =~ URI.regexp
60
+ end
61
+
62
+ def validate_file path
63
+ error "#{path.inspect} doesn't exist" unless File.exists? path
64
+ end
65
+
69
66
 
70
67
  print_version if ARGV.delete('--version') || ARGV.delete('-v')
71
68
 
@@ -75,32 +72,39 @@ while not valid_token?
75
72
  Credentials.save_token token
76
73
  end
77
74
 
78
- link = ARGV.delete('--direct') || ARGV.delete('-d') ? :embed : :canonical
79
- copy = ARGV.delete('--no-copy').nil?
75
+ link_type = ARGV.delete('--direct') || ARGV.delete('-d') ? :embed : :canonical
76
+ copy = ARGV.delete('--no-copy').nil?
80
77
 
81
78
  case ARGV.shift
82
79
  when 'bookmark'
83
- link = :canonical # No such thing as an embed link for a bookmark.
80
+ error 'Missing URL' if ARGV.empty?
81
+
82
+ link_type = :canonical # No such thing as an embed link for a bookmark.
84
83
  while url = ARGV.shift
85
- break unless valid_url? url
84
+ $stderr.print "Bookmarking #{url}... "
85
+ validate_url url
86
86
  bookmark = service.bookmark(url)
87
87
  exit 1 unless bookmark
88
88
 
89
- url = bookmark.link(link)
90
- copy url if copy
91
- $stdout.puts url
89
+ link = bookmark.link(link_type)
90
+ copy link if copy
91
+ print_link link
92
92
  end
93
+
93
94
  when 'upload'
94
- while file = next_file
95
- break unless valid_file? file
96
- upload = service.upload(file)
95
+ error 'Missing file' if ARGV.empty?
96
+
97
+ while path = ARGV.shift
98
+ $stderr.print "Uploading #{File.basename(path)}... "
99
+ validate_file path
100
+ upload = service.upload(path)
97
101
  exit 1 unless upload
98
102
 
99
- url = upload.link(link)
100
- copy url if copy
101
- $stdout.puts url
102
- ARGF.skip
103
+ link = upload.link(link_type)
104
+ copy link if copy
105
+ print_link link
103
106
  end
107
+
104
108
  else
105
109
  $stderr.puts <<EOS
106
110
  Usage:
data/cloudapp.gemspec CHANGED
@@ -13,7 +13,7 @@ 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.10'
16
+ s.version = '2.0.0.beta.11'
17
17
  s.date = '2012-12-29'
18
18
  s.rubyforge_project = 'cloudapp'
19
19
 
@@ -3,6 +3,7 @@
3
3
  module CloudApp
4
4
  module CLI
5
5
  class Prompt
6
+
6
7
  def ask_for_credentials
7
8
  $stderr.puts "Sign into CloudApp."
8
9
  $stderr.print "Email: "
@@ -21,8 +22,13 @@ module CloudApp
21
22
  return password
22
23
  end
23
24
 
24
- def echo_on() with_tty { system "stty echo" } end
25
- def echo_off() with_tty { system "stty -echo" } end
25
+ # This part gratuitously copied from hub.
26
+ # https://github.com/defunkt/hub/blob/master/lib/hub/github_api.rb#L399-L400
27
+ NULL = defined?(File::NULL) ? File::NULL :
28
+ File.exist?('/dev/null') ? '/dev/null' : 'NUL'
29
+
30
+ def echo_on() with_tty { system "stty echo 2>#{NULL}" } end
31
+ def echo_off() with_tty { system "stty -echo 2>#{NULL}" } end
26
32
  def with_tty(&block)
27
33
  return unless $stdin.isatty
28
34
  yield
data/lib/cloudapp.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CloudApp
2
- VERSION = '2.0.0.beta.10'
2
+ VERSION = '2.0.0.beta.11'
3
3
  end
data/man/cloudapp.1 CHANGED
@@ -25,7 +25,7 @@ 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\-c\fR, \fB\-\-no\-copy\fR
28
+ \fB\-\-no\-copy\fR
29
29
  Don\'t copy the new drop\'s link to the system clipboard\.
30
30
  .
31
31
  .SH "EXAMPLE"
@@ -59,41 +59,42 @@ http://cl\.ly/ghi789
59
59
  .IP "" 0
60
60
  .
61
61
  .P
62
- Copy the drop\'s share link to the clipboard on OS X:
62
+ Bookmark a URL:
63
63
  .
64
64
  .IP "" 4
65
65
  .
66
66
  .nf
67
67
 
68
- $ cloudapp upload screenshot\.png | pbcopy
68
+ $ cloudapp bookmark http://getcloudapp\.com
69
+ http://cl\.ly/abc123
69
70
  .
70
71
  .fi
71
72
  .
72
73
  .IP "" 0
73
74
  .
74
75
  .P
75
- Bookmark a URL:
76
+ Copy the drop\'s direct link:
76
77
  .
77
78
  .IP "" 4
78
79
  .
79
80
  .nf
80
81
 
81
- $ cloudapp bookmark http://getcloudapp\.com
82
- http://cl\.ly/abc123
82
+ $ cloudapp upload \-\-direct screenshot\.png
83
+ http://cl\.ly/abc123/screenshot\.png
83
84
  .
84
85
  .fi
85
86
  .
86
87
  .IP "" 0
87
88
  .
88
89
  .P
89
- Print the drop\'s direct link:
90
+ Print but don\'t copy the drop\'s link:
90
91
  .
91
92
  .IP "" 4
92
93
  .
93
94
  .nf
94
95
 
95
- $ cloudapp upload \-\-direct screenshot\.png
96
- http://cl\.ly/abc123/screenshot\.png
96
+ $ cloudapp upload \-\-no\-copy screenshot\.png
97
+ http://cl\.ly/abc123
97
98
  .
98
99
  .fi
99
100
  .
data/man/cloudapp.1.html CHANGED
@@ -95,7 +95,7 @@ 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>-c</code>, <code>--no-copy</code></dt><dd><p>Don't copy the new drop's link to the system clipboard.</p></dd>
98
+ <dt><code>--no-copy</code></dt><dd><p>Don't copy the new drop's link to the system clipboard.</p></dd>
99
99
  </dl>
100
100
 
101
101
 
@@ -115,23 +115,24 @@ http://cl.ly/def456
115
115
  http://cl.ly/ghi789
116
116
  </code></pre>
117
117
 
118
- <p>Copy the drop's share link to the clipboard on OS X:</p>
119
-
120
- <pre><code>$ cloudapp upload screenshot.png | pbcopy
121
- </code></pre>
122
-
123
118
  <p>Bookmark a URL:</p>
124
119
 
125
120
  <pre><code>$ cloudapp bookmark http://getcloudapp.com
126
121
  http://cl.ly/abc123
127
122
  </code></pre>
128
123
 
129
- <p>Print the drop's direct link:</p>
124
+ <p>Copy the drop's direct link:</p>
130
125
 
131
126
  <pre><code>$ cloudapp upload --direct screenshot.png
132
127
  http://cl.ly/abc123/screenshot.png
133
128
  </code></pre>
134
129
 
130
+ <p>Print but don't copy the drop's link:</p>
131
+
132
+ <pre><code>$ cloudapp upload --no-copy screenshot.png
133
+ http://cl.ly/abc123
134
+ </code></pre>
135
+
135
136
 
136
137
  <ol class='man-decor man-foot man foot'>
137
138
  <li class='tl'></li>
data/man/cloudapp.1.ronn CHANGED
@@ -37,16 +37,17 @@ Upload several files:
37
37
  http://cl.ly/def456
38
38
  http://cl.ly/ghi789
39
39
 
40
- Copy the drop's share link to the clipboard on OS X:
41
-
42
- $ cloudapp upload screenshot.png | pbcopy
43
-
44
40
  Bookmark a URL:
45
41
 
46
42
  $ cloudapp bookmark http://getcloudapp.com
47
43
  http://cl.ly/abc123
48
44
 
49
- Print the drop's direct link:
45
+ Copy the drop's direct link:
50
46
 
51
47
  $ cloudapp upload --direct screenshot.png
52
48
  http://cl.ly/abc123/screenshot.png
49
+
50
+ Print but don't copy the drop's link:
51
+
52
+ $ cloudapp upload --no-copy screenshot.png
53
+ http://cl.ly/abc123
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.10
4
+ version: 2.0.0.beta.11
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -187,6 +187,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
187
  - - ! '>='
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
+ segments:
191
+ - 0
192
+ hash: -179383608361943794
190
193
  required_rubygems_version: !ruby/object:Gem::Requirement
191
194
  none: false
192
195
  requirements: