brick_ftp 2.0.3 → 2.1.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
  SHA256:
3
- metadata.gz: f89f5228f66c2b5a9b36d711b39ed799d41eb2257106a3306d15f87baff57859
4
- data.tar.gz: e3e76df6a6829230a55168dd76e82d659967a232d5a19f8cde26ee0686ce3607
3
+ metadata.gz: '0963dd222588305e1338d88de6cbbc880994cc1c6d6285d1db7611f0d211745d'
4
+ data.tar.gz: 9677a3209ae374ce09cc879a057b742c9cb59773417a040302658cb1a23b0e34
5
5
  SHA512:
6
- metadata.gz: a796baec9ec77b321d2856b59efcd7a45ccb665ae23df4cd4d82d1814894de43d4d4502000824ddc2eae00f89440fdaad0a7d7a300e99d0fe8c4930b968a7f30
7
- data.tar.gz: 1eccf58c09d2ed1dd3c96ebb3ebf3bbae8675b9d5bf076f11793e96746fa7c03fd34e5413e098007a4ec27953755b7cf06780b4d033ad5896a2914b01347df0b
6
+ metadata.gz: 1c29f0e5dd4a68a7252d5c5c6559056c821ba9a865efbed6fd50c406f0126106f7fc8c7dba23e0a3941d82f17df428d373e7112a3a1449b36b7f09cb1a97bbc7
7
+ data.tar.gz: c9652d9b29f3886cfd3b81b5b0441d661b93d178e0f823816dd409058e3082f9c5589c277a87647649b152fffbe8504f041240e0d1ec66ccd4f4c965ac0f4a02
data/.circleci/config.yml CHANGED
@@ -18,14 +18,6 @@ jobs:
18
18
  - run:
19
19
  name: RSpec
20
20
  command: rspec
21
- ruby-2.3:
22
- <<: *build
23
- docker:
24
- - image: circleci/ruby:2.3
25
- ruby-2.4:
26
- <<: *build
27
- docker:
28
- - image: circleci/ruby:2.4
29
21
  ruby-2.5:
30
22
  <<: *build
31
23
  docker:
@@ -43,8 +35,6 @@ workflows:
43
35
  version: 2
44
36
  build-using-multi-rubies:
45
37
  jobs:
46
- - ruby-2.3
47
- - ruby-2.4
48
38
  - ruby-2.5
49
39
  - ruby-2.6
50
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
@@ -18,6 +18,25 @@ Files::User.new(params, api_key: 'YOUR_API_KEY')
18
18
  I will archive this repository after found official SDK.
19
19
 
20
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
+
21
40
  [v2.0.3](https://github.com/koshigoe/brick_ftp/compare/v2.0.2...v2.0.3)
22
41
  ----
23
42
 
data/README.md CHANGED
@@ -33,22 +33,18 @@ Usage
33
33
  ----
34
34
 
35
35
  ```
36
+ $ docker compose up -d
36
37
  $ bin/console
37
- > client = BrickFTP::Client.new
38
+ > client = BrickFTP::Client.new(base_url: 'http://localhost:40410', api_key: 'dummy')
38
39
  > client.list_users
39
40
  ```
40
41
 
41
- ```
42
- $ bin/console
43
- > api_client = BrickFTP::RESTfulAPI::Client.new(ENV['BRICK_FTP_SUBDOMAIN'], ENV['BRICK_FTP_API_KEY'])
44
- > BrickFTP::RESTfulAPI::ListUsers.new(api_client).call
45
- ```
46
-
47
42
  ### Environment Variables
48
43
 
49
44
  Name | Description
50
45
  --------------------- | -----------
51
- `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/`)
52
48
  `BRICK_FTP_API_KEY` | Default API key
53
49
 
54
50
 
data/brick_ftp.gemspec CHANGED
@@ -20,7 +20,7 @@ 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
25
  spec.add_development_dependency 'bundler', '>= 1.16'
26
26
  spec.add_development_dependency 'pry', '~> 0.11'
@@ -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
@@ -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,11 +147,22 @@ 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
156
168
  when Net::HTTPNoContent
@@ -169,10 +181,10 @@ module BrickFTP
169
181
 
170
182
  def parse_error_response(response)
171
183
  parsed = begin
172
- JSON.parse(response.body)
173
- rescue StandardError
174
- {}
175
- end
184
+ JSON.parse(response.body)
185
+ rescue StandardError
186
+ {}
187
+ end
176
188
  parsed = {} unless parsed.is_a?(Hash)
177
189
 
178
190
  ErrorResponse.new(parsed.symbolize_keys).tap do |e|
@@ -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.3'
4
+ VERSION = '2.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick_ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - koshigoe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-20 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
@@ -164,6 +164,7 @@ files:
164
164
  - bin/console
165
165
  - bin/setup
166
166
  - brick_ftp.gemspec
167
+ - docker-compose.yml
167
168
  - lib/brick_ftp.rb
168
169
  - lib/brick_ftp/client.rb
169
170
  - lib/brick_ftp/core_ext.rb
@@ -272,14 +273,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
272
273
  requirements:
273
274
  - - ">="
274
275
  - !ruby/object:Gem::Version
275
- version: 2.3.0
276
+ version: 2.5.0
276
277
  required_rubygems_version: !ruby/object:Gem::Requirement
277
278
  requirements:
278
279
  - - ">="
279
280
  - !ruby/object:Gem::Version
280
281
  version: '0'
281
282
  requirements: []
282
- rubygems_version: 3.1.4
283
+ rubygems_version: 3.1.6
283
284
  signing_key:
284
285
  specification_version: 4
285
286
  summary: BrickFTP's REST API client.