ruby-box 1.12.2 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8433a7ebad739882d2edb3928678512c70eaf7c
4
- data.tar.gz: cfad2e9815486989edb7f3dc0983f1c4c1da5f74
3
+ metadata.gz: c016a6ca1bcf95bcf583d8ebc1c72273b8f334a4
4
+ data.tar.gz: 1fb5d7ab0a109d4864cbb4285a7b038e805eb7b8
5
5
  SHA512:
6
- metadata.gz: c2476b48ea8e7d3dfea2a98f51c5f82ababa80b80eeb7a43cac9fb024c10211aceddb313900195d40c28e5a3720c188b00ad1973364092d9aef28f3b675490ed
7
- data.tar.gz: a68d72e04903989535314b5b96b3e36b197950a8d4ad60e2e59ad9097253bfc7614f7e52d0fde5aab78748153e6c88aa47a8b5a54a5548a87a0369d7bb5d2e2e
6
+ metadata.gz: 44460ff855652f088916f3caaa669f407734219780c09cc3bbd6143cddce746aabc176dbee898db8646bc2e971f2de8351415e583ef6f38f2d7bb689f4aaeed8
7
+ data.tar.gz: 42066260e9426378a72e6d642569f8941bba87300e6c906d2dfffee7743f594f9c13e0b14f6879baec9ee84e06121cc65e9ac56e1afc9fc466090e4cbbaaf5d4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.12.2
1
+ 1.13.0
@@ -66,13 +66,32 @@ module RubyBox
66
66
  'role' => role.to_s
67
67
  }).create
68
68
  end
69
-
69
+
70
+ # see http://developers.box.com/docs/#folders-copy-a-folder
71
+ # for a description of the behavior
72
+ def copy_to(destination, name=nil)
73
+ parent = {'parent' => {'id' => destination.id}}
74
+ parent.merge!('name' => name) if name
75
+
76
+ RubyBox::Folder.new(@session, post(folder_method(:copy), parent))
77
+ end
78
+
70
79
  private
80
+ def post(extra_url, body)
81
+ uri = URI.parse("#{RubyBox::API_URL}/#{extra_url}")
82
+ post = Net::HTTP::Post.new(uri.request_uri)
83
+ post.body = JSON.dump(body)
84
+ @session.request(uri, post)
85
+ end
71
86
 
72
87
  def resource_name
73
88
  'folders'
74
89
  end
75
90
 
91
+ def folder_method(method)
92
+ "folders/#{id}/#{method}"
93
+ end
94
+
76
95
  def has_mini_format?
77
96
  true
78
97
  end
@@ -2,15 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: ruby-box 1.12.2 ruby lib
5
+ # stub: ruby-box 1.13.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "ruby-box"
9
- s.version = "1.12.2"
9
+ s.version = "1.13.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
12
13
  s.authors = ["Attachments.me"]
13
- s.date = "2013-12-26"
14
+ s.date = "2014-01-28"
14
15
  s.description = "ruby gem for box.com 2.0 api"
15
16
  s.email = "ben@attachments.me"
16
17
  s.extra_rdoc_files = [
@@ -60,8 +61,7 @@ Gem::Specification.new do |s|
60
61
  ]
61
62
  s.homepage = "http://github.com/attachmentsme/ruby-box"
62
63
  s.licenses = ["MIT"]
63
- s.require_paths = ["lib"]
64
- s.rubygems_version = "2.1.11"
64
+ s.rubygems_version = "2.2.1"
65
65
  s.summary = "ruby gem for box.com 2.0 api"
66
66
 
67
67
  if s.respond_to? :specification_version then
@@ -137,4 +137,45 @@ describe RubyBox::Folder do
137
137
  end
138
138
  end
139
139
 
140
+ context '#copy_to' do
141
+ let(:source_folder) { RubyBox::Folder.new(@session, {'id' => 1}) }
142
+ let(:destination) { RubyBox::Folder.new(@session, {'id' => 100}) }
143
+ let(:last_request) { JSON.parse(@request.body) }
144
+ let(:last_uri) { @uri.to_s }
145
+
146
+ before(:each) do
147
+ @session.stub(:request).with do |uri, request, _, _|
148
+ @uri, @request = uri, request
149
+ end
150
+ end
151
+
152
+ it 'uses itself for the copy uri' do
153
+ source_folder.copy_to destination
154
+ last_uri.should match /folders\/#{source_folder.id}\/copy/
155
+ end
156
+
157
+ it 'uses the destination as the parent' do
158
+ source_folder.copy_to destination
159
+ last_request['parent']['id'].should eq(destination.id)
160
+ end
161
+
162
+ it 'uses the source as the name by default' do
163
+ source_folder.copy_to destination
164
+ last_request.should_not have_key 'name'
165
+ end
166
+
167
+ it 'can provide a new name if desired' do
168
+ source_folder.copy_to destination, 'renamed-folder'
169
+ last_request['name'].should eq('renamed-folder')
170
+ end
171
+
172
+ it 'returns the newly created folder' do
173
+ @session.should_receive(:request).and_return('type' => 'folder', 'id' => '123')
174
+ copied_folder = source_folder.copy_to(destination)
175
+
176
+ copied_folder.should be_a(RubyBox::Folder)
177
+ copied_folder.id.should eq("123")
178
+ end
179
+ end
180
+
140
181
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-box
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.2
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Attachments.me
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-26 00:00:00.000000000 Z
11
+ date: 2014-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multipart-post
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: addressable
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
@@ -112,14 +112,14 @@ dependencies:
112
112
  name: webmock
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  description: ruby gem for box.com 2.0 api
@@ -179,17 +179,17 @@ require_paths:
179
179
  - lib
180
180
  required_ruby_version: !ruby/object:Gem::Requirement
181
181
  requirements:
182
- - - ! '>='
182
+ - - '>='
183
183
  - !ruby/object:Gem::Version
184
184
  version: '0'
185
185
  required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  requirements:
187
- - - ! '>='
187
+ - - '>='
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
190
  requirements: []
191
191
  rubyforge_project:
192
- rubygems_version: 2.1.11
192
+ rubygems_version: 2.2.1
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: ruby gem for box.com 2.0 api