cloudapp 2.0.0.beta.8 → 2.0.0.beta.9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudapp (2.0.0.beta.8)
5
- leadlight (~> 0.0.7)
4
+ cloudapp (2.0.0.beta.9)
5
+ leadlight (~> 0.1.0)
6
6
  mime-types (~> 1.19)
7
7
  netrc (~> 0.7.7)
8
8
  typhoeus (~> 0.3.3)
@@ -19,7 +19,7 @@ GEM
19
19
  hookr (1.1.1)
20
20
  fail-fast (= 1.0.0)
21
21
  hpricot (0.8.6)
22
- leadlight (0.0.7)
22
+ leadlight (0.1.0)
23
23
  addressable (~> 2.2.0)
24
24
  faraday (= 0.8.1)
25
25
  fattr
@@ -46,7 +46,7 @@ GEM
46
46
  rspec-core (2.12.2)
47
47
  rspec-expectations (2.12.1)
48
48
  diff-lcs (~> 1.1.3)
49
- rspec-mocks (2.12.0)
49
+ rspec-mocks (2.12.1)
50
50
  typhoeus (0.3.3)
51
51
  mime-types
52
52
 
data/README.md CHANGED
@@ -7,7 +7,7 @@ Experience all the pleasures of sharing with [CloudApp][] from your terminal.
7
7
 
8
8
  ## Requirements
9
9
 
10
- `cloudapp` requires Ruby 1.9.2 or greater. Windows is not yet supported. If
10
+ `cloudapp` requires Ruby 1.9.3 or greater. Windows is not yet supported. If
11
11
  you're willing to lend a hand, we'd love to officially support it.
12
12
 
13
13
 
@@ -42,6 +42,11 @@ link to a file like an HTML IMG tag.
42
42
  ``` bash
43
43
  $ cloudapp upload screenshot.png
44
44
  http://cl.ly/abc123
45
+
46
+ $ cloudapp upload *.png
47
+ http://cl.ly/abc123
48
+ http://cl.ly/def456
49
+ http://cl.ly/ghi789
45
50
  ```
46
51
 
47
52
  ### cloudapp bookmark `<url>`
@@ -51,6 +56,11 @@ Bookmark `<url>` and print its link to standard out.
51
56
  ``` bash
52
57
  $ cloudapp bookmark http://getcloudapp.com
53
58
  http://cl.ly/abc123
59
+
60
+ $ cloudapp bookmark http://getcloudapp.com http://google.com http://bing.com
61
+ http://cl.ly/abc123
62
+ http://cl.ly/def456
63
+ http://cl.ly/ghi789
54
64
  ```
55
65
 
56
66
  ## Wish List
@@ -58,8 +68,6 @@ http://cl.ly/abc123
58
68
  A few simple commands to allow scripting and input from other Unix programs
59
69
  would be ideal.
60
70
 
61
- - Share several files: `cloudapp upload *.png`
62
- - Bookmark several links: `cloudapp bookmark http://douglasadams.com http://zombo.com`
63
71
  - Handle bookmarks from STDIN: `pbpaste | cloudapp bookmark`
64
72
  - Download a drop: `cloudapp download http://cl.ly/abc123`
65
73
  - Encrypt and share a file: `cloudapp upload --encrypt launch_codes.txt`
data/bin/cloudapp CHANGED
@@ -6,7 +6,21 @@ require 'cloudapp/cli/prompt'
6
6
  require 'cloudapp/service'
7
7
 
8
8
  def service
9
- CloudApp::Service.using_token token
9
+ CloudApp::Service.using_token(token)
10
+ .on_error(&method(:service_error_handler))
11
+ end
12
+
13
+ def token_for_account credentials
14
+ CloudApp::Service
15
+ .token_for_account(*credentials, &method(:service_error_handler))
16
+ end
17
+
18
+ def service_error_handler representation
19
+ if representation.collection.error
20
+ puts
21
+ puts "! #{representation.collection.error.message}"
22
+ puts
23
+ end
10
24
  end
11
25
 
12
26
  def token
@@ -44,14 +58,14 @@ def print_version
44
58
  end
45
59
 
46
60
 
61
+ print_version if ARGV.delete('--version') || ARGV.delete('-v')
62
+
47
63
  while not valid_token?
48
64
  credentials = CloudApp::CLI::Prompt.new.ask_for_credentials
49
- token = CloudApp::Service.token_for_account *credentials
65
+ token = token_for_account credentials
50
66
  Credentials.save_token token
51
67
  end
52
68
 
53
- print_version if ARGV.delete('--version') || ARGV.delete('-v')
54
-
55
69
  link = ARGV.delete('--direct') || ARGV.delete('-d') ? :embed : :canonical
56
70
 
57
71
  case ARGV.shift
@@ -59,12 +73,14 @@ when 'bookmark'
59
73
  link = :canonical # No such thing as an embed link for a bookmark.
60
74
  while url = ARGV.shift
61
75
  break unless valid_url? url
62
- puts service.bookmark(url).link(link)
76
+ bookmark = service.bookmark(url)
77
+ puts bookmark.link(link)
63
78
  end
64
79
  when 'upload'
65
80
  while file = next_file
66
81
  break unless valid_file? file
67
- puts service.upload(file).link(link)
82
+ upload = service.upload(file)
83
+ puts upload.link(link) if upload
68
84
  ARGF.skip
69
85
  end
70
86
  else
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.8'
17
- s.date = '2012-12-23'
16
+ s.version = '2.0.0.beta.9'
17
+ s.date = '2012-12-28'
18
18
  s.rubyforge_project = 'cloudapp'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  ## List your runtime dependencies here. Runtime dependencies are those
45
45
  ## that are needed for an end user to actually USE your code.
46
46
  s.add_dependency 'netrc', '~> 0.7.7'
47
- s.add_dependency 'leadlight', '~> 0.0.7'
47
+ s.add_dependency 'leadlight', '~> 0.1.0'
48
48
  s.add_dependency 'mime-types', '~> 1.19'
49
49
  s.add_dependency 'typhoeus', '~> 0.3.3'
50
50
 
@@ -78,11 +78,13 @@ Gem::Specification.new do |s|
78
78
  man/cloudapp.1
79
79
  man/cloudapp.1.html
80
80
  man/cloudapp.1.ronn
81
+ script/docs
81
82
  spec/cloudapp/authorized_spec.rb
82
83
  spec/cloudapp/collection_json/collection_spec.rb
83
84
  spec/cloudapp/collection_json/item_spec.rb
84
85
  spec/cloudapp/collection_json/template_spec.rb
85
86
  spec/cloudapp/credentials_spec.rb
87
+ spec/helper.rb
86
88
  ]
87
89
  # = MANIFEST =
88
90
 
@@ -16,6 +16,11 @@ module CloudApp
16
16
  def template
17
17
  Template.new(fetch('template'), href)
18
18
  end
19
+
20
+ def error
21
+ return unless has_key? 'error'
22
+ Item.new(fetch('error'))
23
+ end
19
24
  end
20
25
  end
21
26
  end
@@ -3,8 +3,9 @@ require 'delegate'
3
3
  module CloudApp
4
4
  module CollectionJson
5
5
  class Item < SimpleDelegator
6
- def href() fetch('href') end
7
- def rel() fetch('rel') end
6
+ def href() fetch('href') end
7
+ def rel() fetch('rel') end
8
+ def message() fetch('message') end
8
9
 
9
10
  def links
10
11
  fetch('links', []).map {|link| Item.new(link) }
@@ -4,7 +4,7 @@ require 'cloudapp/collection_json/template'
4
4
 
5
5
  module CloudApp
6
6
  module CollectionJson
7
- Tint = Leadlight::Tint.new 'collection+json', status: [ :success, 401 ] do
7
+ Tint = Leadlight::Tint.new 'collection+json', status: :any do
8
8
  match_content_type 'application/vnd.collection+json'
9
9
  extend CloudApp::CollectionJson::Representation
10
10
  end
@@ -34,8 +34,10 @@ module CloudApp
34
34
  connection.token_auth token
35
35
  end
36
36
 
37
- def self.token_for_account email, password
38
- new.token_for_account(email, password)
37
+ def self.token_for_account email, password, &error_handler
38
+ service = new
39
+ service.on_error &error_handler if error_handler
40
+ service.token_for_account(email, password)
39
41
  end
40
42
 
41
43
  def token_for_account email, password
@@ -52,6 +54,7 @@ module CloudApp
52
54
  template = drops_template.template.
53
55
  fill('bookmark_url', url)
54
56
  post template.href, template.data do |representation|
57
+ # TODO: Test unauthorized
55
58
  return representation.item
56
59
  end
57
60
  end
@@ -60,12 +63,16 @@ module CloudApp
60
63
  template = drops_template.template.
61
64
  fill('file_size', FileTest.size(path))
62
65
  post template.href, template.data do |representation|
66
+ # TODO: Test unauthorized
67
+ # TODO: Test uploading after free plan exhausted
68
+ return unless representation.__response__.success?
63
69
  return upload_file(path, representation.template)
64
70
  end
65
71
  end
66
72
 
67
73
  def drops_template
68
74
  root.link('drops-template').get do |representation|
75
+ # TODO: Test unauthorized
69
76
  return representation
70
77
  end
71
78
  end
data/lib/cloudapp.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CloudApp
2
- VERSION = '2.0.0.beta.8'
2
+ VERSION = '2.0.0.beta.9'
3
3
  end
data/man/cloudapp.1 CHANGED
@@ -7,14 +7,17 @@
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] \fIurl\fR
10
+ \fBcloudapp bookmark\fR [\fB\-\-direct\fR] \fIurl\fR [\fIurl\fR\.\.\.]
11
11
  .
12
12
  .br
13
- \fBcloudapp upload\fR [\fB\-\-direct\fR] \fIfile\fR
13
+ \fBcloudapp upload\fR [\fB\-\-direct\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\. Account credentials are stored in \fB~/\.netrc\fR\.
17
17
  .
18
+ .P
19
+ \fBcloudapp\fR requires ruby 1\.9\.3 or greater\.
20
+ .
18
21
  .SH "OPTIONS"
19
22
  .
20
23
  .TP
@@ -56,6 +59,22 @@ http://cl\.ly/abc123
56
59
  .IP "" 0
57
60
  .
58
61
  .P
62
+ Upload several files:
63
+ .
64
+ .IP "" 4
65
+ .
66
+ .nf
67
+
68
+ $ cloudapp upload *\.png
69
+ http://cl\.ly/abc123
70
+ http://cl\.ly/def456
71
+ http://cl\.ly/ghi789
72
+ .
73
+ .fi
74
+ .
75
+ .IP "" 0
76
+ .
77
+ .P
59
78
  Copy the drop\'s share link to the clipboard on OS X:
60
79
  .
61
80
  .IP "" 4
data/man/cloudapp.1.html CHANGED
@@ -82,14 +82,16 @@
82
82
 
83
83
  <h2 id="SYNOPSIS">SYNOPSIS</h2>
84
84
 
85
- <p><code>cloudapp bookmark</code> [<code>--direct</code>] <var>url</var><br />
86
- <code>cloudapp upload</code> [<code>--direct</code>] <var>file</var></p>
85
+ <p><code>cloudapp bookmark</code> [<code>--direct</code>] <var>url</var> [<var>url</var>...]<br />
86
+ <code>cloudapp upload</code> [<code>--direct</code>] <var>file</var> [<var>file</var>...]</p>
87
87
 
88
88
  <h2 id="DESCRIPTION">DESCRIPTION</h2>
89
89
 
90
90
  <p>Upload a file or share a bookmark with CloudApp. The drop's share link will be
91
91
  printed to standard output. Account credentials are stored in <code>~/.netrc</code>.</p>
92
92
 
93
+ <p><strong>cloudapp</strong> requires ruby 1.9.3 or greater.</p>
94
+
93
95
  <h2 id="OPTIONS">OPTIONS</h2>
94
96
 
95
97
  <dl>
@@ -124,6 +126,14 @@ use in places that expect a link to a file like an HTML IMG tag.</dd>
124
126
  http://cl.ly/abc123
125
127
  </code></pre>
126
128
 
129
+ <p>Upload several files:</p>
130
+
131
+ <pre><code>$ cloudapp upload *.png
132
+ http://cl.ly/abc123
133
+ http://cl.ly/def456
134
+ http://cl.ly/ghi789
135
+ </code></pre>
136
+
127
137
  <p>Copy the drop's share link to the clipboard on OS X:</p>
128
138
 
129
139
  <pre><code>$ cloudapp upload screenshot.png | pbcopy
data/man/cloudapp.1.ronn CHANGED
@@ -3,14 +3,16 @@ cloudapp(1) -- all the pleasures of cloudapp in a cli
3
3
 
4
4
  ## SYNOPSIS
5
5
 
6
- `cloudapp bookmark` [`--direct`] <url><br>
7
- `cloudapp upload` [`--direct`] <file>
6
+ `cloudapp bookmark` [`--direct`] <url> [<url>...]<br>
7
+ `cloudapp upload` [`--direct`] <file> [<file>...]
8
8
 
9
9
  ## DESCRIPTION
10
10
 
11
11
  Upload a file or share a bookmark with CloudApp. The drop's share link will be
12
12
  printed to standard output. Account credentials are stored in `~/.netrc`.
13
13
 
14
+ **cloudapp** requires ruby 1.9.3 or greater.
15
+
14
16
  ## OPTIONS
15
17
 
16
18
  - `-d`, `--direct`:
@@ -37,6 +39,13 @@ Upload a file:
37
39
  $ cloudapp upload screenshot.png
38
40
  http://cl.ly/abc123
39
41
 
42
+ Upload several files:
43
+
44
+ $ cloudapp upload *.png
45
+ http://cl.ly/abc123
46
+ http://cl.ly/def456
47
+ http://cl.ly/ghi789
48
+
40
49
  Copy the drop's share link to the clipboard on OS X:
41
50
 
42
51
  $ cloudapp upload screenshot.png | pbcopy
data/script/docs ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ git co gh-pages &&
4
+ git show master:man/cloudapp.1.html > index.html &&
5
+ git commit -am "Update docs" &&
6
+ git co master
@@ -1,3 +1,4 @@
1
+ require 'helper'
1
2
  require 'cloudapp/authorized'
2
3
 
3
4
  describe CloudApp::Authorized::Representation do
@@ -1,3 +1,4 @@
1
+ require 'helper'
1
2
  require 'cloudapp/collection_json/collection'
2
3
 
3
4
  describe CloudApp::CollectionJson::Collection do
@@ -66,4 +67,19 @@ describe CloudApp::CollectionJson::Collection do
66
67
  its(:href) { should eq 'http://href.com' }
67
68
  its(:data) { should eq 'first_name' => '', 'last_name' => '' }
68
69
  end
70
+
71
+ describe '#error' do
72
+ let(:data) {{
73
+ 'collection' => {
74
+ 'error' => { 'message' => 'error!' }}}}
75
+ subject { collection.error }
76
+
77
+ it { should be_an CloudApp::CollectionJson::Item }
78
+ its(:message) { should eq 'error!' }
79
+
80
+ context 'with no error' do
81
+ let(:data) {{ 'collection' => {} }}
82
+ it { should be_nil }
83
+ end
84
+ end
69
85
  end
@@ -1,3 +1,4 @@
1
+ require 'helper'
1
2
  require 'cloudapp/collection_json/item'
2
3
 
3
4
  describe CloudApp::CollectionJson::Item do
@@ -13,6 +14,11 @@ describe CloudApp::CollectionJson::Item do
13
14
  its(:rel) { should eq 'relation' }
14
15
  end
15
16
 
17
+ describe '#message' do
18
+ let(:data) {{ 'message' => 'error!' }}
19
+ its(:message) { should eq 'error!' }
20
+ end
21
+
16
22
  describe '#links' do
17
23
  subject { described_class.new(data).links }
18
24
  let(:data) {{ 'links' => [
@@ -1,3 +1,4 @@
1
+ require 'helper'
1
2
  require 'cloudapp/collection_json/template'
2
3
 
3
4
  describe CloudApp::CollectionJson::Template do
@@ -1,3 +1,4 @@
1
+ require 'helper'
1
2
  require 'cloudapp/credentials'
2
3
 
3
4
  describe Credentials do
data/spec/helper.rb ADDED
@@ -0,0 +1,8 @@
1
+ begin
2
+ # use `bundle install --standalone' to get this...
3
+ require_relative '../bundle/bundler/setup'
4
+ rescue LoadError
5
+ # fall back to regular bundler if the developer hasn't bundled standalone
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
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.8
4
+ version: 2.0.0.beta.9
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: 2012-12-23 00:00:00.000000000 Z
12
+ date: 2012-12-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: netrc
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 0.0.7
37
+ version: 0.1.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 0.0.7
45
+ version: 0.1.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: mime-types
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -151,11 +151,13 @@ files:
151
151
  - man/cloudapp.1
152
152
  - man/cloudapp.1.html
153
153
  - man/cloudapp.1.ronn
154
+ - script/docs
154
155
  - spec/cloudapp/authorized_spec.rb
155
156
  - spec/cloudapp/collection_json/collection_spec.rb
156
157
  - spec/cloudapp/collection_json/item_spec.rb
157
158
  - spec/cloudapp/collection_json/template_spec.rb
158
159
  - spec/cloudapp/credentials_spec.rb
160
+ - spec/helper.rb
159
161
  homepage: https://github.com/cloudapp/cloudapp
160
162
  licenses: []
161
163
  post_install_message:
@@ -169,6 +171,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
171
  - - ! '>='
170
172
  - !ruby/object:Gem::Version
171
173
  version: '0'
174
+ segments:
175
+ - 0
176
+ hash: -2960018242600154187
172
177
  required_rubygems_version: !ruby/object:Gem::Requirement
173
178
  none: false
174
179
  requirements: