ruby-box 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.document +5 -0
- data/.gitignore +52 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +160 -0
- data/Rakefile +32 -0
- data/VERSION +1 -0
- data/lib/ruby-box.rb +16 -0
- data/lib/ruby-box/client.rb +97 -0
- data/lib/ruby-box/comment.rb +10 -0
- data/lib/ruby-box/discussion.rb +16 -0
- data/lib/ruby-box/exceptions.rb +17 -0
- data/lib/ruby-box/file.rb +70 -0
- data/lib/ruby-box/folder.rb +71 -0
- data/lib/ruby-box/item.rb +83 -0
- data/lib/ruby-box/session.rb +102 -0
- data/lib/ruby-box/user.rb +10 -0
- data/ruby-box.gemspec +50 -0
- data/spec/client_spec.rb +28 -0
- data/spec/file_spec.rb +95 -0
- data/spec/folder_spec.rb +101 -0
- data/spec/helper/account.example +3 -0
- data/spec/helper/account.rb +8 -0
- data/spec/integration_spec.rb +181 -0
- metadata +143 -0
data/spec/file_spec.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
|
3
|
+
require 'helper/account'
|
4
|
+
require 'ruby-box'
|
5
|
+
require 'webmock/rspec'
|
6
|
+
|
7
|
+
describe RubyBox::File do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@session = RubyBox::Session.new
|
11
|
+
@full_file = JSON.parse('{ "type": "file", "id": "5000948880", "sequence_id": "3", "etag": "3", "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc", "name": "tigers.jpeg", "description": "a picture of tigers", "size": 629644, "path_collection": { "total_count": 2, "entries": [ { "type": "folder", "id": "0", "sequence_id": null, "etag": null, "name": "All Files" }, { "type": "folder", "id": "11446498", "sequence_id": "1", "etag": "1", "name": "Pictures" } ] }, "created_at": "2012-12-12T10:55:30-08:00", "modified_at": "2012-12-12T11:04:26-08:00", "trashed_at": null, "purged_at": null, "content_created_at": "2013-02-04T16:57:52-08:00", "content_modified_at": "2013-02-04T16:57:52-08:00", "created_by": { "type": "user", "id": "17738362", "name": "sean rose", "login": "sean@box.com" }, "modified_by": { "type": "user", "id": "17738362", "name": "sean rose", "login": "sean@box.com" }, "owned_by": { "type": "user", "id": "17738362", "name": "sean rose", "login": "sean@box.com" }, "shared_link": { "url": "https://www.box.com/s/rh935iit6ewrmw0unyul", "download_url": "https://www.box.com/shared/static/rh935iit6ewrmw0unyul.jpeg", "vanity_url": null, "is_password_enabled": false, "unshared_at": null, "download_count": 0, "preview_count": 0, "access": "open", "permissions": { "can_download": true, "can_preview": true } }, "parent": { "type": "folder", "id": "11446498", "sequence_id": "1", "etag": "1", "name": "Pictures" }, "item_status": "active"}')
|
12
|
+
@mini_file = JSON.parse('{ "sequence_id": "0", "type": "file", "id": "2631999573", "name":"IMG_1312.JPG"}')
|
13
|
+
@comments = JSON.parse('{ "total_count": 1, "entries": [ { "type": "comment", "id": "191969", "is_reply_comment": false, "message": "These tigers are cool!", "created_by": { "type": "user", "id": "17738362", "name": "sean rose", "login": "sean@box.com" }, "created_at": "2012-12-12T11:25:01-08:00", "item": { "id": "5000948880", "type": "file" }, "modified_at": "2012-12-12T11:25:01-08:00" } ]}')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should use missing_method to expose files fields" do
|
17
|
+
file = RubyBox::File.new(@session, @mini_file)
|
18
|
+
file.id.should == '2631999573'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should load all meta information if reload_meta is called" do
|
22
|
+
# request is called once when reload_meta is automatically executed.
|
23
|
+
RubyBox::Session.any_instance.should_receive(:request).once.and_return(@full_file)
|
24
|
+
session = RubyBox::Session.new
|
25
|
+
|
26
|
+
file = RubyBox::File.new(session, @mini_file)
|
27
|
+
file.size.should == 629644
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#parent' do
|
31
|
+
it 'should return parent folder' do
|
32
|
+
session = RubyBox::Session.new
|
33
|
+
file = RubyBox::File.new(session, @full_file)
|
34
|
+
file.parent.name.should == 'Pictures'
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should reload_meta data if necessary before loading parent' do
|
38
|
+
RubyBox::Session.any_instance.stub(:request).and_return(@full_file)
|
39
|
+
session = RubyBox::Session.new
|
40
|
+
file = RubyBox::File.new(session, @mini_file)
|
41
|
+
file.parent.name.should == 'Pictures'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#update' do
|
46
|
+
it 'should update files raw_item hash if name or description changed' do
|
47
|
+
RubyBox::Session.any_instance.stub(:request).and_return(@full_file)
|
48
|
+
session = RubyBox::Session.new
|
49
|
+
file = RubyBox::File.new(session, @mini_file)
|
50
|
+
file.name = 'Funky Monkey.jpg'
|
51
|
+
file.description = 'a new description'
|
52
|
+
file.name.should == 'Funky Monkey.jpg'
|
53
|
+
file.description.should == 'a new description'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should not update files raw_item hash for keys not in update_fields' do
|
57
|
+
RubyBox::Session.any_instance.stub(:request).and_return(@full_file)
|
58
|
+
session = RubyBox::Session.new
|
59
|
+
file = RubyBox::File.new(session, @mini_file)
|
60
|
+
file.id = '000'
|
61
|
+
file.id.should == '2631999573'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should make request with appropriate update hash when update called' do
|
65
|
+
RubyBox::Session.any_instance.stub(:request) do |uri, request|
|
66
|
+
data = JSON.parse(request.body)
|
67
|
+
data['description'].should == 'a new description'
|
68
|
+
end
|
69
|
+
session = RubyBox::Session.new
|
70
|
+
file = RubyBox::File.new(session, @full_file)
|
71
|
+
file.description = 'a new description'
|
72
|
+
file.update
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#put_data' do
|
77
|
+
it "should load full meta information if etag not present" do
|
78
|
+
RubyBox::Session.any_instance.should_receive(:request).twice.and_return(@full_file)
|
79
|
+
session = RubyBox::Session.new
|
80
|
+
file = RubyBox::File.new(session, @mini_file)
|
81
|
+
file.stub(:prepare_upload).and_return('fake data')
|
82
|
+
file.update_content('data')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#comments' do
|
87
|
+
it 'should return an array of comment objects' do
|
88
|
+
RubyBox::Session.any_instance.stub(:request).and_return(@comments)
|
89
|
+
session = RubyBox::Session.new
|
90
|
+
file = RubyBox::File.new(session, @mini_file)
|
91
|
+
file.comments.first.message.should == 'These tigers are cool!'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
data/spec/folder_spec.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
|
3
|
+
require 'helper/account'
|
4
|
+
require 'ruby-box'
|
5
|
+
require 'webmock/rspec'
|
6
|
+
|
7
|
+
describe RubyBox::Folder do
|
8
|
+
before do
|
9
|
+
@session = RubyBox::Session.new
|
10
|
+
@full_folder = JSON.parse('{ "type": "folder", "id": "11446498", "sequence_id": "1", "etag": "1", "name": "Pictures", "created_at": "2012-12-12T10:53:43-08:00", "modified_at": "2012-12-12T11:15:04-08:00", "description": "Some pictures I took", "size": 629644, "path_collection": { "total_count": 1, "entries": [ { "type": "folder", "id": "0", "sequence_id": null, "etag": null, "name": "All Files" } ] }, "created_by": { "type": "user", "id": "17738362", "name": "sean rose", "login": "sean@box.com" }, "modified_by": { "type": "user", "id": "17738362", "name": "sean rose", "login": "sean@box.com" }, "owned_by": { "type": "user", "id": "17738362", "name": "sean rose", "login": "sean@box.com" }, "shared_link": { "url": "https://www.box.com/s/vspke7y05sb214wjokpk", "download_url": "https://www.box.com/shared/static/vspke7y05sb214wjokpk", "vanity_url": null, "is_password_enabled": false, "unshared_at": null, "download_count": 0, "preview_count": 0, "access": "open", "permissions": { "can_download": true, "can_preview": true } }, "folder_upload_email": { "access": "open", "email": "upload.Picture.k13sdz1@u.box.com" }, "parent": { "type": "folder", "id": "0", "sequence_id": null, "etag": null, "name": "All Files" }, "item_status": "active", "item_collection": { "total_count": 1, "entries": [ { "type": "file", "id": "5000948880", "sequence_id": "3", "etag": "3", "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc", "name": "tigers.jpeg" } ], "offset": 0, "limit": 100 }}')
|
11
|
+
@mini_folder = JSON.parse('{ "type":"folder", "id":"301415432", "sequence_id":"0", "name":"my first sub-folder"}')
|
12
|
+
@items = [
|
13
|
+
JSON.parse('{ "total_count": 4, "entries": [ { "type": "folder", "id": "409047867", "sequence_id": "1", "etag": "1", "name": "Here\'s your folder" }, { "type": "file", "id": "409042867", "sequence_id": "1", "etag": "1", "name": "A choice file" } ], "offset": "0", "limit": "2"}'),
|
14
|
+
JSON.parse('{ "total_count": 4, "entries": [ { "type": "folder", "id": "409047868", "sequence_id": "1", "etag": "1", "name": "Here\'s another folder" }, { "type": "file", "id": "409042810", "sequence_id": "1", "etag": "1", "name": "A choice file" } ], "offset": "2", "limit": "2"}')
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
it "#root returns full root folder object" do
|
19
|
+
RubyBox::Session.any_instance.stub(:request).and_return(@full_folder)
|
20
|
+
session = RubyBox::Session.new
|
21
|
+
root = RubyBox::Client.new(session).root_folder
|
22
|
+
root.name.should == 'Pictures'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns iso8601 format keys as a time object" do
|
26
|
+
RubyBox::Session.any_instance.stub(:request).and_return(@full_folder)
|
27
|
+
session = RubyBox::Session.new
|
28
|
+
root = RubyBox::Client.new(session).root_folder
|
29
|
+
root.created_at.year.should == 2012
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#items' do
|
33
|
+
it "should return a folder object for folder items" do
|
34
|
+
item = JSON.parse('{ "id": "0000001", "total_count": 1, "entries": [ { "type": "folder", "id": "409047867", "sequence_id": "1", "etag": "1", "name": "Here\'s your folder" } ], "offset": "0", "limit": "1"}')
|
35
|
+
RubyBox::Session.any_instance.stub(:request).and_return(item)
|
36
|
+
session = RubyBox::Session.new
|
37
|
+
item = RubyBox::Client.new(session).root_folder.items.first
|
38
|
+
item.kind_of?(RubyBox::Folder).should == true
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return a file object for file items" do
|
42
|
+
item = JSON.parse('{ "id": "0000001", "total_count": 1, "entries": [ { "type": "file", "id": "409042867", "sequence_id": "1", "etag": "1", "name": "A choice file" } ], "offset": "0", "limit": "1"}')
|
43
|
+
RubyBox::Session.any_instance.stub(:request).and_return(item)
|
44
|
+
session = RubyBox::Session.new
|
45
|
+
item = RubyBox::Client.new(session).root_folder.items.first
|
46
|
+
item.kind_of?(RubyBox::File).should == true
|
47
|
+
end
|
48
|
+
|
49
|
+
it "it should return an iterator that lazy loads all entries" do
|
50
|
+
RubyBox::Session.any_instance.stub(:request) { @items.pop }
|
51
|
+
session = RubyBox::Session.new
|
52
|
+
items = RubyBox::Folder.new(session, {'id' => 1}).items(1).to_a
|
53
|
+
items[0].kind_of?(RubyBox::Folder).should == true
|
54
|
+
items[1].kind_of?(RubyBox::File).should == true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#files' do
|
59
|
+
it "should only return items of type file" do
|
60
|
+
RubyBox::Session.any_instance.stub(:request) { @items.pop }
|
61
|
+
session = RubyBox::Session.new
|
62
|
+
files = RubyBox::Folder.new(session, {'id' => 1}).files
|
63
|
+
files.count.should == 1
|
64
|
+
files.first.kind_of?(RubyBox::File).should == true
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should allow you to filter files by name" do
|
68
|
+
items = [
|
69
|
+
JSON.parse('{ "total_count": 4, "entries": [ { "type": "folder", "id": "409047867", "sequence_id": "1", "etag": "1", "name": "Here\'s your folder" }, { "type": "file", "id": "409042867", "sequence_id": "1", "etag": "1", "name": "A choice file" } ], "offset": "0", "limit": "2"}'),
|
70
|
+
JSON.parse('{ "total_count": 4, "entries": [ { "type": "folder", "id": "409047868", "sequence_id": "1", "etag": "1", "name": "Here\'s another folder" }, { "type": "file", "id": "409042810", "sequence_id": "1", "etag": "1", "name": "A choice file" } ], "offset": "2", "limit": "2"}')
|
71
|
+
]
|
72
|
+
|
73
|
+
RubyBox::Session.any_instance.stub(:request) { items.pop }
|
74
|
+
session = RubyBox::Session.new
|
75
|
+
|
76
|
+
# should return one file.
|
77
|
+
files = RubyBox::Folder.new(session, {'id' => 1}).files('A choice file')
|
78
|
+
files.count.should == 1
|
79
|
+
|
80
|
+
items = [
|
81
|
+
JSON.parse('{ "total_count": 4, "entries": [ { "type": "folder", "id": "409047867", "sequence_id": "1", "etag": "1", "name": "Here\'s your folder" }, { "type": "file", "id": "409042867", "sequence_id": "1", "etag": "1", "name": "A choice file" } ], "offset": "0", "limit": "2"}'),
|
82
|
+
JSON.parse('{ "total_count": 4, "entries": [ { "type": "folder", "id": "409047868", "sequence_id": "1", "etag": "1", "name": "Here\'s another folder" }, { "type": "file", "id": "409042810", "sequence_id": "1", "etag": "1", "name": "A choice file" } ], "offset": "2", "limit": "2"}')
|
83
|
+
]
|
84
|
+
|
85
|
+
# should return no files.
|
86
|
+
files = RubyBox::Folder.new(session, {'id' => 1}).files('foobar')
|
87
|
+
files.count.should == 0
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#folders' do
|
93
|
+
it "should only return items of type folder" do
|
94
|
+
RubyBox::Session.any_instance.stub(:request) { @items.pop }
|
95
|
+
session = RubyBox::Session.new
|
96
|
+
files = RubyBox::Folder.new(session, {'id' => 1}).folders
|
97
|
+
files.count.should == 1
|
98
|
+
files.first.kind_of?(RubyBox::Folder).should == true
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
|
3
|
+
require 'helper/account'
|
4
|
+
require 'ruby-box'
|
5
|
+
require 'webmock/rspec'
|
6
|
+
|
7
|
+
describe RubyBox do
|
8
|
+
before do
|
9
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
10
|
+
|
11
|
+
WebMock.allow_net_connect!
|
12
|
+
|
13
|
+
@session = RubyBox::Session.new({
|
14
|
+
api_key: ACCOUNT['api_key'],
|
15
|
+
auth_token: ACCOUNT['auth_token']
|
16
|
+
})
|
17
|
+
|
18
|
+
@client = RubyBox::Client.new(@session)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "raises an AuthError if not client auth fails" do
|
22
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
23
|
+
|
24
|
+
session = RubyBox::Session.new({
|
25
|
+
api_key: 'bad-key',
|
26
|
+
auth_token: 'bad-token'
|
27
|
+
})
|
28
|
+
|
29
|
+
@bad_client = RubyBox::Client.new(session)
|
30
|
+
|
31
|
+
lambda {@bad_client.root_folder}.should raise_error( RubyBox::AuthError )
|
32
|
+
end
|
33
|
+
|
34
|
+
it "raises a RequestError if a badly formed request detected by the server" do
|
35
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
36
|
+
stub_request(:get, "https://api.box.com/2.0/folders/0").to_return(:status => 401, :body => '{"type": "error", "status": 401, "message": "baddd req"}', :headers => {})
|
37
|
+
lambda {@client.root_folder}.should raise_error( RubyBox::AuthError )
|
38
|
+
end
|
39
|
+
|
40
|
+
it "raises a ServerError if the server raises a 500 error" do
|
41
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
42
|
+
stub_request(:get, "https://api.box.com/2.0/folders/0").to_return(:status => 503, :body => '{"type": "error", "status": 503, "message": "We messed up! - Box.com"}', :headers => {})
|
43
|
+
lambda {@client.root_folder}.should raise_error( RubyBox::ServerError )
|
44
|
+
end
|
45
|
+
|
46
|
+
describe RubyBox::Folder do
|
47
|
+
describe '#root_folder' do
|
48
|
+
it "#items returns a lits of items in the root folder" do
|
49
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
50
|
+
items = @client.root_folder.items.to_a
|
51
|
+
items.count.should == 6
|
52
|
+
items.any? do |item|
|
53
|
+
item.type == "folder" &&
|
54
|
+
item.id == "318810303" &&
|
55
|
+
item.name == "ruby-box_gem_testing"
|
56
|
+
end.should == true
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns list of items in the folder id passed in" do
|
60
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
61
|
+
folder = RubyBox::Folder.new(@session, {'id' => '318810303'})
|
62
|
+
items = folder.items.to_a
|
63
|
+
items.count.should == 2
|
64
|
+
items.any? do |item|
|
65
|
+
item.type == "file" &&
|
66
|
+
item.id == "2550686921" &&
|
67
|
+
item.name == "2513582219_03fb9b67db_b.jpg"
|
68
|
+
end.should == true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#file' do
|
73
|
+
it "finds the id of a file" do
|
74
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
75
|
+
folder = RubyBox::Folder.new(@session, {'id' => '318810303'})
|
76
|
+
file = folder.files( '2513582219_03fb9b67db_b.jpg' ).first
|
77
|
+
file.id.should == "2550686921"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#create' do
|
82
|
+
it "creates a folder" do
|
83
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
84
|
+
|
85
|
+
folder = @client.folder('/ruby-box_gem_testing')
|
86
|
+
subfolder = folder.create_subfolder( 'new_folder_created' )
|
87
|
+
subfolder.id.should_not == nil
|
88
|
+
|
89
|
+
subfolder.delete
|
90
|
+
end
|
91
|
+
|
92
|
+
it "creates a folder with special chars in the name" do
|
93
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
94
|
+
|
95
|
+
folder = @client.folder('/ruby-box_gem_testing')
|
96
|
+
subfolder = folder.create_subfolder( '!@#$%^&$$()' )
|
97
|
+
subfolder.id.should_not == nil
|
98
|
+
|
99
|
+
subfolder.delete
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
describe RubyBox::Client do
|
106
|
+
|
107
|
+
describe '#put_data' do
|
108
|
+
it "should update an existing file" do
|
109
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
110
|
+
|
111
|
+
utf8_file_name = '遠志教授.jpg'
|
112
|
+
fdata = File.open( 'spec/fixtures/' + utf8_file_name, 'rb' )
|
113
|
+
response = @client.upload_data('/ruby-box_gem_testing/cool stuff/遠志教授.jpg', fdata)
|
114
|
+
fdata = File.open( 'spec/fixtures/' + utf8_file_name, 'rb' )
|
115
|
+
|
116
|
+
file = @client.upload_data('/ruby-box_gem_testing/cool stuff/遠志教授.jpg', fdata)
|
117
|
+
file.name.should == '遠志教授.jpg'
|
118
|
+
file.delete
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should upload a new file" do
|
122
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
123
|
+
utf8_file_name = '遠志教授.jpg'
|
124
|
+
file = @client.upload_file('spec/fixtures/' + utf8_file_name, '/ruby-box_gem_testing/cool stuff/')
|
125
|
+
file.name.should == '遠志教授.jpg'
|
126
|
+
file.delete
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '#create_folder' do
|
131
|
+
it "creates a path that doesnt exist" do
|
132
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
133
|
+
folder = @client.create_folder('/ruby-box_gem_testing/cool stuff/екузц/path1/path2')
|
134
|
+
folder.id.should_not == nil
|
135
|
+
folder.delete if folder
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#get_file_info' do
|
140
|
+
it "returns meta information for a file" do
|
141
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
142
|
+
file = @client.file( '/ruby-box_gem_testing/cool stuff/кузнецкий_105_а_№2.test' )
|
143
|
+
file.size.should == 14
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe '#stream' do
|
148
|
+
it "should download file contents" do
|
149
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
150
|
+
stream = @client.stream( '/ruby-box_gem_testing/cool stuff/кузнецкий_105_а_№2.test' )
|
151
|
+
stream.read.should eq "Test more data"
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should execute content_length_proc lambda with filesize" do
|
155
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
156
|
+
stream = @client.stream(
|
157
|
+
'/ruby-box_gem_testing/cool stuff/кузнецкий_105_а_№2.test',
|
158
|
+
:content_length_proc => lambda {|filesize|
|
159
|
+
filesize.should == 14
|
160
|
+
}
|
161
|
+
)
|
162
|
+
stream.read.should eq "Test more data"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe '#download' do
|
167
|
+
it "finds the id of a file" do
|
168
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
169
|
+
data = @client.download( '/ruby-box_gem_testing/cool stuff/кузнецкий_105_а_№2.test' )
|
170
|
+
data.should eq "Test more data"
|
171
|
+
end
|
172
|
+
|
173
|
+
it "returns nil for a nonexistent file" do
|
174
|
+
next unless ACCOUNT['api_key'] # skip these tests if accout.yml does not exist.
|
175
|
+
data = @client.download( '/ruby-box_gem_testing/doesntexist' )
|
176
|
+
data.should eq nil
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-box
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Benjamin Coe
|
8
|
+
- Jesse Miller
|
9
|
+
- Larry Kang
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-03-02 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: multipart-post
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.5
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 1.1.5
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rspec
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: bundler
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: jeweler
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.6.4
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.6.4
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: webmock
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
description: ruby gem for box.com 2.0 api
|
86
|
+
email: ben@attachments.me
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files:
|
90
|
+
- LICENSE.txt
|
91
|
+
- README.markdown
|
92
|
+
files:
|
93
|
+
- .document
|
94
|
+
- .gitignore
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.markdown
|
99
|
+
- Rakefile
|
100
|
+
- VERSION
|
101
|
+
- lib/ruby-box.rb
|
102
|
+
- lib/ruby-box/client.rb
|
103
|
+
- lib/ruby-box/comment.rb
|
104
|
+
- lib/ruby-box/discussion.rb
|
105
|
+
- lib/ruby-box/exceptions.rb
|
106
|
+
- lib/ruby-box/file.rb
|
107
|
+
- lib/ruby-box/folder.rb
|
108
|
+
- lib/ruby-box/item.rb
|
109
|
+
- lib/ruby-box/session.rb
|
110
|
+
- lib/ruby-box/user.rb
|
111
|
+
- ruby-box.gemspec
|
112
|
+
- spec/client_spec.rb
|
113
|
+
- spec/file_spec.rb
|
114
|
+
- spec/folder_spec.rb
|
115
|
+
- spec/helper/account.example
|
116
|
+
- spec/helper/account.rb
|
117
|
+
- spec/integration_spec.rb
|
118
|
+
homepage: http://github.com/attachmentsme/ruby-box
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ! '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.0.3
|
139
|
+
signing_key:
|
140
|
+
specification_version: 3
|
141
|
+
summary: ruby gem for box.com 2.0 api
|
142
|
+
test_files: []
|
143
|
+
has_rdoc:
|