brick_ftp 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +8 -11
  3. data/.rubocop.yml +1 -1
  4. data/.rubocop_todo.yml +7 -0
  5. data/CHANGELOG.md +67 -2
  6. data/README.md +8 -9
  7. data/brick_ftp.gemspec +2 -3
  8. data/docker-compose.yml +7 -0
  9. data/lib/brick_ftp/client.rb +17 -4
  10. data/lib/brick_ftp/core_ext/hash/symbolize_keys.rb +4 -4
  11. data/lib/brick_ftp/restful_api/add_group_member.rb +1 -1
  12. data/lib/brick_ftp/restful_api/client.rb +22 -8
  13. data/lib/brick_ftp/restful_api/complete_upload.rb +1 -1
  14. data/lib/brick_ftp/restful_api/continue_upload.rb +1 -1
  15. data/lib/brick_ftp/restful_api/count_folder_contents.rb +1 -1
  16. data/lib/brick_ftp/restful_api/create_api_key.rb +1 -1
  17. data/lib/brick_ftp/restful_api/create_behavior.rb +1 -1
  18. data/lib/brick_ftp/restful_api/create_bundle.rb +1 -1
  19. data/lib/brick_ftp/restful_api/create_group.rb +1 -1
  20. data/lib/brick_ftp/restful_api/create_notification.rb +1 -1
  21. data/lib/brick_ftp/restful_api/create_permission.rb +1 -1
  22. data/lib/brick_ftp/restful_api/create_public_key.rb +1 -1
  23. data/lib/brick_ftp/restful_api/create_user.rb +1 -1
  24. data/lib/brick_ftp/restful_api/create_user_in_group.rb +1 -1
  25. data/lib/brick_ftp/restful_api/delete_folder.rb +5 -7
  26. data/lib/brick_ftp/restful_api/download_file.rb +1 -1
  27. data/lib/brick_ftp/restful_api/get_api_key.rb +1 -1
  28. data/lib/brick_ftp/restful_api/get_behavior.rb +1 -1
  29. data/lib/brick_ftp/restful_api/get_bundle.rb +1 -1
  30. data/lib/brick_ftp/restful_api/get_bundle_zip.rb +1 -1
  31. data/lib/brick_ftp/restful_api/get_file_in_bundle.rb +1 -1
  32. data/lib/brick_ftp/restful_api/get_group.rb +1 -1
  33. data/lib/brick_ftp/restful_api/get_public_key.rb +1 -1
  34. data/lib/brick_ftp/restful_api/get_site_usage.rb +1 -1
  35. data/lib/brick_ftp/restful_api/get_user.rb +1 -1
  36. data/lib/brick_ftp/restful_api/list_api_keys.rb +1 -1
  37. data/lib/brick_ftp/restful_api/list_behaviors.rb +1 -1
  38. data/lib/brick_ftp/restful_api/list_bundle_contents.rb +1 -1
  39. data/lib/brick_ftp/restful_api/list_bundles.rb +1 -1
  40. data/lib/brick_ftp/restful_api/list_folder_behaviors.rb +1 -1
  41. data/lib/brick_ftp/restful_api/list_folders.rb +1 -1
  42. data/lib/brick_ftp/restful_api/list_groups.rb +1 -1
  43. data/lib/brick_ftp/restful_api/list_notifications.rb +1 -1
  44. data/lib/brick_ftp/restful_api/list_permissions.rb +1 -1
  45. data/lib/brick_ftp/restful_api/list_public_keys.rb +1 -1
  46. data/lib/brick_ftp/restful_api/list_users.rb +1 -1
  47. data/lib/brick_ftp/restful_api/retrieve_history.rb +1 -1
  48. data/lib/brick_ftp/restful_api/search_user.rb +1 -1
  49. data/lib/brick_ftp/restful_api/start_upload.rb +1 -1
  50. data/lib/brick_ftp/restful_api/unlock_user.rb +1 -1
  51. data/lib/brick_ftp/restful_api/update_behavior.rb +1 -1
  52. data/lib/brick_ftp/restful_api/update_group.rb +1 -1
  53. data/lib/brick_ftp/restful_api/update_group_member.rb +1 -1
  54. data/lib/brick_ftp/restful_api/update_user.rb +1 -1
  55. data/lib/brick_ftp/restful_api/upload_file.rb +1 -1
  56. data/lib/brick_ftp/version.rb +1 -1
  57. metadata +10 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 742d808ea0faafa27e7447766e96f3ed29accafeb125802b9760c289d2b08252
4
- data.tar.gz: c723a9c56a9e19ef1bf1d1781afd1a41d26ebe0aa97c168fe7e51f0613ebd02c
3
+ metadata.gz: '0963dd222588305e1338d88de6cbbc880994cc1c6d6285d1db7611f0d211745d'
4
+ data.tar.gz: 9677a3209ae374ce09cc879a057b742c9cb59773417a040302658cb1a23b0e34
5
5
  SHA512:
6
- metadata.gz: 38c32e3356d422b54ca22d39d73145c766830fc4aec4ee22bc1cbb2da8af63f6a8fa009ed312a9651dfceac77e2aea1abd64d54e427f21a380968c4b80b9c26c
7
- data.tar.gz: 4d4c8b7dbe080f6e097f759e0698bc67826abd106d3812ff3cde8af9dab1db039333251385e70532bdd28993611b4640818f615d5c300e2f8264c11f5096ef9c
6
+ metadata.gz: 1c29f0e5dd4a68a7252d5c5c6559056c821ba9a865efbed6fd50c406f0126106f7fc8c7dba23e0a3941d82f17df428d373e7112a3a1449b36b7f09cb1a97bbc7
7
+ data.tar.gz: c9652d9b29f3886cfd3b81b5b0441d661b93d178e0f823816dd409058e3082f9c5589c277a87647649b152fffbe8504f041240e0d1ec66ccd4f4c965ac0f4a02
data/.circleci/config.yml CHANGED
@@ -18,26 +18,23 @@ jobs:
18
18
  - run:
19
19
  name: RSpec
20
20
  command: rspec
21
- - store_artifacts:
22
- path: coverage
23
- destination: coverage
24
- ruby-2.3:
21
+ ruby-2.5:
25
22
  <<: *build
26
23
  docker:
27
- - image: circleci/ruby:2.3
28
- ruby-2.4:
24
+ - image: circleci/ruby:2.5
25
+ ruby-2.6:
29
26
  <<: *build
30
27
  docker:
31
- - image: circleci/ruby:2.4
32
- ruby-2.5:
28
+ - image: circleci/ruby:2.6
29
+ ruby-2.7:
33
30
  <<: *build
34
31
  docker:
35
- - image: circleci/ruby:2.5
32
+ - image: circleci/ruby:2.7
36
33
 
37
34
  workflows:
38
35
  version: 2
39
36
  build-using-multi-rubies:
40
37
  jobs:
41
- - ruby-2.3
42
- - ruby-2.4
43
38
  - ruby-2.5
39
+ - ruby-2.6
40
+ - ruby-2.7
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.3
4
+ TargetRubyVersion: 2.5
5
5
 
6
6
  Style/EmptyCaseCondition:
7
7
  Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -40,3 +40,10 @@ Style/Documentation:
40
40
 
41
41
  Style/Lambda:
42
42
  EnforcedStyle: literal
43
+
44
+ Lint/StructNewOverride:
45
+ Enabled: false
46
+
47
+ Style/StringConcatenation:
48
+ Exclude:
49
+ - "spec/**/*_spec.rb"
data/CHANGELOG.md CHANGED
@@ -1,19 +1,84 @@
1
1
  Changelog
2
2
  ====
3
3
 
4
+ The official Ruby SDK released by Files.com
4
5
 
5
- [unreleased](https://github.com/koshigoe/brick_ftp/compare/v2.0.0...master)
6
+ > SDKs in Ruby and PHP are available for download using the typical package manager for each language.
7
+ > https://developers.files.com/?ruby#introduction
8
+
9
+ Its usage like:
10
+
11
+ ```ruby
12
+ Files.api_key = 'YOUR_API_KEY'
13
+
14
+ # Alternatively, you can specify the API key on a per-request basis in the final parameter to any method or initializer.
15
+ Files::User.new(params, api_key: 'YOUR_API_KEY')
16
+ ```
17
+
18
+ I will archive this repository after found official SDK.
19
+
20
+
21
+ [v2.1.0](https://github.com/koshigoe/brick_ftp/compare/v2.0.3...v2.1.0)
22
+ ----
23
+
24
+ [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v2.0.3...v2.1.0)
25
+
26
+ ### Enhancements:
27
+
28
+ ### Fixed Bugs:
29
+
30
+ ### Deprecate
31
+
32
+ - Deprecate keyword argument `subdomain:` of `BrickFTP::Client#initialize`
33
+ - To enable to specify base URL of REST API (e.g. `http://127.0.0.1:40410/`)
34
+
35
+ ### Breaking Changes:
36
+
37
+ - Dropping support for Ruby 2.3, 2.4
38
+
39
+
40
+ [v2.0.3](https://github.com/koshigoe/brick_ftp/compare/v2.0.2...v2.0.3)
41
+ ----
42
+
43
+ [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v2.0.2...v2.0.3)
44
+
45
+ ### Enhancements:
46
+
47
+ ### Fixed Bugs:
48
+
49
+ - [#133](https://github.com/koshigoe/brick_ftp/pull/133) Fix to enable to delete folders recursively
50
+
51
+ ### Breaking Changes:
52
+
53
+
54
+ [v2.0.2](https://github.com/koshigoe/brick_ftp/compare/v2.0.1...v2.0.2)
6
55
  ----
7
56
 
8
- [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v2.0.0...master)
57
+ [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v2.0.1...v2.0.2)
9
58
 
10
59
  ### Enhancements:
11
60
 
61
+ - [#132](https://github.com/koshigoe/brick_ftp/pull/132) Suppress warnings in Ruby 2.7
62
+
12
63
  ### Fixed Bugs:
13
64
 
14
65
  ### Breaking Changes:
15
66
 
16
67
 
68
+ [v2.0.1](https://github.com/koshigoe/brick_ftp/compare/v2.0.0...v2.0.1)
69
+ ----
70
+
71
+ [Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v2.0.0...v2.0.1)
72
+
73
+ ### Enhancements:
74
+
75
+ ### Fixed Bugs:
76
+
77
+ - [#124](https://github.com/koshigoe/brick_ftp/pull/124) Handle response 204 No Content avoid to parse error.
78
+
79
+ ### Breaking Changes:
80
+
81
+
17
82
  [v2.0.0](https://github.com/koshigoe/brick_ftp/compare/v1.0.1...v2.0.0)
18
83
  ----
19
84
 
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![CircleCI](https://circleci.com/gh/koshigoe/brick_ftp/tree/master.svg?style=svg)](https://circleci.com/gh/koshigoe/brick_ftp/tree/master)
2
- [![codecov](https://codecov.io/gh/koshigoe/brick_ftp/branch/master/graph/badge.svg)](https://codecov.io/gh/koshigoe/brick_ftp)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/b996c388d3d32b7ec953/maintainability)](https://codeclimate.com/github/koshigoe/brick_ftp/maintainability)
3
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/b996c388d3d32b7ec953/test_coverage)](https://codeclimate.com/github/koshigoe/brick_ftp/test_coverage)
3
4
 
4
5
 
5
6
  Files.com (BrickFTP)
@@ -7,6 +8,8 @@ Files.com (BrickFTP)
7
8
 
8
9
  This is a [File.com (BrickFTP)](https://files.com/)'s _unofficial_ [RESTful API](https://developers.files.com/) Client.
9
10
 
11
+ **I recommend official SDK: [Files-com/files-sdk-ruby](https://github.com/Files-com/files-sdk-ruby)**
12
+
10
13
 
11
14
  Installation
12
15
  ----
@@ -30,22 +33,18 @@ Usage
30
33
  ----
31
34
 
32
35
  ```
36
+ $ docker compose up -d
33
37
  $ bin/console
34
- > client = BrickFTP::Client.new
38
+ > client = BrickFTP::Client.new(base_url: 'http://localhost:40410', api_key: 'dummy')
35
39
  > client.list_users
36
40
  ```
37
41
 
38
- ```
39
- $ bin/console
40
- > api_client = BrickFTP::RESTfulAPI::Client.new(ENV['BRICK_FTP_SUBDOMAIN'], ENV['BRICK_FTP_API_KEY'])
41
- > BrickFTP::RESTfulAPI::ListUsers.new(api_client).call
42
- ```
43
-
44
42
  ### Environment Variables
45
43
 
46
44
  Name | Description
47
45
  --------------------- | -----------
48
- `BRICK_FTP_SUBDOMAIN` | Default subdomain
46
+ `BRICK_FTP_SUBDOMAIN` | Default subdomain (deprecated)
47
+ `BRICK_FTP_BASE_URL` | Base URL of Files.com's REST API (e.g. `https://{subdomain}.files.com/`)
49
48
  `BRICK_FTP_API_KEY` | Default API key
50
49
 
51
50
 
data/brick_ftp.gemspec CHANGED
@@ -20,10 +20,9 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.required_ruby_version = '>= 2.3.0'
23
+ spec.required_ruby_version = '>= 2.5.0'
24
24
 
25
- spec.add_development_dependency 'bundler', '~> 1.16'
26
- spec.add_development_dependency 'codecov', '~> 0.1.10'
25
+ spec.add_development_dependency 'bundler', '>= 1.16'
27
26
  spec.add_development_dependency 'pry', '~> 0.11'
28
27
  spec.add_development_dependency 'rake', '~> 12.0'
29
28
  spec.add_development_dependency 'redcarpet', '~> 3.4'
@@ -0,0 +1,7 @@
1
+ version: '3'
2
+
3
+ services:
4
+ files-mock-server:
5
+ image: filescom/files-mock-server:latest
6
+ ports:
7
+ - 40410:4041
@@ -10,14 +10,26 @@ module BrickFTP
10
10
  # BrickFTP::Client.new.list_users
11
11
  #
12
12
  class Client
13
- attr_reader :subdomain, :api_key, :api_client
13
+ attr_reader :base_url, :api_key, :api_client
14
14
 
15
- # @param [String] subdomain
15
+ # @param [String] base_url
16
+ # @param [String] subdomain (deprecated)
16
17
  # @param [String] api_key
17
- def initialize(subdomain: nil, api_key: nil)
18
+ def initialize(base_url: nil, subdomain: nil, api_key: nil)
19
+ if subdomain
20
+ warn('DEPRECATION WARNING: The argument `subdomain:` will be deprecated in a future version.' \
21
+ ' Please use `base_url:` instead.')
22
+ end
23
+
18
24
  @subdomain = subdomain || ENV['BRICK_FTP_SUBDOMAIN']
25
+ @base_url = base_url || ENV['BRICK_FTP_BASE_URL']
19
26
  @api_key = api_key || ENV['BRICK_FTP_API_KEY']
20
- @api_client = BrickFTP::RESTfulAPI::Client.new(@subdomain, @api_key)
27
+ @api_client = BrickFTP::RESTfulAPI::Client.new(@base_url || @subdomain, @api_key)
28
+ end
29
+
30
+ def subdomain
31
+ warn("DEPRECATION WARNING: #{self.class.name}##{__method__} will be deprecated in a future version.")
32
+ @subdomain
21
33
  end
22
34
 
23
35
  private
@@ -34,6 +46,7 @@ module BrickFTP
34
46
 
35
47
  def respond_to_missing?(symbol, include_private)
36
48
  return true if command_class(symbol)
49
+
37
50
  super
38
51
  end
39
52
 
@@ -7,10 +7,10 @@ module BrickFTP
7
7
  def symbolize_keys
8
8
  each_key.each_with_object({}) do |key, mem|
9
9
  symbolized_key = begin
10
- key.to_sym
11
- rescue StandardError
12
- key
13
- end
10
+ key.to_sym
11
+ rescue StandardError
12
+ key
13
+ end
14
14
  mem[symbolized_key] = self[key]
15
15
  end
16
16
  end
@@ -37,7 +37,7 @@ module BrickFTP
37
37
  def call(group_id, user_id, params)
38
38
  res = client.put("/api/rest/v1/groups/#{group_id}/memberships/#{user_id}.json", membership: params.to_h.compact)
39
39
 
40
- BrickFTP::Types::GroupMembership.new(res.symbolize_keys)
40
+ BrickFTP::Types::GroupMembership.new(**res.symbolize_keys)
41
41
  end
42
42
  end
43
43
  end
@@ -35,12 +35,13 @@ module BrickFTP
35
35
 
36
36
  # Initialize REST API client.
37
37
  #
38
- # @param [String] subdomain
38
+ # @param [String] base_url
39
39
  # @param [String] api_key
40
40
  #
41
- def initialize(subdomain, api_key)
42
- @http = Net::HTTP.new("#{subdomain}.files.com", 443)
43
- @http.use_ssl = true
41
+ def initialize(base_url, api_key)
42
+ @base_uri = make_base_uri(base_url)
43
+ @http = Net::HTTP.new(@base_uri.host, @base_uri.port)
44
+ @http.use_ssl = (@base_uri.scheme == 'https')
44
45
  @http.open_timeout = OPEN_TIMEOUT
45
46
  @http.read_timeout = READ_TIMEOUT
46
47
  @request_headers = {
@@ -146,13 +147,26 @@ module BrickFTP
146
147
  res = http.start { |session| session.request(req) }
147
148
 
148
149
  return io.size if res.is_a?(Net::HTTPSuccess)
150
+
149
151
  raise Error, parse_error_response(res)
150
152
  end
151
153
 
152
154
  private
153
155
 
156
+ DEFAULT_BASE_URL_TEMPLATE = 'https://%{subdomain}.files.com'
157
+
158
+ def make_base_uri(url_or_subdomain)
159
+ unless /[.:]/.match?(url_or_subdomain)
160
+ url_or_subdomain = format(DEFAULT_BASE_URL_TEMPLATE, subdomain: url_or_subdomain)
161
+ end
162
+
163
+ URI.parse(url_or_subdomain)
164
+ end
165
+
154
166
  def handle_response(response)
155
167
  case response
168
+ when Net::HTTPNoContent
169
+ nil
156
170
  when Net::HTTPSuccess
157
171
  parse_success_response(response)
158
172
  else
@@ -167,10 +181,10 @@ module BrickFTP
167
181
 
168
182
  def parse_error_response(response)
169
183
  parsed = begin
170
- JSON.parse(response.body)
171
- rescue StandardError
172
- {}
173
- end
184
+ JSON.parse(response.body)
185
+ rescue StandardError
186
+ {}
187
+ end
174
188
  parsed = {} unless parsed.is_a?(Hash)
175
189
 
176
190
  ErrorResponse.new(parsed.symbolize_keys).tap do |e|
@@ -39,7 +39,7 @@ module BrickFTP
39
39
  def call(path, params)
40
40
  res = client.post("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", params.to_h.compact.merge(action: 'end'))
41
41
 
42
- BrickFTP::Types::File.new(res.symbolize_keys)
42
+ BrickFTP::Types::File.new(**res.symbolize_keys)
43
43
  end
44
44
  end
45
45
  end
@@ -43,7 +43,7 @@ module BrickFTP
43
43
  def call(path, params)
44
44
  res = client.post("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", params.to_h.compact.merge(action: 'put'))
45
45
 
46
- BrickFTP::Types::Upload.new(res.symbolize_keys)
46
+ BrickFTP::Types::Upload.new(**res.symbolize_keys)
47
47
  end
48
48
  end
49
49
  end
@@ -29,7 +29,7 @@ module BrickFTP
29
29
  if recursive
30
30
  BrickFTP::Types::FolderContentsCount.new(total: res['data']['count'])
31
31
  else
32
- BrickFTP::Types::FolderContentsCount.new(res['data']['count'].symbolize_keys)
32
+ BrickFTP::Types::FolderContentsCount.new(**res['data']['count'].symbolize_keys)
33
33
  end
34
34
  end
35
35
  end
@@ -39,7 +39,7 @@ module BrickFTP
39
39
  def call(id, params)
40
40
  res = client.post("/api/rest/v1/users/#{id}/api_keys.json", params.to_h.compact)
41
41
 
42
- BrickFTP::Types::UserAPIKey.new(res.symbolize_keys)
42
+ BrickFTP::Types::UserAPIKey.new(**res.symbolize_keys)
43
43
  end
44
44
  end
45
45
  end
@@ -35,7 +35,7 @@ module BrickFTP
35
35
  def call(params)
36
36
  res = client.post('/api/rest/v1/behaviors.json', params.to_h.compact)
37
37
 
38
- BrickFTP::Types::Behavior.new(res.symbolize_keys)
38
+ BrickFTP::Types::Behavior.new(**res.symbolize_keys)
39
39
  end
40
40
  end
41
41
  end
@@ -33,7 +33,7 @@ module BrickFTP
33
33
  def call(params)
34
34
  res = client.post('/api/rest/v1/bundles.json', params.to_h.compact)
35
35
 
36
- BrickFTP::Types::Bundle.new(res.symbolize_keys)
36
+ BrickFTP::Types::Bundle.new(**res.symbolize_keys)
37
37
  end
38
38
  end
39
39
  end
@@ -35,7 +35,7 @@ module BrickFTP
35
35
  def call(params)
36
36
  res = client.post('/api/rest/v1/groups.json', params.to_h.compact)
37
37
 
38
- BrickFTP::Types::Group.new(res.symbolize_keys)
38
+ BrickFTP::Types::Group.new(**res.symbolize_keys)
39
39
  end
40
40
  end
41
41
  end
@@ -37,7 +37,7 @@ module BrickFTP
37
37
  def call(params)
38
38
  res = client.post('/api/rest/v1/notifications.json', params.to_h.compact)
39
39
 
40
- BrickFTP::Types::Notification.new(res.symbolize_keys)
40
+ BrickFTP::Types::Notification.new(**res.symbolize_keys)
41
41
  end
42
42
  end
43
43
  end
@@ -41,7 +41,7 @@ module BrickFTP
41
41
  def call(params)
42
42
  res = client.post('/api/rest/v1/permissions.json', params.to_h.compact)
43
43
 
44
- BrickFTP::Types::Permission.new(res.symbolize_keys)
44
+ BrickFTP::Types::Permission.new(**res.symbolize_keys)
45
45
  end
46
46
  end
47
47
  end
@@ -35,7 +35,7 @@ module BrickFTP
35
35
  def call(id, params)
36
36
  res = client.post("/api/rest/v1/users/#{id}/public_keys.json", params.to_h.compact)
37
37
 
38
- BrickFTP::Types::UserPublicKey.new(res.symbolize_keys)
38
+ BrickFTP::Types::UserPublicKey.new(**res.symbolize_keys)
39
39
  end
40
40
  end
41
41
  end
@@ -83,7 +83,7 @@ module BrickFTP
83
83
  def call(params)
84
84
  res = client.post('/api/rest/v1/users.json', params.to_h.compact)
85
85
 
86
- BrickFTP::Types::User.new(res.symbolize_keys)
86
+ BrickFTP::Types::User.new(**res.symbolize_keys)
87
87
  end
88
88
  end
89
89
  end
@@ -53,7 +53,7 @@ module BrickFTP
53
53
  def call(id, params)
54
54
  res = client.post("/api/rest/v1/groups/#{id}/users.json", user: params.to_h.compact)
55
55
 
56
- BrickFTP::Types::User.new(res.symbolize_keys)
56
+ BrickFTP::Types::User.new(**res.symbolize_keys)
57
57
  end
58
58
  end
59
59
  end
@@ -6,25 +6,23 @@ module BrickFTP
6
6
  module RESTfulAPI
7
7
  # Delete a file or folder
8
8
  #
9
- # @see https://developers.files.com/#delete-a-file-or-folder Delete a file or folder
9
+ # @see https://developers.files.com/#delete-file-folder Delete file/folder
10
10
  #
11
11
  class DeleteFolder
12
12
  include Command
13
13
 
14
14
  # Deletes a file or folder.
15
15
  #
16
- # Note that this operation works for both files and folders, but normally it will only work on empty folders.
17
- # If you want to recursively delete a folder and all its contents, send the request with a `Depth` header
18
- # with the value set to `infinity`.
16
+ # > If true, will recursively delete folers. Otherwise, will error on non-empty folders.
19
17
  #
20
18
  # @param [String] path Full path of the file or folder. Maximum of 550 characters.
21
19
  # @param [Boolean] recursive
22
20
  #
23
21
  def call(path, recursive: false)
24
- headers = {}
25
- headers = { 'Depth' => 'infinity' } if recursive
22
+ url = "/api/rest/v1/files/#{ERB::Util.url_encode(path)}"
23
+ url += '?recursive=true' if recursive
26
24
 
27
- client.delete("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", headers)
25
+ client.delete(url)
28
26
  true
29
27
  end
30
28
  end
@@ -38,7 +38,7 @@ module BrickFTP
38
38
  res = client.get(endpoint)
39
39
  return nil if !res || res.empty?
40
40
 
41
- BrickFTP::Types::File.new(res.symbolize_keys)
41
+ BrickFTP::Types::File.new(**res.symbolize_keys)
42
42
  end
43
43
  end
44
44
  end
@@ -19,7 +19,7 @@ module BrickFTP
19
19
  def call(id)
20
20
  res = client.get("/api/rest/v1/api_keys/#{id}.json")
21
21
 
22
- BrickFTP::Types::UserAPIKey.new(res.symbolize_keys)
22
+ BrickFTP::Types::UserAPIKey.new(**res.symbolize_keys)
23
23
  end
24
24
  end
25
25
  end
@@ -19,7 +19,7 @@ module BrickFTP
19
19
  res = client.get("/api/rest/v1/behaviors/#{id}.json")
20
20
  return nil if !res || res.empty?
21
21
 
22
- BrickFTP::Types::Behavior.new(res.symbolize_keys)
22
+ BrickFTP::Types::Behavior.new(**res.symbolize_keys)
23
23
  end
24
24
  end
25
25
  end
@@ -19,7 +19,7 @@ module BrickFTP
19
19
  res = client.get("/api/rest/v1/bundles/#{id}.json")
20
20
  return nil if !res || res.empty?
21
21
 
22
- BrickFTP::Types::Bundle.new(res.symbolize_keys)
22
+ BrickFTP::Types::Bundle.new(**res.symbolize_keys)
23
23
  end
24
24
  end
25
25
  end
@@ -41,7 +41,7 @@ module BrickFTP
41
41
  def call(params)
42
42
  res = client.post('/api/rest/v1/bundles/zip.json', params.to_h.compact)
43
43
 
44
- BrickFTP::Types::BundleZip.new(res.symbolize_keys)
44
+ BrickFTP::Types::BundleZip.new(**res.symbolize_keys)
45
45
  end
46
46
  end
47
47
  end
@@ -42,7 +42,7 @@ module BrickFTP
42
42
  def call(params)
43
43
  res = client.post('/api/rest/v1/bundles/download.json', params.to_h.compact)
44
44
 
45
- BrickFTP::Types::FileInBundle.new(res.symbolize_keys)
45
+ BrickFTP::Types::FileInBundle.new(**res.symbolize_keys)
46
46
  end
47
47
  end
48
48
  end
@@ -20,7 +20,7 @@ module BrickFTP
20
20
  res = client.get("/api/rest/v1/groups/#{id}.json")
21
21
  return nil if !res || res.empty?
22
22
 
23
- BrickFTP::Types::Group.new(res.symbolize_keys)
23
+ BrickFTP::Types::Group.new(**res.symbolize_keys)
24
24
  end
25
25
  end
26
26
  end
@@ -19,7 +19,7 @@ module BrickFTP
19
19
  def call(id)
20
20
  res = client.get("/api/rest/v1/public_keys/#{id}.json")
21
21
 
22
- BrickFTP::Types::UserPublicKey.new(res.symbolize_keys)
22
+ BrickFTP::Types::UserPublicKey.new(**res.symbolize_keys)
23
23
  end
24
24
  end
25
25
  end
@@ -13,7 +13,7 @@ module BrickFTP
13
13
  def call
14
14
  res = client.get('/api/rest/v1/site/usage.json')
15
15
 
16
- BrickFTP::Types::SiteUsage.new(res.symbolize_keys)
16
+ BrickFTP::Types::SiteUsage.new(**res.symbolize_keys)
17
17
  end
18
18
  end
19
19
  end
@@ -20,7 +20,7 @@ module BrickFTP
20
20
  res = client.get("/api/rest/v1/users/#{id}.json")
21
21
  return nil if !res || res.empty?
22
22
 
23
- BrickFTP::Types::User.new(res.symbolize_keys)
23
+ BrickFTP::Types::User.new(**res.symbolize_keys)
24
24
  end
25
25
  end
26
26
  end
@@ -19,7 +19,7 @@ module BrickFTP
19
19
  def call(id)
20
20
  res = client.get("/api/rest/v1/users/#{id}/api_keys.json")
21
21
 
22
- res.map { |i| BrickFTP::Types::UserAPIKey.new(i.symbolize_keys) }
22
+ res.map { |i| BrickFTP::Types::UserAPIKey.new(**i.symbolize_keys) }
23
23
  end
24
24
  end
25
25
  end
@@ -17,7 +17,7 @@ module BrickFTP
17
17
  def call
18
18
  res = client.get('/api/rest/v1/behaviors.json')
19
19
 
20
- res.map { |i| BrickFTP::Types::Behavior.new(i.symbolize_keys) }
20
+ res.map { |i| BrickFTP::Types::Behavior.new(**i.symbolize_keys) }
21
21
  end
22
22
  end
23
23
  end
@@ -51,7 +51,7 @@ module BrickFTP
51
51
  end
52
52
  res = client.post(endpoint, params.to_h.compact)
53
53
 
54
- res.map { |i| BrickFTP::Types::BundleContent.new(i.symbolize_keys) }
54
+ res.map { |i| BrickFTP::Types::BundleContent.new(**i.symbolize_keys) }
55
55
  end
56
56
  end
57
57
  end
@@ -17,7 +17,7 @@ module BrickFTP
17
17
  def call
18
18
  res = client.get('/api/rest/v1/bundles.json')
19
19
 
20
- res.map { |i| BrickFTP::Types::Bundle.new(i.symbolize_keys) }
20
+ res.map { |i| BrickFTP::Types::Bundle.new(**i.symbolize_keys) }
21
21
  end
22
22
  end
23
23
  end
@@ -33,7 +33,7 @@ module BrickFTP
33
33
  endpoint = "#{endpoint}?recursive=1" if recursive
34
34
  res = client.get(endpoint)
35
35
 
36
- res.map { |i| BrickFTP::Types::Behavior.new(i.symbolize_keys) }
36
+ res.map { |i| BrickFTP::Types::Behavior.new(**i.symbolize_keys) }
37
37
  end
38
38
  end
39
39
  end
@@ -59,7 +59,7 @@ module BrickFTP
59
59
 
60
60
  res = client.get(endpoint)
61
61
 
62
- res.map { |i| BrickFTP::Types::File.new(i.symbolize_keys) }
62
+ res.map { |i| BrickFTP::Types::File.new(**i.symbolize_keys) }
63
63
  end
64
64
 
65
65
  private
@@ -17,7 +17,7 @@ module BrickFTP
17
17
  def call
18
18
  res = client.get('/api/rest/v1/groups.json')
19
19
 
20
- res.map { |i| BrickFTP::Types::Group.new(i.symbolize_keys) }
20
+ res.map { |i| BrickFTP::Types::Group.new(**i.symbolize_keys) }
21
21
  end
22
22
  end
23
23
  end
@@ -17,7 +17,7 @@ module BrickFTP
17
17
  def call
18
18
  res = client.get('/api/rest/v1/notifications.json')
19
19
 
20
- res.map { |i| BrickFTP::Types::Notification.new(i.symbolize_keys) }
20
+ res.map { |i| BrickFTP::Types::Notification.new(**i.symbolize_keys) }
21
21
  end
22
22
  end
23
23
  end
@@ -35,7 +35,7 @@ module BrickFTP
35
35
  endpoint = "#{endpoint}?path=#{ERB::Util.url_encode(path)}" unless path.nil?
36
36
  res = client.get(endpoint)
37
37
 
38
- res.map { |i| BrickFTP::Types::Permission.new(i.symbolize_keys) }
38
+ res.map { |i| BrickFTP::Types::Permission.new(**i.symbolize_keys) }
39
39
  end
40
40
  end
41
41
  end
@@ -19,7 +19,7 @@ module BrickFTP
19
19
  def call(id)
20
20
  res = client.get("/api/rest/v1/users/#{id}/public_keys.json")
21
21
 
22
- res.map { |i| BrickFTP::Types::UserPublicKey.new(i.symbolize_keys) }
22
+ res.map { |i| BrickFTP::Types::UserPublicKey.new(**i.symbolize_keys) }
23
23
  end
24
24
  end
25
25
  end
@@ -38,7 +38,7 @@ module BrickFTP
38
38
  endpoint = "#{endpoint}?#{query}" unless query.empty?
39
39
  res = client.get(endpoint)
40
40
 
41
- res.map { |i| BrickFTP::Types::User.new(i.symbolize_keys) }
41
+ res.map { |i| BrickFTP::Types::User.new(**i.symbolize_keys) }
42
42
  end
43
43
 
44
44
  private
@@ -17,7 +17,7 @@ module BrickFTP
17
17
  endpoint = "#{path}?#{query}" unless query.empty?
18
18
  res = client.get(endpoint)
19
19
 
20
- res.map { |i| BrickFTP::Types::History.new(i.symbolize_keys) }
20
+ res.map { |i| BrickFTP::Types::History.new(**i.symbolize_keys) }
21
21
  end
22
22
 
23
23
  def validate_page!(page)
@@ -22,7 +22,7 @@ module BrickFTP
22
22
  res = client.get("/api/rest/v1/users.json?q[username]=#{ERB::Util.url_encode(username)}")
23
23
  return nil if !res || res.empty?
24
24
 
25
- BrickFTP::Types::User.new(res.first.symbolize_keys)
25
+ BrickFTP::Types::User.new(**res.first.symbolize_keys)
26
26
  end
27
27
  end
28
28
  end
@@ -21,7 +21,7 @@ module BrickFTP
21
21
  def call(path)
22
22
  res = client.post("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", action: 'put')
23
23
 
24
- BrickFTP::Types::Upload.new(res.symbolize_keys)
24
+ BrickFTP::Types::Upload.new(**res.symbolize_keys)
25
25
  end
26
26
  end
27
27
  end
@@ -19,7 +19,7 @@ module BrickFTP
19
19
  def call(id)
20
20
  res = client.post("/api/rest/v1/users/#{id}/unlock.json")
21
21
 
22
- BrickFTP::Types::User.new(res.symbolize_keys)
22
+ BrickFTP::Types::User.new(**res.symbolize_keys)
23
23
  end
24
24
  end
25
25
  end
@@ -32,7 +32,7 @@ module BrickFTP
32
32
  def call(id, params)
33
33
  res = client.patch("/api/rest/v1/behaviors/#{id}.json", params.to_h.compact)
34
34
 
35
- BrickFTP::Types::Behavior.new(res.symbolize_keys)
35
+ BrickFTP::Types::Behavior.new(**res.symbolize_keys)
36
36
  end
37
37
  end
38
38
  end
@@ -37,7 +37,7 @@ module BrickFTP
37
37
  def call(id, params)
38
38
  res = client.put("/api/rest/v1/groups/#{id}.json", params.to_h.compact)
39
39
 
40
- BrickFTP::Types::Group.new(res.symbolize_keys)
40
+ BrickFTP::Types::Group.new(**res.symbolize_keys)
41
41
  end
42
42
  end
43
43
  end
@@ -33,7 +33,7 @@ module BrickFTP
33
33
  def call(group_id, user_id, params)
34
34
  res = client.patch("/api/rest/v1/groups/#{group_id}/memberships/#{user_id}.json", membership: params.to_h.compact)
35
35
 
36
- BrickFTP::Types::GroupMembership.new(res.symbolize_keys)
36
+ BrickFTP::Types::GroupMembership.new(**res.symbolize_keys)
37
37
  end
38
38
  end
39
39
  end
@@ -94,7 +94,7 @@ module BrickFTP
94
94
  def call(id, params)
95
95
  res = client.put("/api/rest/v1/users/#{id}.json", params.to_h.compact)
96
96
 
97
- BrickFTP::Types::User.new(res.symbolize_keys)
97
+ BrickFTP::Types::User.new(**res.symbolize_keys)
98
98
  end
99
99
  end
100
100
  end
@@ -17,7 +17,7 @@ module BrickFTP
17
17
  class UploadFile
18
18
  include Command
19
19
 
20
- CHUNK_SIZE_RANGE = 5_242_880..5_368_709_120
20
+ CHUNK_SIZE_RANGE = (5_242_880..5_368_709_120).freeze
21
21
 
22
22
  # At this point, you are to send a PUT request to the returned upload_uri with the file data,
23
23
  # along with the headers and parameters provided to you from BrickFTP.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrickFTP
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick_ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - koshigoe
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-03 00:00:00.000000000 Z
11
+ date: 2021-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.16'
20
20
  type: :development
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: '1.16'
27
- - !ruby/object:Gem::Dependency
28
- name: codecov
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 0.1.10
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 0.1.10
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: pry
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +164,7 @@ files:
178
164
  - bin/console
179
165
  - bin/setup
180
166
  - brick_ftp.gemspec
167
+ - docker-compose.yml
181
168
  - lib/brick_ftp.rb
182
169
  - lib/brick_ftp/client.rb
183
170
  - lib/brick_ftp/core_ext.rb
@@ -278,7 +265,7 @@ homepage: https://github.com/koshigoe/brick_ftp
278
265
  licenses:
279
266
  - MIT
280
267
  metadata: {}
281
- post_install_message:
268
+ post_install_message:
282
269
  rdoc_options: []
283
270
  require_paths:
284
271
  - lib
@@ -286,15 +273,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
286
273
  requirements:
287
274
  - - ">="
288
275
  - !ruby/object:Gem::Version
289
- version: 2.3.0
276
+ version: 2.5.0
290
277
  required_rubygems_version: !ruby/object:Gem::Requirement
291
278
  requirements:
292
279
  - - ">="
293
280
  - !ruby/object:Gem::Version
294
281
  version: '0'
295
282
  requirements: []
296
- rubygems_version: 3.0.3
297
- signing_key:
283
+ rubygems_version: 3.1.6
284
+ signing_key:
298
285
  specification_version: 4
299
286
  summary: BrickFTP's REST API client.
300
287
  test_files: []