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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDBhNGIyNTBjOWFiMzI2NjFlY2U4YTRlMjcyNWYzN2FlNWZiOWFmNQ==
4
+ NTQ5NTgyY2ZiNTNlNzZhZTM4NjNiYWJhYTViZDUwYzVhMmY1MjI3Ng==
5
5
  data.tar.gz: !binary |-
6
- NThlNGEwMjU1YzU2MDU0ZTg4Nzg3MDU2Y2I0NDlmZWVhYmVhZTg3ZA==
6
+ ZDIzM2Y4YTlkNjU4NzcwNjVmYTVlZWY1MTMxYjExMzI0OWIzZDhmNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NzE0Y2EwNmUyZTViN2MxY2U4NDdhZWY1MjBhYTA1NDkxY2EzYzQ5ZGM4NzZk
10
- MmQ0YTM2MjBkZTE2ZTU1OTA0NGRhZDRlNzFlMDU2NDQ1ODRlNjA2ZjYzYTU4
11
- NmQ1MzM5ZGVlMDgyNzNlNTI3YzkyNWIwMTE3MTZiMGVhOGE3NDA=
9
+ NGZhNmI3NTVmN2FiZDUwYjhhZTlkM2UyNjIwZDYwMDExMTRjMjRiMzVmYWM5
10
+ MzI5MzZhYzYwZTMyMWEyOTBlMjkyZWYwMTliZDE4NzYyNjQwMjA2NTA4MWEz
11
+ ZDc5YjMxOGQwMTllYzM3ZDQ4ZWEwMWQ3ZTQ5YzU5YTEyMzYwZTE=
12
12
  data.tar.gz: !binary |-
13
- YmMyYWZhNDg2YWQwNTExN2E3NTA0ZGFhOTJhOGE1NTIwZmVlOGI0MmJjYzE1
14
- NzgzNDdkMmZiNTY0YzgwYjNiYzcyYzEzYzg4OGZhYmY1NjUyMmExYzIxNDky
15
- M2NiMDJjOWJkZmM5ZDRlMzYwNGU4NGMzMzFlMWU0ZTJkODRiN2I=
13
+ M2I0OGIwZDQ5YjRmM2JkYjJiY2Y3YmEzZWRlYmIyMTJjMzJhZGM1YWQxZWFj
14
+ M2Q4NDBkMDdkNjYxYTIzZGNiYjY2MzkxOWJjMmY1YWY2MjIxNTdmOTNhODY4
15
+ MTgyYzMzM2Y2YzVmYWY4MDllNzEwZGJjMWNjZjI1OWI2Njg1ZmI=
@@ -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.7.0
1
+ 1.8.0
@@ -64,6 +64,13 @@ module RubyBox
64
64
  self
65
65
  end
66
66
 
67
+ def create_comment(message)
68
+ RubyBox::Comment.new(@session, {
69
+ 'item' => {'id' => id, 'type' => type},
70
+ 'message' => message
71
+ }).create
72
+ end
73
+
67
74
  private
68
75
 
69
76
  def resource_name
@@ -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
- collaboration = RubyBox::Collaboration.new(@session, {
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ruby-box"
8
- s.version = "1.7.0"
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",
@@ -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
+ }
@@ -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.7.0
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