cloudapp 2.0.0.beta.4 → 2.0.0.beta.5
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/Gemfile.lock +12 -19
- data/README.md +60 -6
- data/Rakefile +1 -19
- data/bin/cloudapp +48 -0
- data/cloudapp.gemspec +11 -42
- data/lib/cloudapp/authorized.rb +14 -0
- data/lib/cloudapp/collection_json.rb +86 -3
- data/lib/cloudapp/credentials.rb +115 -0
- data/lib/cloudapp/service.rb +43 -146
- data/lib/cloudapp.rb +1 -3
- data/man/cloudapp.1 +100 -0
- data/man/cloudapp.1.html +157 -0
- data/man/cloudapp.1.ronn +56 -0
- metadata +24 -69
- data/CHANGELOG.md +0 -34
- data/lib/cloudapp/authorized_representation.rb +0 -17
- data/lib/cloudapp/collection_json/item.rb +0 -20
- data/lib/cloudapp/collection_json/representation.rb +0 -74
- data/lib/cloudapp/collection_json/template.rb +0 -17
- data/lib/cloudapp/collection_json/tint.rb +0 -11
- data/lib/cloudapp/drop.rb +0 -37
- data/lib/cloudapp/drop_collection.rb +0 -37
- data/spec/cassettes/account_token.yml +0 -88
- data/spec/cassettes/create_bookmark.yml +0 -132
- data/spec/cassettes/create_bookmark_with_name.yml +0 -133
- data/spec/cassettes/create_bookmark_with_privacy.yml +0 -133
- data/spec/cassettes/list_drops.yml +0 -87
- data/spec/cassettes/list_drops_with_bad_token.yml +0 -45
- data/spec/cassettes/list_drops_with_filter.yml +0 -129
- data/spec/cassettes/list_drops_with_limit.yml +0 -129
- data/spec/cassettes/purge_drops.yml +0 -466
- data/spec/cassettes/setup_drops.yml +0 -620
- data/spec/cassettes/token_for_account.yml +0 -88
- data/spec/cassettes/token_for_account_with_bad_credentials.yml +0 -86
- data/spec/cassettes/upload_file.yml +0 -276
- data/spec/cassettes/upload_file_with_name.yml +0 -278
- data/spec/cassettes/upload_file_with_privacy.yml +0 -277
- data/spec/cassettes/view_drop.yml +0 -45
- data/spec/cloudapp/authorized_representation_spec.rb +0 -32
- data/spec/cloudapp/collection_json/item_spec.rb +0 -45
- data/spec/cloudapp/collection_json/representation_spec.rb +0 -118
- data/spec/cloudapp/collection_json/template_spec.rb +0 -53
- data/spec/cloudapp/drop_collection_spec.rb +0 -127
- data/spec/cloudapp/drop_spec.rb +0 -142
- data/spec/cloudapp/service_spec.rb +0 -335
- data/spec/helper.rb +0 -8
- data/spec/integration_spec.rb +0 -68
- data/spec/support/files/favicon.ico +0 -0
- data/spec/support/stub_class_or_module.rb +0 -22
- data/spec/support/vcr.rb +0 -24
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
require 'cloudapp/collection_json/item'
|
4
|
-
|
5
|
-
describe CloudApp::CollectionJson::Item do
|
6
|
-
let(:item_data) {{ 'data' => [] }}
|
7
|
-
subject { CloudApp::CollectionJson::Item.new item_data }
|
8
|
-
|
9
|
-
its(:href) { should be_nil }
|
10
|
-
its(:links) { should be_empty }
|
11
|
-
its(:data) { should be_empty }
|
12
|
-
|
13
|
-
context 'with an href' do
|
14
|
-
let(:href) { stub :href }
|
15
|
-
before do item_data['href'] = href end
|
16
|
-
its(:href) { should eq(href) }
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'with links' do
|
20
|
-
let(:links) {[
|
21
|
-
{ 'rel' => 'canonical', 'href' => 'link1' },
|
22
|
-
{ 'rel' => 'alternate', 'href' => 'link2' }
|
23
|
-
]}
|
24
|
-
before do item_data['links'] = links end
|
25
|
-
|
26
|
-
its(:links) { should have(2).items }
|
27
|
-
|
28
|
-
it 'presents links' do
|
29
|
-
subject.links.find {|link| link.rel == 'canonical' }.
|
30
|
-
href.should eq('link1')
|
31
|
-
subject.links.find {|link| link.rel == 'alternate' }.
|
32
|
-
href.should eq('link2')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'with data' do
|
37
|
-
let(:data) {[
|
38
|
-
{ 'name' => 'attr1', 'value' => 'value1' },
|
39
|
-
{ 'name' => 'attr2', 'value' => 'value2' }
|
40
|
-
]}
|
41
|
-
before do item_data['data'] = data end
|
42
|
-
|
43
|
-
its(:data) { should eq('attr1' => 'value1', 'attr2' => 'value2') }
|
44
|
-
end
|
45
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
require 'cloudapp/collection_json/representation'
|
4
|
-
|
5
|
-
describe CloudApp::CollectionJson::Representation do
|
6
|
-
let(:response) { stub :response, status: status }
|
7
|
-
let(:status) { 200 }
|
8
|
-
let(:representation) {{
|
9
|
-
'collection' => {
|
10
|
-
'href' => href,
|
11
|
-
'items' => []
|
12
|
-
}
|
13
|
-
}}
|
14
|
-
let(:href) { stub }
|
15
|
-
subject { representation }
|
16
|
-
before do
|
17
|
-
representation.extend CloudApp::CollectionJson::Representation
|
18
|
-
representation.stub __response__: response
|
19
|
-
end
|
20
|
-
|
21
|
-
its(:href) { should eq(href) }
|
22
|
-
|
23
|
-
describe '#collection_links' do
|
24
|
-
its(:collection_links) { should be_empty }
|
25
|
-
|
26
|
-
context 'with collection links' do
|
27
|
-
let(:links) {[
|
28
|
-
{ 'rel' => 'next', 'href' => '/next' },
|
29
|
-
{ 'rel' => 'prev', 'href' => '/prev' }
|
30
|
-
]}
|
31
|
-
before do representation['collection']['links'] = links end
|
32
|
-
|
33
|
-
its(:collection_links) { should have(2).items }
|
34
|
-
|
35
|
-
it 'presents links' do
|
36
|
-
subject.collection_links.find {|link| link.rel == 'next' }.
|
37
|
-
href.should eq('/next')
|
38
|
-
subject.collection_links.find {|link| link.rel == 'prev' }.
|
39
|
-
href.should eq('/prev')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#items' do
|
45
|
-
it 'is empty' do
|
46
|
-
subject.items(stub(:item_source)).should be_empty
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'with items' do
|
50
|
-
let(:items) {[ stub(:item1), stub(:item2) ]}
|
51
|
-
let(:item_data) {[ stub(:item_data1), stub(:item_data2) ]}
|
52
|
-
let(:item_source) { ->(item) {
|
53
|
-
if item == item_data[0]
|
54
|
-
items[0]
|
55
|
-
elsif item == item_data[1]
|
56
|
-
items[1]
|
57
|
-
end
|
58
|
-
}}
|
59
|
-
before do representation['collection']['items'] = item_data end
|
60
|
-
|
61
|
-
it 'should have items' do
|
62
|
-
subject.items(item_source).should eq(items)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#templates' do
|
68
|
-
it 'is nil' do
|
69
|
-
subject.template(stub(:template_source)).should be_nil
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'with a template' do
|
73
|
-
let(:template) { stub :template }
|
74
|
-
let(:template_data) { stub :template_data }
|
75
|
-
let(:template_source) { ->(item) { template if item == template_data }}
|
76
|
-
before do representation['collection']['template'] = template_data end
|
77
|
-
|
78
|
-
it 'finds the template' do
|
79
|
-
subject.template(template_source).should eq(template)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe '#queries' do
|
85
|
-
it 'is nil' do
|
86
|
-
subject.queries(stub(:query_source)).should be_nil
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'with queries' do
|
90
|
-
let(:queries) {[ stub(:query1), stub(:query2) ]}
|
91
|
-
let(:query_data) {[ stub(:query_data1), stub(:query_data2) ]}
|
92
|
-
let(:query_source) { ->(query) { queries.at(query_data.index(query)) }}
|
93
|
-
before do representation['collection']['queries'] = query_data end
|
94
|
-
|
95
|
-
it 'should have queries' do
|
96
|
-
subject.queries(query_source).should eq(queries)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe '#query' do
|
102
|
-
it 'is nil' do
|
103
|
-
subject.query('rel', stub(:query_source)).should be_nil
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'with queries' do
|
107
|
-
let(:queries) {[ stub(:query1, rel: 'one'),
|
108
|
-
stub(:query2, rel: 'two') ]}
|
109
|
-
let(:query_data) {[ stub(:query_data1), stub(:query_data2) ]}
|
110
|
-
let(:query_source) { ->(query) { queries.at(query_data.index(query)) }}
|
111
|
-
before do representation['collection']['queries'] = query_data end
|
112
|
-
|
113
|
-
it 'finds the query by rel' do
|
114
|
-
subject.query('one', query_source).should eq(queries.first)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
require 'cloudapp/collection_json/item'
|
3
|
-
|
4
|
-
require 'cloudapp/collection_json/template'
|
5
|
-
|
6
|
-
describe CloudApp::CollectionJson::Template do
|
7
|
-
let(:template_data) {{ 'data' => [] }}
|
8
|
-
subject { CloudApp::CollectionJson::Template.new template_data }
|
9
|
-
|
10
|
-
its(:rel) { should be_nil }
|
11
|
-
its(:enctype) { should be_nil }
|
12
|
-
|
13
|
-
|
14
|
-
context 'with a rel' do
|
15
|
-
let(:rel) { stub :rel }
|
16
|
-
before do template_data['rel'] = rel end
|
17
|
-
|
18
|
-
its(:rel) { should eq(rel) }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'with an encoding type' do
|
22
|
-
let(:enctype) { stub :enctype }
|
23
|
-
before do template_data['enctype'] = enctype end
|
24
|
-
|
25
|
-
its(:enctype) { should eq(enctype) }
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#fill' do
|
29
|
-
let(:email) { 'arthur@dent.com' }
|
30
|
-
let(:template_data) {{
|
31
|
-
'data' => [
|
32
|
-
{ 'name' => 'email', 'value' => '' },
|
33
|
-
{ 'name' => 'age', 'value' => 29 }
|
34
|
-
]
|
35
|
-
}}
|
36
|
-
|
37
|
-
it 'returns a filled template' do
|
38
|
-
expected = { 'email' => email, 'age' => 29 }
|
39
|
-
subject.fill('email' => email).should eq(expected)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'leaves data untouched' do
|
43
|
-
subject.fill('email' => email)
|
44
|
-
subject.data.should eq('email' => '', 'age' => 29)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'ignores attributes not in the template' do
|
48
|
-
expected = { 'email' => email, 'age' => 29 }
|
49
|
-
new_data = { 'email' => email, 'ignore' => 'me' }
|
50
|
-
subject.fill(new_data).should eq(expected)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,127 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
require 'cloudapp/drop_collection'
|
5
|
-
|
6
|
-
describe CloudApp::DropCollection do
|
7
|
-
let(:representation) { stub :representation, unauthorized?: false,
|
8
|
-
items: items }
|
9
|
-
let(:service) { stub :service }
|
10
|
-
let(:items) {[ stub(:item1), stub(:item2) ]}
|
11
|
-
let(:drop_class) { stub(:drop_class, new: :drop) }
|
12
|
-
subject { CloudApp::DropCollection.new representation, service, drop_class }
|
13
|
-
|
14
|
-
describe 'collection' do
|
15
|
-
it 'is a collection of drops' do
|
16
|
-
subject.size.should eq(2)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'decodes each drop' do
|
20
|
-
items.each do |drop|
|
21
|
-
drop_class.should_receive(:new).once.
|
22
|
-
with(drop, kind_of(CloudApp::DropCollection))
|
23
|
-
end
|
24
|
-
subject
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#authorized?' do
|
29
|
-
let(:authorized) { stub :authorized }
|
30
|
-
before do representation.stub(authorized?: authorized) end
|
31
|
-
|
32
|
-
it 'delegates to representation' do
|
33
|
-
subject.authorized?.should eq(authorized)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#unauthorized?' do
|
38
|
-
let(:unauthorized) { stub :unauthorized }
|
39
|
-
before do representation.stub(unauthorized?: unauthorized) end
|
40
|
-
|
41
|
-
it 'delegates to representation' do
|
42
|
-
subject.unauthorized?.should eq(unauthorized)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#follow' do
|
47
|
-
let(:link_representation) {
|
48
|
-
stub :link_representation, unauthorized?: false,
|
49
|
-
items: []
|
50
|
-
}
|
51
|
-
subject {
|
52
|
-
CloudApp::DropCollection.
|
53
|
-
new(representation, service, drop_class).
|
54
|
-
follow('yes')
|
55
|
-
}
|
56
|
-
|
57
|
-
before do
|
58
|
-
link = stub :link
|
59
|
-
link.should_receive(:follow).once.and_return(link_representation)
|
60
|
-
representation.should_receive(:link).once.and_return(link)
|
61
|
-
end
|
62
|
-
|
63
|
-
it { subject.should be_a(CloudApp::DropCollection) }
|
64
|
-
its(:representation) { should eq(link_representation) }
|
65
|
-
its(:drop_class) { should eq(drop_class) }
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '#has_link?' do
|
69
|
-
context 'with link' do
|
70
|
-
before do
|
71
|
-
representation.should_receive(:link).
|
72
|
-
once.
|
73
|
-
with('yes').
|
74
|
-
and_return(stub(:link))
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'returns false' do
|
78
|
-
subject.has_link?('yes').should eq(true)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'without link' do
|
83
|
-
before do
|
84
|
-
representation.should_receive(:link).
|
85
|
-
once.
|
86
|
-
with('no').
|
87
|
-
and_yield
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'returns true' do
|
91
|
-
subject.has_link?('no').should eq(false)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe '#trash' do
|
97
|
-
it 'trashes the given drop' do
|
98
|
-
href = stub :href
|
99
|
-
service.should_receive(:trash_drop).once.with(href)
|
100
|
-
subject.trash stub(:drop, href: href)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe '#recover' do
|
105
|
-
it 'recovers the given drop' do
|
106
|
-
href = stub :href
|
107
|
-
service.should_receive(:recover_drop).once.with(href)
|
108
|
-
subject.recover stub(:drop, href: href)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe '#delete' do
|
113
|
-
it 'deletes the given drop' do
|
114
|
-
href = stub :href
|
115
|
-
service.should_receive(:delete_drop).once.with(href)
|
116
|
-
subject.delete stub(:drop, href: href)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe '#delete'
|
121
|
-
|
122
|
-
context 'unauthorized' do
|
123
|
-
before do representation.stub(unauthorized?: true) end
|
124
|
-
|
125
|
-
it { should be_empty }
|
126
|
-
end
|
127
|
-
end
|
data/spec/cloudapp/drop_spec.rb
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
require 'cloudapp/drop'
|
4
|
-
stub_class :DropContent
|
5
|
-
|
6
|
-
describe CloudApp::Drop do
|
7
|
-
let(:href) { stub :href }
|
8
|
-
let(:links) { [] }
|
9
|
-
let(:data) { {} }
|
10
|
-
let(:collection) { stub :collection }
|
11
|
-
subject {
|
12
|
-
CloudApp::Drop.new stub(:drop, href: href, links: links, data: data),
|
13
|
-
collection
|
14
|
-
}
|
15
|
-
|
16
|
-
its(:href) { should eq(href) }
|
17
|
-
|
18
|
-
describe '#data' do
|
19
|
-
let(:data) {{ name: 'Drop' }}
|
20
|
-
its(:data) { should eq(data) }
|
21
|
-
|
22
|
-
context 'with string keys' do
|
23
|
-
let(:data) {{ 'name' => 'Drop' }}
|
24
|
-
its(:data) { should eq(data) }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#name' do
|
29
|
-
let(:data) {{ name: 'Drop' }}
|
30
|
-
its(:name) { should eq(data[:name]) }
|
31
|
-
|
32
|
-
context 'when nil' do
|
33
|
-
let(:data) {{ name: nil }}
|
34
|
-
let(:links) {[ stub(:link, rel: 'canonical', href: '/canonical') ]}
|
35
|
-
|
36
|
-
it 'returns the share url' do
|
37
|
-
subject.name.should eq('/canonical')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '#private?' do
|
43
|
-
describe 'a private drop' do
|
44
|
-
let(:data) {{ private: true }}
|
45
|
-
it { should be_private }
|
46
|
-
end
|
47
|
-
|
48
|
-
describe 'a public drop' do
|
49
|
-
let(:data) {{ private: false }}
|
50
|
-
it { should_not be_private }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#public?' do
|
55
|
-
describe 'a private drop' do
|
56
|
-
let(:data) {{ private: true }}
|
57
|
-
it { should_not be_public }
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'a public drop' do
|
61
|
-
let(:data) {{ private: false }}
|
62
|
-
it { should be_public }
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '#created' do
|
67
|
-
let(:data) {{ created: '2012-04-01T00:00:00Z' }}
|
68
|
-
it 'parses date' do
|
69
|
-
expected = DateTime.new(2012, 4, 1)
|
70
|
-
subject.created.should eq(expected)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#share_url' do
|
75
|
-
let(:links) {[
|
76
|
-
stub(:canonical, rel: 'canonical', href: '/canonical'),
|
77
|
-
stub(:alternate, rel: 'alternate', href: '/alternate')
|
78
|
-
]}
|
79
|
-
its(:share_url) { should eq('/canonical') }
|
80
|
-
end
|
81
|
-
|
82
|
-
describe '#thumbnail_url' do
|
83
|
-
let(:links) {[
|
84
|
-
stub(:canonical, rel: 'canonical', href: '/canonical'),
|
85
|
-
stub(:icon, rel: 'icon', href: '/icon')
|
86
|
-
]}
|
87
|
-
|
88
|
-
its(:thumbnail_url) { should eq('/icon') }
|
89
|
-
|
90
|
-
context 'without an icon link' do
|
91
|
-
let(:links) {[ stub(:canonical, rel: 'canonical', href: '/canonical') ]}
|
92
|
-
its(:thumbnail_url) { should be_nil }
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe '#embed_url' do
|
97
|
-
let(:links) {[
|
98
|
-
stub(:canonical, rel: 'canonical', href: '/canonical'),
|
99
|
-
stub(:embed, rel: 'embed', href: '/embed')
|
100
|
-
]}
|
101
|
-
its(:embed_url) { should eq('/embed') }
|
102
|
-
|
103
|
-
context 'without an embed link' do
|
104
|
-
let(:links) {[ stub(:canonical, rel: 'canonical', href: '/canonical') ]}
|
105
|
-
its(:embed_url) { should be_nil }
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe '#download_url' do
|
110
|
-
let(:links) {[
|
111
|
-
stub(:canonical, rel: 'canonical', href: '/canonical'),
|
112
|
-
stub(:download, rel: 'download', href: '/download')
|
113
|
-
]}
|
114
|
-
its(:download_url) { should eq('/download') }
|
115
|
-
|
116
|
-
context 'without an download link' do
|
117
|
-
let(:links) {[ stub(:canonical, rel: 'canonical', href: '/canonical') ]}
|
118
|
-
its(:download_url) { should be_nil }
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe '#trash' do
|
123
|
-
it 'trashes itself' do
|
124
|
-
collection.should_receive(:trash).once.with(subject)
|
125
|
-
subject.trash
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe '#recover' do
|
130
|
-
it 'recovers itself' do
|
131
|
-
collection.should_receive(:recover).once.with(subject)
|
132
|
-
subject.recover
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
describe '#delete' do
|
137
|
-
it 'deletes itself' do
|
138
|
-
collection.should_receive(:delete).once.with(subject)
|
139
|
-
subject.delete
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|