cloudapp 1.1.0 → 2.0.0.beta.1
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/CHANGELOG.md +3 -0
- data/Gemfile.lock +18 -34
- data/README.md +2 -1
- data/Rakefile +5 -1
- data/cloudapp.gemspec +50 -41
- data/lib/cloudapp/account.rb +111 -0
- data/lib/cloudapp/authorized_representation.rb +17 -0
- data/lib/cloudapp/collection_json/item.rb +20 -0
- data/lib/cloudapp/collection_json/representation.rb +74 -0
- data/lib/cloudapp/collection_json/template.rb +17 -0
- data/lib/cloudapp/collection_json/tint.rb +11 -0
- data/lib/cloudapp/collection_json.rb +3 -0
- data/lib/cloudapp/drop.rb +22 -6
- data/lib/cloudapp/drop_collection.rb +22 -0
- data/lib/cloudapp/service.rb +172 -0
- data/lib/cloudapp/token.rb +27 -0
- data/lib/cloudapp.rb +5 -1
- data/man/cloudapp.1 +202 -45
- data/man/cloudapp.1.html +114 -42
- data/man/cloudapp.1.ronn +125 -45
- data/spec/cassettes/create_bookmark.yml +255 -0
- data/spec/cassettes/create_bookmark_with_name.yml +266 -0
- data/spec/cassettes/create_bookmark_with_privacy.yml +277 -0
- data/spec/cassettes/delete_drop.yml +383 -0
- data/spec/cassettes/list_drops.yml +139 -0
- data/spec/cassettes/list_drops_with_bad_token.yml +57 -0
- data/spec/cassettes/list_drops_with_filter.yml +209 -0
- data/spec/cassettes/list_drops_with_href.yml +287 -0
- data/spec/cassettes/list_drops_with_href_and_filter.yml +287 -0
- data/spec/cassettes/list_drops_with_href_and_limit.yml +287 -0
- data/spec/cassettes/list_drops_with_limit.yml +211 -0
- data/spec/cassettes/list_drops_with_nil_href.yml +139 -0
- data/spec/cassettes/purge_drops.yml +1103 -0
- data/spec/cassettes/recover_drop.yml +628 -0
- data/spec/cassettes/rename_drop.yml +367 -0
- data/spec/cassettes/setup_drops.yml +968 -0
- data/spec/cassettes/token_for_account.yml +127 -0
- data/spec/cassettes/token_for_account_with_bad_credentials.yml +115 -0
- data/spec/cassettes/trash_drop.yml +478 -0
- data/spec/cassettes/update_drop_bookmark_url.yml +379 -0
- data/spec/cassettes/update_file.yml +573 -0
- data/spec/cassettes/upload_file.yml +470 -0
- data/spec/cassettes/upload_file_with_name.yml +484 -0
- data/spec/cassettes/upload_file_with_privacy.yml +495 -0
- data/spec/cassettes/view_drop.yml +73 -0
- data/spec/cloudapp/account_spec.rb +166 -0
- data/spec/cloudapp/authorized_representation_spec.rb +32 -0
- data/spec/cloudapp/collection_json/item_spec.rb +45 -0
- data/spec/cloudapp/collection_json/representation_spec.rb +118 -0
- data/spec/cloudapp/collection_json/template_spec.rb +53 -0
- data/spec/cloudapp/drop_collection_spec.rb +63 -0
- data/spec/cloudapp/drop_spec.rb +81 -51
- data/spec/cloudapp/service_spec.rb +357 -0
- data/spec/cloudapp/token_spec.rb +33 -0
- data/spec/integration_spec.rb +100 -0
- data/spec/support/stub_class_or_module.rb +6 -3
- data/spec/support/vcr.rb +21 -5
- metadata +84 -106
- data/bin/cloudapp +0 -184
- data/lib/cloudapp/config.rb +0 -39
- data/lib/cloudapp/drop_content.rb +0 -34
- data/lib/cloudapp/drop_presenter.rb +0 -80
- data/lib/cloudapp/drop_service.rb +0 -255
- data/lib/cloudapp/identity.rb +0 -14
- data/spec/cassettes/DropContent/download.yml +0 -116
- data/spec/cassettes/DropService/create_bookmark.yml +0 -105
- data/spec/cassettes/DropService/create_bookmark_with_bad_credentials.yml +0 -39
- data/spec/cassettes/DropService/create_bookmark_with_name.yml +0 -105
- data/spec/cassettes/DropService/create_private_bookmark.yml +0 -105
- data/spec/cassettes/DropService/create_public_bookmark.yml +0 -105
- data/spec/cassettes/DropService/drop.yml +0 -81
- data/spec/cassettes/DropService/list_drops.yml +0 -135
- data/spec/cassettes/DropService/list_drops_with_bad_credentials.yml +0 -39
- data/spec/cassettes/DropService/list_drops_with_limit.yml +0 -117
- data/spec/cassettes/DropService/list_trash.yml +0 -111
- data/spec/cassettes/DropService/list_trash_with_bad_credentials.yml +0 -39
- data/spec/cassettes/DropService/retrieve_token.yml +0 -42
- data/spec/cassettes/DropService/retrieve_token_with_bad_credentials.yml +0 -43
- data/spec/cassettes/DropService/upload_file.yml +0 -291
- data/spec/cassettes/DropService/upload_public_file.yml +0 -293
- data/spec/cloudapp/config_spec.rb +0 -59
- data/spec/cloudapp/drop_content_spec.rb +0 -21
- data/spec/cloudapp/drop_presenter_spec.rb +0 -120
- data/spec/cloudapp/drop_service_spec.rb +0 -400
- data/spec/cloudapp/identity_spec.rb +0 -27
- data/spec/support/fakefs_rspec.rb +0 -5
- data/spec/support/vcr_rspec.rb +0 -9
metadata
CHANGED
|
@@ -1,96 +1,67 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cloudapp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 2.0.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: 2012-
|
|
12
|
+
date: 2012-08-17 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
16
|
-
requirement:
|
|
17
|
-
none: false
|
|
18
|
-
requirements:
|
|
19
|
-
- - ! '>='
|
|
20
|
-
- !ruby/object:Gem::Version
|
|
21
|
-
version: '0'
|
|
22
|
-
type: :runtime
|
|
23
|
-
prerelease: false
|
|
24
|
-
version_requirements: *70180042556660
|
|
25
|
-
- !ruby/object:Gem::Dependency
|
|
26
|
-
name: faraday
|
|
27
|
-
requirement: &70180042552240 !ruby/object:Gem::Requirement
|
|
15
|
+
name: leadlight
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
28
17
|
none: false
|
|
29
18
|
requirements:
|
|
30
|
-
- -
|
|
19
|
+
- - '='
|
|
31
20
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
21
|
+
version: 0.0.5
|
|
33
22
|
type: :runtime
|
|
34
23
|
prerelease: false
|
|
35
|
-
version_requirements:
|
|
36
|
-
- !ruby/object:Gem::Dependency
|
|
37
|
-
name: gli
|
|
38
|
-
requirement: &70180042550960 !ruby/object:Gem::Requirement
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
25
|
none: false
|
|
40
26
|
requirements:
|
|
41
|
-
- -
|
|
27
|
+
- - '='
|
|
42
28
|
- !ruby/object:Gem::Version
|
|
43
|
-
version:
|
|
44
|
-
type: :runtime
|
|
45
|
-
prerelease: false
|
|
46
|
-
version_requirements: *70180042550960
|
|
29
|
+
version: 0.0.5
|
|
47
30
|
- !ruby/object:Gem::Dependency
|
|
48
|
-
name:
|
|
49
|
-
requirement:
|
|
31
|
+
name: typhoeus
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
33
|
none: false
|
|
51
34
|
requirements:
|
|
52
|
-
- -
|
|
35
|
+
- - ~>
|
|
53
36
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
37
|
+
version: 0.3.3
|
|
55
38
|
type: :runtime
|
|
56
39
|
prerelease: false
|
|
57
|
-
version_requirements:
|
|
58
|
-
- !ruby/object:Gem::Dependency
|
|
59
|
-
name: leadlight
|
|
60
|
-
requirement: &70180042545740 !ruby/object:Gem::Requirement
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
61
41
|
none: false
|
|
62
42
|
requirements:
|
|
63
43
|
- - ~>
|
|
64
44
|
- !ruby/object:Gem::Version
|
|
65
|
-
version: 0.
|
|
66
|
-
type: :runtime
|
|
67
|
-
prerelease: false
|
|
68
|
-
version_requirements: *70180042545740
|
|
45
|
+
version: 0.3.3
|
|
69
46
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
71
|
-
requirement:
|
|
47
|
+
name: rake
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
49
|
none: false
|
|
73
50
|
requirements:
|
|
74
51
|
- - ! '>='
|
|
75
52
|
- !ruby/object:Gem::Version
|
|
76
53
|
version: '0'
|
|
77
|
-
type: :
|
|
54
|
+
type: :development
|
|
78
55
|
prerelease: false
|
|
79
|
-
version_requirements:
|
|
80
|
-
- !ruby/object:Gem::Dependency
|
|
81
|
-
name: fakefs
|
|
82
|
-
requirement: &70180038451940 !ruby/object:Gem::Requirement
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
83
57
|
none: false
|
|
84
58
|
requirements:
|
|
85
59
|
- - ! '>='
|
|
86
60
|
- !ruby/object:Gem::Version
|
|
87
61
|
version: '0'
|
|
88
|
-
type: :development
|
|
89
|
-
prerelease: false
|
|
90
|
-
version_requirements: *70180038451940
|
|
91
62
|
- !ruby/object:Gem::Dependency
|
|
92
|
-
name:
|
|
93
|
-
requirement:
|
|
63
|
+
name: rspec
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
94
65
|
none: false
|
|
95
66
|
requirements:
|
|
96
67
|
- - ! '>='
|
|
@@ -98,43 +69,31 @@ dependencies:
|
|
|
98
69
|
version: '0'
|
|
99
70
|
type: :development
|
|
100
71
|
prerelease: false
|
|
101
|
-
version_requirements:
|
|
102
|
-
- !ruby/object:Gem::Dependency
|
|
103
|
-
name: ronn
|
|
104
|
-
requirement: &70180038449860 !ruby/object:Gem::Requirement
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
73
|
none: false
|
|
106
74
|
requirements:
|
|
107
75
|
- - ! '>='
|
|
108
76
|
- !ruby/object:Gem::Version
|
|
109
77
|
version: '0'
|
|
110
|
-
type: :development
|
|
111
|
-
prerelease: false
|
|
112
|
-
version_requirements: *70180038449860
|
|
113
78
|
- !ruby/object:Gem::Dependency
|
|
114
|
-
name:
|
|
115
|
-
requirement:
|
|
79
|
+
name: vcr
|
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
|
116
81
|
none: false
|
|
117
82
|
requirements:
|
|
118
|
-
- -
|
|
83
|
+
- - ~>
|
|
119
84
|
- !ruby/object:Gem::Version
|
|
120
|
-
version:
|
|
85
|
+
version: 2.0.0
|
|
121
86
|
type: :development
|
|
122
87
|
prerelease: false
|
|
123
|
-
version_requirements:
|
|
124
|
-
- !ruby/object:Gem::Dependency
|
|
125
|
-
name: vcr
|
|
126
|
-
requirement: &70180038448640 !ruby/object:Gem::Requirement
|
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
127
89
|
none: false
|
|
128
90
|
requirements:
|
|
129
91
|
- - ~>
|
|
130
92
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: 2.0.0
|
|
132
|
-
type: :development
|
|
133
|
-
prerelease: false
|
|
134
|
-
version_requirements: *70180038448640
|
|
93
|
+
version: 2.0.0
|
|
135
94
|
- !ruby/object:Gem::Dependency
|
|
136
95
|
name: webmock
|
|
137
|
-
requirement:
|
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
|
138
97
|
none: false
|
|
139
98
|
requirements:
|
|
140
99
|
- - ! '>='
|
|
@@ -142,11 +101,15 @@ dependencies:
|
|
|
142
101
|
version: '0'
|
|
143
102
|
type: :development
|
|
144
103
|
prerelease: false
|
|
145
|
-
version_requirements:
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ! '>='
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
146
110
|
description: Experience all the pleasures of sharing with CloudApp now in your terminal.
|
|
147
111
|
email: larry@marburger.cc
|
|
148
|
-
executables:
|
|
149
|
-
- cloudapp
|
|
112
|
+
executables: []
|
|
150
113
|
extensions: []
|
|
151
114
|
extra_rdoc_files:
|
|
152
115
|
- README.md
|
|
@@ -158,46 +121,61 @@ files:
|
|
|
158
121
|
- MIT-LICENSE
|
|
159
122
|
- README.md
|
|
160
123
|
- Rakefile
|
|
161
|
-
- bin/cloudapp
|
|
162
124
|
- cloudapp.gemspec
|
|
163
125
|
- lib/cloudapp.rb
|
|
164
|
-
- lib/cloudapp/
|
|
126
|
+
- lib/cloudapp/account.rb
|
|
127
|
+
- lib/cloudapp/authorized_representation.rb
|
|
128
|
+
- lib/cloudapp/collection_json.rb
|
|
129
|
+
- lib/cloudapp/collection_json/item.rb
|
|
130
|
+
- lib/cloudapp/collection_json/representation.rb
|
|
131
|
+
- lib/cloudapp/collection_json/template.rb
|
|
132
|
+
- lib/cloudapp/collection_json/tint.rb
|
|
165
133
|
- lib/cloudapp/drop.rb
|
|
166
|
-
- lib/cloudapp/
|
|
167
|
-
- lib/cloudapp/
|
|
168
|
-
- lib/cloudapp/
|
|
169
|
-
- lib/cloudapp/identity.rb
|
|
134
|
+
- lib/cloudapp/drop_collection.rb
|
|
135
|
+
- lib/cloudapp/service.rb
|
|
136
|
+
- lib/cloudapp/token.rb
|
|
170
137
|
- man/cloudapp.1
|
|
171
138
|
- man/cloudapp.1.html
|
|
172
139
|
- man/cloudapp.1.ronn
|
|
173
|
-
- spec/cassettes/
|
|
174
|
-
- spec/cassettes/
|
|
175
|
-
- spec/cassettes/
|
|
176
|
-
- spec/cassettes/
|
|
177
|
-
- spec/cassettes/
|
|
178
|
-
- spec/cassettes/
|
|
179
|
-
- spec/cassettes/
|
|
180
|
-
- spec/cassettes/
|
|
181
|
-
- spec/cassettes/
|
|
182
|
-
- spec/cassettes/
|
|
183
|
-
- spec/cassettes/
|
|
184
|
-
- spec/cassettes/
|
|
185
|
-
- spec/cassettes/
|
|
186
|
-
- spec/cassettes/
|
|
187
|
-
- spec/cassettes/
|
|
188
|
-
- spec/cassettes/
|
|
189
|
-
- spec/
|
|
190
|
-
- spec/
|
|
191
|
-
- spec/
|
|
192
|
-
- spec/
|
|
140
|
+
- spec/cassettes/create_bookmark.yml
|
|
141
|
+
- spec/cassettes/create_bookmark_with_name.yml
|
|
142
|
+
- spec/cassettes/create_bookmark_with_privacy.yml
|
|
143
|
+
- spec/cassettes/delete_drop.yml
|
|
144
|
+
- spec/cassettes/list_drops.yml
|
|
145
|
+
- spec/cassettes/list_drops_with_bad_token.yml
|
|
146
|
+
- spec/cassettes/list_drops_with_filter.yml
|
|
147
|
+
- spec/cassettes/list_drops_with_href.yml
|
|
148
|
+
- spec/cassettes/list_drops_with_href_and_filter.yml
|
|
149
|
+
- spec/cassettes/list_drops_with_href_and_limit.yml
|
|
150
|
+
- spec/cassettes/list_drops_with_limit.yml
|
|
151
|
+
- spec/cassettes/list_drops_with_nil_href.yml
|
|
152
|
+
- spec/cassettes/purge_drops.yml
|
|
153
|
+
- spec/cassettes/recover_drop.yml
|
|
154
|
+
- spec/cassettes/rename_drop.yml
|
|
155
|
+
- spec/cassettes/setup_drops.yml
|
|
156
|
+
- spec/cassettes/token_for_account.yml
|
|
157
|
+
- spec/cassettes/token_for_account_with_bad_credentials.yml
|
|
158
|
+
- spec/cassettes/trash_drop.yml
|
|
159
|
+
- spec/cassettes/update_drop_bookmark_url.yml
|
|
160
|
+
- spec/cassettes/update_file.yml
|
|
161
|
+
- spec/cassettes/upload_file.yml
|
|
162
|
+
- spec/cassettes/upload_file_with_name.yml
|
|
163
|
+
- spec/cassettes/upload_file_with_privacy.yml
|
|
164
|
+
- spec/cassettes/view_drop.yml
|
|
165
|
+
- spec/cloudapp/account_spec.rb
|
|
166
|
+
- spec/cloudapp/authorized_representation_spec.rb
|
|
167
|
+
- spec/cloudapp/collection_json/item_spec.rb
|
|
168
|
+
- spec/cloudapp/collection_json/representation_spec.rb
|
|
169
|
+
- spec/cloudapp/collection_json/template_spec.rb
|
|
170
|
+
- spec/cloudapp/drop_collection_spec.rb
|
|
193
171
|
- spec/cloudapp/drop_spec.rb
|
|
194
|
-
- spec/cloudapp/
|
|
172
|
+
- spec/cloudapp/service_spec.rb
|
|
173
|
+
- spec/cloudapp/token_spec.rb
|
|
195
174
|
- spec/helper.rb
|
|
196
|
-
- spec/
|
|
175
|
+
- spec/integration_spec.rb
|
|
197
176
|
- spec/support/files/favicon.ico
|
|
198
177
|
- spec/support/stub_class_or_module.rb
|
|
199
178
|
- spec/support/vcr.rb
|
|
200
|
-
- spec/support/vcr_rspec.rb
|
|
201
179
|
homepage: https://github.com/cloudapp/cloudapp
|
|
202
180
|
licenses: []
|
|
203
181
|
post_install_message:
|
|
@@ -214,12 +192,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
214
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
193
|
none: false
|
|
216
194
|
requirements:
|
|
217
|
-
- - ! '
|
|
195
|
+
- - ! '>'
|
|
218
196
|
- !ruby/object:Gem::Version
|
|
219
|
-
version:
|
|
197
|
+
version: 1.3.1
|
|
220
198
|
requirements: []
|
|
221
199
|
rubyforge_project: cloudapp
|
|
222
|
-
rubygems_version: 1.8.
|
|
200
|
+
rubygems_version: 1.8.23
|
|
223
201
|
signing_key:
|
|
224
202
|
specification_version: 2
|
|
225
203
|
summary: CloudApp CLI
|
data/bin/cloudapp
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
|
3
|
-
|
|
4
|
-
require 'rubygems'
|
|
5
|
-
require 'gli'
|
|
6
|
-
require 'highline'
|
|
7
|
-
require 'pathname'
|
|
8
|
-
|
|
9
|
-
require 'cloudapp'
|
|
10
|
-
require 'cloudapp/config'
|
|
11
|
-
require 'cloudapp/drop_presenter'
|
|
12
|
-
require 'cloudapp/drop_service'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
extend Forwardable
|
|
16
|
-
def_delegator 'HighLine.new', :color
|
|
17
|
-
|
|
18
|
-
def config
|
|
19
|
-
CloudApp::Config.new
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def service
|
|
23
|
-
CloudApp::DropService.using_token config.token
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def require_credentials
|
|
27
|
-
return unless config.token.nil?
|
|
28
|
-
|
|
29
|
-
$stdout.puts 'Sign into your CloudApp account.'
|
|
30
|
-
|
|
31
|
-
email = HighLine.new.ask('Email: ')
|
|
32
|
-
password = HighLine.new.ask('Password: ') {|q| q.echo = false }
|
|
33
|
-
config.token = CloudApp::DropService.retrieve_token email, password
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def format_from_options(options)
|
|
37
|
-
if options[:format].nil?
|
|
38
|
-
$stdout.tty? ? :pretty : :csv
|
|
39
|
-
else
|
|
40
|
-
options[:format].to_sym
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def privacy_from_options(options)
|
|
45
|
-
if options[:private] || options[:public]
|
|
46
|
-
options[:private] || !options[:public]
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def create_drop_action_on_command(c)
|
|
51
|
-
c.desc 'Use a private (long) link'
|
|
52
|
-
c.switch :private
|
|
53
|
-
|
|
54
|
-
c.desc 'Use a public (short) link'
|
|
55
|
-
c.switch :public
|
|
56
|
-
|
|
57
|
-
c.action do |global_options, options, args|
|
|
58
|
-
require_credentials
|
|
59
|
-
format = format_from_options global_options
|
|
60
|
-
private = privacy_from_options options
|
|
61
|
-
|
|
62
|
-
yield format, private, args
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
include GLI
|
|
68
|
-
|
|
69
|
-
program_desc 'All the pleasures of CloudApp now at your terminal'
|
|
70
|
-
version CloudApp::VERSION
|
|
71
|
-
|
|
72
|
-
desc 'Output format (default: pretty for tty, csv otherwise)'
|
|
73
|
-
arg_name 'csv|pretty'
|
|
74
|
-
flag [:f, :format]
|
|
75
|
-
|
|
76
|
-
desc 'Create a new bookmark to each url and print each link'
|
|
77
|
-
arg_name 'url [url...]'
|
|
78
|
-
command :bookmark do |c|
|
|
79
|
-
create_drop_action_on_command(c) do |format, private, urls|
|
|
80
|
-
urls.each do |url|
|
|
81
|
-
url = URI.parse url
|
|
82
|
-
waiting = "Bookmarking #{ url }... "
|
|
83
|
-
|
|
84
|
-
CloudApp::DropPresenter.print(on: $stdout,
|
|
85
|
-
waiting: waiting,
|
|
86
|
-
format: format) do
|
|
87
|
-
new_options = { url: url }
|
|
88
|
-
new_options[:private] = private unless private.nil?
|
|
89
|
-
|
|
90
|
-
new_drop = service.create new_options
|
|
91
|
-
new_drop.url
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
desc 'Upload each file and print each link'
|
|
98
|
-
arg_name 'file [file...]'
|
|
99
|
-
command :upload do |c|
|
|
100
|
-
create_drop_action_on_command(c) do |format, private, files|
|
|
101
|
-
files.each do |file|
|
|
102
|
-
file = Pathname.new file
|
|
103
|
-
waiting = "Uploading #{ file }... "
|
|
104
|
-
|
|
105
|
-
CloudApp::DropPresenter.print(on: $stdout,
|
|
106
|
-
waiting: waiting,
|
|
107
|
-
format: format) do
|
|
108
|
-
new_options = { path: file }
|
|
109
|
-
new_options[:private] = private unless private.nil?
|
|
110
|
-
|
|
111
|
-
new_drop = service.create new_options
|
|
112
|
-
new_drop.url
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
desc 'List the most recent drops'
|
|
119
|
-
command [:list, :ls] do |c|
|
|
120
|
-
|
|
121
|
-
c.desc 'Number of drops to display'
|
|
122
|
-
c.arg_name 'count'
|
|
123
|
-
c.default_value '20'
|
|
124
|
-
c.flag :n, :count
|
|
125
|
-
|
|
126
|
-
c.action do |global_options, options, args|
|
|
127
|
-
require_credentials
|
|
128
|
-
|
|
129
|
-
count = options[:count].to_i
|
|
130
|
-
columns = { display_name: 'Name', url: 'Link', view_counter: 'Views' }
|
|
131
|
-
format = format_from_options global_options
|
|
132
|
-
|
|
133
|
-
CloudApp::DropPresenter.print(on: $stdout,
|
|
134
|
-
columns: columns,
|
|
135
|
-
format: format) do
|
|
136
|
-
service.drops count
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
desc 'Download the drop at <url>'
|
|
143
|
-
arg_name 'url'
|
|
144
|
-
command :download do |c|
|
|
145
|
-
|
|
146
|
-
c.desc 'Download the file to <file>'
|
|
147
|
-
c.arg_name 'file'
|
|
148
|
-
c.flag :o, :output
|
|
149
|
-
|
|
150
|
-
c.action do |global_options, options, urls|
|
|
151
|
-
format = format_from_options global_options
|
|
152
|
-
download_options = {}
|
|
153
|
-
download_options[:to] = options[:output] if options[:output]
|
|
154
|
-
|
|
155
|
-
urls.each do |url|
|
|
156
|
-
url = URI.parse url
|
|
157
|
-
waiting = "Downloading #{ url }... "
|
|
158
|
-
|
|
159
|
-
CloudApp::DropPresenter.print(on: $stdout,
|
|
160
|
-
waiting: waiting,
|
|
161
|
-
format: format) do
|
|
162
|
-
content = service.download_drop url, download_options
|
|
163
|
-
{ pretty: 'done', csv: content }
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
on_error do |e|
|
|
171
|
-
case e
|
|
172
|
-
when CloudApp::DropService::UNAUTHORIZED
|
|
173
|
-
$stderr.puts color('Email and password given are incorrect.', :bold)
|
|
174
|
-
config.token = nil
|
|
175
|
-
false
|
|
176
|
-
when CloudApp::DropService::NO_CONTENT
|
|
177
|
-
$stderr.puts 'drop was deleted or is a bookmark'
|
|
178
|
-
false
|
|
179
|
-
else
|
|
180
|
-
true
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
exit GLI.run(ARGV)
|
data/lib/cloudapp/config.rb
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require 'pathname'
|
|
2
|
-
require 'singleton'
|
|
3
|
-
require 'yaml'
|
|
4
|
-
|
|
5
|
-
module CloudApp
|
|
6
|
-
class Config
|
|
7
|
-
def initialize(path = File.expand_path('~/.cloudapprc'))
|
|
8
|
-
@path = path
|
|
9
|
-
@config = read_config
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def token
|
|
13
|
-
@config[:token]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def token=(token)
|
|
17
|
-
if token
|
|
18
|
-
@config[:token] = token
|
|
19
|
-
else
|
|
20
|
-
@config.delete :token
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
write_config
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
def read_config
|
|
29
|
-
return {} unless File.exist?(@path)
|
|
30
|
-
File.open(@path) {|file| YAML.load(file) }
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def write_config
|
|
34
|
-
File.open(@path, 'w', 0600) {|file|
|
|
35
|
-
YAML.dump @config, file
|
|
36
|
-
}
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require 'faraday'
|
|
2
|
-
require 'logger'
|
|
3
|
-
require 'typhoeus'
|
|
4
|
-
|
|
5
|
-
module CloudApp
|
|
6
|
-
class DropContent
|
|
7
|
-
def initialize(drop)
|
|
8
|
-
@content_url = drop.content_url
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.download(drop)
|
|
12
|
-
new(drop).content
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def content(url = @content_url)
|
|
16
|
-
connection.get(url) do |req|
|
|
17
|
-
req.headers['Accept'] = 'application/json'
|
|
18
|
-
end.on_complete do |env|
|
|
19
|
-
location = env[:response]['location']
|
|
20
|
-
if location
|
|
21
|
-
return content(location)
|
|
22
|
-
else
|
|
23
|
-
return env[:body]
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def connection
|
|
29
|
-
Faraday.new do |builder|
|
|
30
|
-
builder.adapter :typhoeus
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
require 'csv'
|
|
2
|
-
require 'delegate'
|
|
3
|
-
|
|
4
|
-
module CloudApp
|
|
5
|
-
class DropPresenter
|
|
6
|
-
def initialize(io, format, waiting, columns, action)
|
|
7
|
-
@io = io
|
|
8
|
-
@format = format
|
|
9
|
-
@waiting = waiting
|
|
10
|
-
@columns = columns
|
|
11
|
-
@action = action
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def self.print(options, &action)
|
|
15
|
-
new(options.fetch(:on),
|
|
16
|
-
options.fetch(:format, :pretty),
|
|
17
|
-
options.fetch(:waiting, nil),
|
|
18
|
-
options.fetch(:columns, nil),
|
|
19
|
-
action).print
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def pretty?() @format == :pretty end
|
|
23
|
-
def csv?() @format == :csv end
|
|
24
|
-
|
|
25
|
-
def print
|
|
26
|
-
@io.print @waiting if pretty?
|
|
27
|
-
@io.puts lines
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
protected
|
|
31
|
-
|
|
32
|
-
def lines
|
|
33
|
-
if not @columns
|
|
34
|
-
response
|
|
35
|
-
else
|
|
36
|
-
headings = @columns.values
|
|
37
|
-
lines = response.inject([ headings ]) do |lines, item|
|
|
38
|
-
lines << extract_values(item)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
if csv?
|
|
42
|
-
csv = CSV.generate do |csv|
|
|
43
|
-
lines.each do |line|
|
|
44
|
-
csv << line
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
else
|
|
48
|
-
column_widths = lines.transpose.map do |column|
|
|
49
|
-
column.map(&:size).max
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
lines.map do |line|
|
|
53
|
-
line.each_with_index.map do |value, i|
|
|
54
|
-
value.ljust column_widths[i]
|
|
55
|
-
end.join ' '
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def extract_values(item)
|
|
62
|
-
value_methods.map do |method|
|
|
63
|
-
item.send(method).to_s
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def value_methods
|
|
68
|
-
@columns.keys
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def response
|
|
72
|
-
@response ||= @action.call
|
|
73
|
-
|
|
74
|
-
case @response
|
|
75
|
-
when Hash then @response.fetch(@format, @response)
|
|
76
|
-
else @response
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|