ruby-box 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.markdown +7 -0
- data/VERSION +1 -1
- data/lib/ruby-box/file.rb +7 -0
- data/lib/ruby-box/folder.rb +2 -13
- data/ruby-box.gemspec +2 -1
- data/spec/file_spec.rb +14 -0
- data/spec/fixtures/comment_create.json +18 -0
- data/spec/integration_spec.rb +9 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTQ5NTgyY2ZiNTNlNzZhZTM4NjNiYWJhYTViZDUwYzVhMmY1MjI3Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDIzM2Y4YTlkNjU4NzcwNjVmYTVlZWY1MTMxYjExMzI0OWIzZDhmNw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGZhNmI3NTVmN2FiZDUwYjhhZTlkM2UyNjIwZDYwMDExMTRjMjRiMzVmYWM5
|
10
|
+
MzI5MzZhYzYwZTMyMWEyOTBlMjkyZWYwMTliZDE4NzYyNjQwMjA2NTA4MWEz
|
11
|
+
ZDc5YjMxOGQwMTllYzM3ZDQ4ZWEwMWQ3ZTQ5YzU5YTEyMzYwZTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2I0OGIwZDQ5YjRmM2JkYjJiY2Y3YmEzZWRlYmIyMTJjMzJhZGM1YWQxZWFj
|
14
|
+
M2Q4NDBkMDdkNjYxYTIzZGNiYjY2MzkxOWJjMmY1YWY2MjIxNTdmOTNhODY4
|
15
|
+
MTgyYzMzM2Y2YzVmYWY4MDllNzEwZGJjMWNjZjI1OWI2Njg1ZmI=
|
data/README.markdown
CHANGED
@@ -155,6 +155,13 @@ folder = client.folder('image_folder')
|
|
155
155
|
file.copy_to(folder)
|
156
156
|
```
|
157
157
|
|
158
|
+
* Adding a comment to a file.
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
file = client.file('/image_folder/an-image.jpg')
|
162
|
+
comment = file.create_comment('Hello World!')
|
163
|
+
```
|
164
|
+
|
158
165
|
Search
|
159
166
|
------
|
160
167
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.8.0
|
data/lib/ruby-box/file.rb
CHANGED
data/lib/ruby-box/folder.rb
CHANGED
@@ -42,22 +42,11 @@ module RubyBox
|
|
42
42
|
# see http://developers.box.com/docs/#collaborations-collaboration-object
|
43
43
|
# for a list of valid roles.
|
44
44
|
def create_collaboration(email, role=:viewer)
|
45
|
-
|
45
|
+
RubyBox::Collaboration.new(@session, {
|
46
46
|
'item' => {'id' => id, 'type' => type},
|
47
47
|
'accessible_by' => {'login' => email},
|
48
48
|
'role' => role.to_s
|
49
|
-
})
|
50
|
-
|
51
|
-
collaboration.create
|
52
|
-
end
|
53
|
-
|
54
|
-
def create_subfolder(name)
|
55
|
-
url = "#{RubyBox::API_URL}/#{resource_name}"
|
56
|
-
uri = URI.parse(url)
|
57
|
-
request = Net::HTTP::Post.new( uri.request_uri )
|
58
|
-
request.body = JSON.dump({ "name" => name, "parent" => {"id" => id} })
|
59
|
-
resp = @session.request(uri, request)
|
60
|
-
RubyBox::Folder.new(@session, resp)
|
49
|
+
}).create
|
61
50
|
end
|
62
51
|
|
63
52
|
private
|
data/ruby-box.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "ruby-box"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.8.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Attachments.me"]
|
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
"spec/client_spec.rb",
|
43
43
|
"spec/event_spec.rb",
|
44
44
|
"spec/file_spec.rb",
|
45
|
+
"spec/fixtures/comment_create.json",
|
45
46
|
"spec/fixtures/events.json",
|
46
47
|
"spec/fixtures/me.json",
|
47
48
|
"spec/folder_spec.rb",
|
data/spec/file_spec.rb
CHANGED
@@ -93,4 +93,18 @@ describe RubyBox::File do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
+
describe '#create_comment' do
|
97
|
+
it 'calls the /comments resource with the appropriate post body' do
|
98
|
+
stub_request(:post, "https://api.box.com/2.0/comments")
|
99
|
+
.to_return(:body => File.read('./spec/fixtures/comment_create.json'), :status => 200)
|
100
|
+
|
101
|
+
session = RubyBox::Session.new
|
102
|
+
file = RubyBox::File.new(session, @mini_file)
|
103
|
+
comment = file.create_comment('Hello world!')
|
104
|
+
|
105
|
+
# note that this value comes from the fixture.
|
106
|
+
comment.message.should == 'These tigers are cool!'
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
96
110
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"type": "comment",
|
3
|
+
"id": "191969",
|
4
|
+
"is_reply_comment": false,
|
5
|
+
"message": "These tigers are cool!",
|
6
|
+
"created_by": {
|
7
|
+
"type": "user",
|
8
|
+
"id": "17738362",
|
9
|
+
"name": "sean rose",
|
10
|
+
"login": "sean@box.com"
|
11
|
+
},
|
12
|
+
"created_at": "2012-12-12T11:25:01-08:00",
|
13
|
+
"item": {
|
14
|
+
"id": "5000948880",
|
15
|
+
"type": "file"
|
16
|
+
},
|
17
|
+
"modified_at": "2012-12-12T11:25:01-08:00"
|
18
|
+
}
|
data/spec/integration_spec.rb
CHANGED
@@ -228,6 +228,15 @@ describe RubyBox, :skip => true do
|
|
228
228
|
end
|
229
229
|
end
|
230
230
|
|
231
|
+
describe "#create_comment" do
|
232
|
+
it "allows a comment to be created on a file" do
|
233
|
+
file = @client.upload_file('spec/fixtures/遠志教授.jpg', '/ruby-box_gem_testing/cool stuff/')
|
234
|
+
file.create_comment('Hello world!')
|
235
|
+
file.comments.first.message.should == 'Hello world!'
|
236
|
+
file.delete
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
231
240
|
describe "#copy_to" do
|
232
241
|
it "it copies a file to a folder when a folder id is passed in" do
|
233
242
|
file = @client.upload_file('spec/fixtures/遠志教授.jpg', '/ruby-box_gem_testing/')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Attachments.me
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- spec/client_spec.rb
|
156
156
|
- spec/event_spec.rb
|
157
157
|
- spec/file_spec.rb
|
158
|
+
- spec/fixtures/comment_create.json
|
158
159
|
- spec/fixtures/events.json
|
159
160
|
- spec/fixtures/me.json
|
160
161
|
- spec/folder_spec.rb
|