brick_ftp 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +48 -0
- data/.github/ISSUE_TEMPLATE.md +31 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +46 -0
- data/.rubocop.yml +24 -0
- data/.rubocop_todo.yml +42 -0
- data/CHANGELOG.md +19 -2
- data/Rakefile +5 -3
- data/bin/console +3 -3
- data/brick_ftp.gemspec +20 -17
- data/exe/brick_ftp +1 -1
- data/lib/brick_ftp.rb +5 -3
- data/lib/brick_ftp/api/base.rb +1 -1
- data/lib/brick_ftp/api/bundle_content.rb +2 -2
- data/lib/brick_ftp/api/file_operation/upload.rb +24 -7
- data/lib/brick_ftp/api/folder.rb +2 -0
- data/lib/brick_ftp/client.rb +25 -15
- data/lib/brick_ftp/configuration.rb +4 -4
- data/lib/brick_ftp/http_client.rb +16 -7
- data/lib/brick_ftp/log_formatter.rb +1 -1
- data/lib/brick_ftp/utils.rb +4 -0
- data/lib/brick_ftp/utils/chunk_io.rb +59 -0
- data/lib/brick_ftp/version.rb +1 -1
- metadata +54 -20
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bff0644f7601a0b205787a383d7e404ea52575f6e10d2e4ec92f2494b0b2e207
|
4
|
+
data.tar.gz: 89b62baafda83fc5a354a3b869bdb9779ec0ff82def20627f40412ef02f2818e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08e939656344e02093ac1df11a0fd9f93194706eac4de105880f90177c7d67876af69cfd42694fe9260e38b4599f89a61ceb6b4ed106ef1d903c68848b20f961'
|
7
|
+
data.tar.gz: f441cbcf2c4e2bb5c64fecb88c2e44ec5bd3293ee6d9fc2bd77b3715635fcb707bd61e3e601e38d048c32d2c6706bcff711d418eab1610c0dbebe7264464c562
|
@@ -0,0 +1,48 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build: &build
|
4
|
+
docker:
|
5
|
+
- image: circleci/ruby:latest
|
6
|
+
working_directory: /home/circleci/app
|
7
|
+
steps:
|
8
|
+
- checkout
|
9
|
+
- run:
|
10
|
+
name: Install gems
|
11
|
+
command: bundle install
|
12
|
+
- run:
|
13
|
+
name: Rubocop
|
14
|
+
command: rubocop
|
15
|
+
- run:
|
16
|
+
name: YARDoc
|
17
|
+
command: yardoc --fail-on-warning lib
|
18
|
+
- run:
|
19
|
+
name: RSpec
|
20
|
+
command: rspec
|
21
|
+
- store_artifacts:
|
22
|
+
path: coverage
|
23
|
+
destination: coverage
|
24
|
+
ruby-2.2:
|
25
|
+
<<: *build
|
26
|
+
docker:
|
27
|
+
- image: circleci/ruby:2.2
|
28
|
+
ruby-2.3:
|
29
|
+
<<: *build
|
30
|
+
docker:
|
31
|
+
- image: circleci/ruby:2.3
|
32
|
+
ruby-2.4:
|
33
|
+
<<: *build
|
34
|
+
docker:
|
35
|
+
- image: circleci/ruby:2.4
|
36
|
+
ruby-2.5:
|
37
|
+
<<: *build
|
38
|
+
docker:
|
39
|
+
- image: circleci/ruby:2.5
|
40
|
+
|
41
|
+
workflows:
|
42
|
+
version: 2
|
43
|
+
build-using-multi-rubies:
|
44
|
+
jobs:
|
45
|
+
- ruby-2.2
|
46
|
+
- ruby-2.3
|
47
|
+
- ruby-2.4
|
48
|
+
- ruby-2.5
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!--
|
2
|
+
1. Please check if an issue already exists so there are no duplicates
|
3
|
+
2. Check out and follow our Guidelines: https://github.com/serverless/serverless/blob/master/CONTRIBUTING.md
|
4
|
+
3. Fill out the whole template so we have a good overview on the issue
|
5
|
+
4. Do not remove any section of the template. If something is not applicable leave it empty but leave it in the Issue
|
6
|
+
5. Please follow the template, otherwise we'll have to ask you to update it
|
7
|
+
-->
|
8
|
+
|
9
|
+
# This is a (Bug Report / Feature Proposal)
|
10
|
+
|
11
|
+
## Description
|
12
|
+
|
13
|
+
For bug reports:
|
14
|
+
* What went wrong?
|
15
|
+
* What did you expect should have happened?
|
16
|
+
* What was the config you used?
|
17
|
+
* What stacktrace or error message from your provider did you see?
|
18
|
+
|
19
|
+
For feature proposals:
|
20
|
+
* What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.
|
21
|
+
* If there is additional config how would it look
|
22
|
+
|
23
|
+
Similar or dependent issues:
|
24
|
+
* #12345
|
25
|
+
|
26
|
+
## Additional Data
|
27
|
+
|
28
|
+
* ***Serverless Framework Version you're using***:
|
29
|
+
* ***Operating System***:
|
30
|
+
* ***Stack Trace***:
|
31
|
+
* ***Provider Error messages***:
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<!--
|
2
|
+
1. Please check out and follow our Contributing Guidelines: https://github.com/koshigoe/brick_ftp#contributing
|
3
|
+
2. Do not remove any section of the template. If something is not applicable leave it empty but leave it in the PR
|
4
|
+
3. Please follow the template, otherwise we'll have to ask you to update it and it will take longer until your PR is merged
|
5
|
+
-->
|
6
|
+
|
7
|
+
## What did you implement:
|
8
|
+
|
9
|
+
Closes #XXXXX
|
10
|
+
|
11
|
+
<!--
|
12
|
+
Briefly describe the feature if no issue exists for this PR
|
13
|
+
-->
|
14
|
+
|
15
|
+
## How did you implement it:
|
16
|
+
|
17
|
+
<!--
|
18
|
+
If this is a nontrivial change please briefly describe your implementation so its easy for us to understand and review your code.
|
19
|
+
-->
|
20
|
+
|
21
|
+
## How can we verify it:
|
22
|
+
|
23
|
+
<!--
|
24
|
+
Add any applicable config, commands, screenshots or other resources
|
25
|
+
to make it easy for us to verify this works. The easier you make it for us
|
26
|
+
to review a PR, the faster we can review and merge it.
|
27
|
+
|
28
|
+
Examples:
|
29
|
+
* serverless.yml - Fully functioning to easily deploy changes
|
30
|
+
* Screenshots - Showing the difference between your output and the master
|
31
|
+
* Cloud Configuration - List cloud resources and show that the correct configuration is in place (e.g. AWS CLI commands)
|
32
|
+
* Other - Anything else that comes to mind to help us evaluate
|
33
|
+
-->
|
34
|
+
|
35
|
+
## Todos:
|
36
|
+
|
37
|
+
- [ ] Write tests
|
38
|
+
- [ ] Write documentation
|
39
|
+
- [ ] Fix linting errors
|
40
|
+
- [ ] Make sure code coverage hasn't dropped
|
41
|
+
- [ ] Provide verification config / commands / resources
|
42
|
+
- [ ] Enable "Allow edits from maintainers" for this PR
|
43
|
+
- [ ] Update the messages below
|
44
|
+
|
45
|
+
***Is this ready for review?:*** NO
|
46
|
+
***Is it a breaking change?:*** NO
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.2
|
5
|
+
|
6
|
+
Style/EmptyCaseCondition:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Style/FormatStringToken:
|
10
|
+
EnforcedStyle: template
|
11
|
+
|
12
|
+
Style/TrailingCommaInLiteral:
|
13
|
+
EnforcedStyleForMultiline: consistent_comma
|
14
|
+
|
15
|
+
Metrics/LineLength:
|
16
|
+
Max: 124
|
17
|
+
AllowURI: true
|
18
|
+
URISchemes:
|
19
|
+
- http
|
20
|
+
- https
|
21
|
+
|
22
|
+
Metrics/BlockLength:
|
23
|
+
Exclude:
|
24
|
+
- 'spec/**/*'
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-01-16 23:25:20 +0900 using RuboCop version 0.52.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 5
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 26
|
12
|
+
|
13
|
+
# Offense count: 107
|
14
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Max: 446
|
17
|
+
|
18
|
+
# Offense count: 1
|
19
|
+
# Configuration parameters: CountComments.
|
20
|
+
Metrics/ClassLength:
|
21
|
+
Max: 170
|
22
|
+
|
23
|
+
# Offense count: 1
|
24
|
+
Metrics/CyclomaticComplexity:
|
25
|
+
Max: 7
|
26
|
+
|
27
|
+
# Offense count: 3
|
28
|
+
# Configuration parameters: CountComments.
|
29
|
+
Metrics/MethodLength:
|
30
|
+
Max: 15
|
31
|
+
|
32
|
+
# Offense count: 2
|
33
|
+
# Configuration parameters: CountKeywordArgs.
|
34
|
+
Metrics/ParameterLists:
|
35
|
+
Max: 7
|
36
|
+
|
37
|
+
# Offense count: 41
|
38
|
+
Style/Documentation:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Style/Lambda:
|
42
|
+
EnforcedStyle: literal
|
data/CHANGELOG.md
CHANGED
@@ -2,10 +2,10 @@ Changelog
|
|
2
2
|
====
|
3
3
|
|
4
4
|
|
5
|
-
[unreleased](https://github.com/koshigoe/brick_ftp/compare/v0.
|
5
|
+
[unreleased](https://github.com/koshigoe/brick_ftp/compare/v0.7.0...master)
|
6
6
|
----
|
7
7
|
|
8
|
-
[Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v0.
|
8
|
+
[Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v0.7.0...master)
|
9
9
|
|
10
10
|
### Enhancements:
|
11
11
|
|
@@ -14,6 +14,23 @@ Changelog
|
|
14
14
|
### Breaking Changes:
|
15
15
|
|
16
16
|
|
17
|
+
[v0.7.0](https://github.com/koshigoe/brick_ftp/compare/v0.6.1...v0.7.0)
|
18
|
+
----
|
19
|
+
|
20
|
+
[Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v0.6.1....v0.7.0)
|
21
|
+
|
22
|
+
### Enhancements:
|
23
|
+
|
24
|
+
- [#80](https://github.com/koshigoe/brick_ftp/pull/80) Use Rubocop.
|
25
|
+
- [#85](https://github.com/koshigoe/brick_ftp/pull/85) Allow `BrickFTP::Client#upload_file` to multi part uploading.
|
26
|
+
|
27
|
+
### Fixed Bugs:
|
28
|
+
|
29
|
+
### Breaking Changes:
|
30
|
+
|
31
|
+
- [#87](https://github.com/koshigoe/brick_ftp/pull/87) Support Ruby >= 2.2.0
|
32
|
+
|
33
|
+
|
17
34
|
[v0.6.1](https://github.com/koshigoe/brick_ftp/compare/v0.6.0...v0.6.1)
|
18
35
|
----
|
19
36
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
RuboCop::RakeTask.new
|
5
7
|
|
6
|
-
task :
|
8
|
+
task default: %i[rubocop spec]
|
data/bin/console
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'brick_ftp'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
|
-
require
|
9
|
+
require 'pry'
|
10
10
|
Pry.start
|
data/brick_ftp.gemspec
CHANGED
@@ -1,32 +1,35 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'brick_ftp/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'brick_ftp'
|
8
7
|
spec.version = BrickFTP::VERSION
|
9
|
-
spec.license =
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
8
|
+
spec.license = 'MIT'
|
9
|
+
spec.authors = ['koshigoe']
|
10
|
+
spec.email = ['koshigoeb@gmail.com']
|
12
11
|
|
13
|
-
spec.summary =
|
14
|
-
spec.description =
|
15
|
-
spec.homepage =
|
12
|
+
spec.summary = "BrickFTP's REST API client."
|
13
|
+
spec.description = "BrickFTP's REST API client."
|
14
|
+
spec.homepage = 'https://github.com/koshigoe/brick_ftp'
|
16
15
|
|
17
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir =
|
17
|
+
spec.bindir = 'exe'
|
19
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
21
20
|
|
22
|
-
spec.
|
23
|
-
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
21
|
+
spec.required_ruby_version = '>= 2.2.0'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
24
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 0.52'
|
28
|
+
spec.add_development_dependency 'simplecov', '~> 0.15'
|
29
|
+
spec.add_development_dependency 'webmock', '~> 2.1'
|
30
|
+
spec.add_development_dependency 'yard', '~> 0.9'
|
28
31
|
|
29
32
|
spec.add_dependency 'deep_hash_transform', '~> 1.0'
|
30
|
-
spec.add_dependency 'thor', '~> 0.19.1'
|
31
33
|
spec.add_dependency 'inifile', '~> 3.0.0'
|
34
|
+
spec.add_dependency 'thor', '~> 0.19.1'
|
32
35
|
end
|
data/exe/brick_ftp
CHANGED
data/lib/brick_ftp.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'deep_hash_transform'
|
2
2
|
require 'thor'
|
3
|
-
require
|
3
|
+
require 'brick_ftp/version'
|
4
4
|
require 'brick_ftp/configuration'
|
5
5
|
require 'brick_ftp/log_formatter'
|
6
6
|
require 'brick_ftp/http_client'
|
@@ -40,10 +40,12 @@ require 'brick_ftp/cli'
|
|
40
40
|
require 'brick_ftp/cli/config'
|
41
41
|
require 'brick_ftp/cli/site'
|
42
42
|
require 'brick_ftp/cli/main'
|
43
|
+
require 'brick_ftp/utils'
|
44
|
+
require 'brick_ftp/utils/chunk_io'
|
43
45
|
|
44
46
|
module BrickFTP
|
45
47
|
# https://brickftp.com/redundancy/
|
46
|
-
IP_ADDRESSES = %w
|
48
|
+
IP_ADDRESSES = %w[
|
47
49
|
54.193.69.72
|
48
50
|
54.193.69.200
|
49
51
|
54.193.65.189
|
@@ -72,7 +74,7 @@ module BrickFTP
|
|
72
74
|
52.29.176.178
|
73
75
|
54.207.27.239
|
74
76
|
52.68.4.44
|
75
|
-
|
77
|
+
].freeze
|
76
78
|
|
77
79
|
# Return configuration.
|
78
80
|
# If it has not been configured yet, initialize configuration.
|
data/lib/brick_ftp/api/base.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module BrickFTP
|
2
2
|
module API
|
3
3
|
class BundleContent < Base
|
4
|
-
endpoint :post, :index, ->(params)
|
4
|
+
endpoint :post, :index, ->(params) do
|
5
5
|
params.key?(:path) ? '/api/rest/v1/bundles/folders/%{path}' : '/api/rest/v1/bundles/folders'
|
6
|
-
|
6
|
+
end
|
7
7
|
|
8
8
|
attribute :id
|
9
9
|
attribute :path
|
@@ -31,17 +31,34 @@ module BrickFTP
|
|
31
31
|
attribute :part, writable: true
|
32
32
|
attribute :restart, writable: true
|
33
33
|
|
34
|
-
|
34
|
+
# Upload file.
|
35
|
+
#
|
36
|
+
# @see https://brickftp.com/docs/rest-api/file-uploading/
|
37
|
+
# @param [String] path Remote file path.
|
38
|
+
# @param [IO] source Source `data` (not `path`) to upload.
|
39
|
+
# @param [Integer] chunk_size Size of chunk to multi-part upload.
|
40
|
+
# @return [BrickFTP::API::FileOperation::Upload] An instance of BrickFTP::API::FileOperation::Upload.
|
41
|
+
#
|
42
|
+
def self.create(path:, source:, chunk_size: nil)
|
35
43
|
api_client = BrickFTP::HTTPClient.new
|
36
|
-
|
44
|
+
chunk_io = BrickFTP::Utils::ChunkIO.new(source, chunk_size: chunk_size)
|
37
45
|
|
38
|
-
|
39
|
-
|
40
|
-
|
46
|
+
ref = nil
|
47
|
+
params_for_request_upload_url = { action: 'put' }
|
48
|
+
upload_info = {}
|
49
|
+
chunk_io.each.with_index(1) do |chunk, part|
|
50
|
+
params_for_request_upload_url.update(part: part, ref: ref) if part > 1
|
51
|
+
upload_info = api_client.post(api_path_for(:create, path: path), params: params_for_request_upload_url)
|
52
|
+
ref = upload_info['ref']
|
41
53
|
|
42
|
-
|
54
|
+
upload_uri = URI.parse(upload_info['upload_uri'])
|
55
|
+
upload_client = BrickFTP::HTTPClient.new(upload_uri.host)
|
56
|
+
upload_client.put(upload_info['upload_uri'], params: chunk)
|
57
|
+
end
|
43
58
|
|
44
|
-
|
59
|
+
uploaded_info = api_client.post(api_path_for(:create, path: path), params: { action: 'end', ref: ref })
|
60
|
+
|
61
|
+
new(upload_info.merge(uploaded_info).symbolize_keys)
|
45
62
|
end
|
46
63
|
end
|
47
64
|
end
|
data/lib/brick_ftp/api/folder.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module BrickFTP
|
2
2
|
module API
|
3
3
|
class Folder < Base
|
4
|
+
# rubocop:disable Metrics/LineLength
|
4
5
|
endpoint :get, :index, '/api/rest/v1/folders/%{path}', :page, :per_page, :search, :'sort_by[path]', :'sort_by[size]', :'sort_by[modified_at_datetime]'
|
6
|
+
# rubocop:enable Metrics/LineLength
|
5
7
|
endpoint :post, :create, '/api/rest/v1/folders/%{path}'
|
6
8
|
|
7
9
|
attribute :id
|
data/lib/brick_ftp/client.rb
CHANGED
@@ -136,7 +136,8 @@ module BrickFTP
|
|
136
136
|
# Show the entire history for the current site.
|
137
137
|
# @see https://brickftp.com/ja/docs/rest-api/history/
|
138
138
|
# @param page [Integer] Page number of items to return in this request.
|
139
|
-
# @param per_page [Integer] Requested number of items returned per request. Default: 1000, maximum: 10000.
|
139
|
+
# @param per_page [Integer] Requested number of items returned per request. Default: 1000, maximum: 10000.
|
140
|
+
# Leave blank for default (strongly recommended).
|
140
141
|
# @param start_at [String] Date and time in the history to start from.
|
141
142
|
# @return [Array] array of `BrickFTP::API::History::Site`
|
142
143
|
def list_site_history(page: nil, per_page: nil, start_at: nil)
|
@@ -147,7 +148,8 @@ module BrickFTP
|
|
147
148
|
# Show login history only.
|
148
149
|
# @see https://brickftp.com/ja/docs/rest-api/history/
|
149
150
|
# @param page [Integer] Page number of items to return in this request.
|
150
|
-
# @param per_page [Integer] Requested number of items returned per request. Default: 1000, maximum: 10000.
|
151
|
+
# @param per_page [Integer] Requested number of items returned per request. Default: 1000, maximum: 10000.
|
152
|
+
# Leave blank for default (strongly recommended).
|
151
153
|
# @param start_at [String] Date and time in the history to start from.
|
152
154
|
# @return [Array] array of `BrickFTP::API::History::Login`
|
153
155
|
def list_login_history(page: nil, per_page: nil, start_at: nil)
|
@@ -159,7 +161,8 @@ module BrickFTP
|
|
159
161
|
# @see https://brickftp.com/ja/docs/rest-api/history/
|
160
162
|
# @param user_id [Integer] User ID.
|
161
163
|
# @param page [Integer] Page number of items to return in this request.
|
162
|
-
# @param per_page [Integer] Requested number of items returned per request.
|
164
|
+
# @param per_page [Integer] Requested number of items returned per request.
|
165
|
+
# Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
|
163
166
|
# @param start_at [String] Date and time in the history to start from.
|
164
167
|
# @return [Array] array of `BrickFTP::API::History::User`
|
165
168
|
def list_user_history(user_id:, page: nil, per_page: nil, start_at: nil)
|
@@ -171,7 +174,8 @@ module BrickFTP
|
|
171
174
|
# @see https://brickftp.com/ja/docs/rest-api/history/
|
172
175
|
# @param path [String] path of folder.
|
173
176
|
# @param page [Integer] Page number of items to return in this request.
|
174
|
-
# @param per_page [Integer] Requested number of items returned per request.
|
177
|
+
# @param per_page [Integer] Requested number of items returned per request.
|
178
|
+
# Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
|
175
179
|
# @param start_at [String] Date and time in the history to start from.
|
176
180
|
# @return [Array] array of `BrickFTP::API::History::Folder`
|
177
181
|
def list_folder_history(path:, page: nil, per_page: nil, start_at: nil)
|
@@ -183,7 +187,8 @@ module BrickFTP
|
|
183
187
|
# @see https://brickftp.com/ja/docs/rest-api/history/
|
184
188
|
# @param path [String] path of file.
|
185
189
|
# @param page [Integer] Page number of items to return in this request.
|
186
|
-
# @param per_page [Integer] Requested number of items returned per request.
|
190
|
+
# @param per_page [Integer] Requested number of items returned per request.
|
191
|
+
# Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
|
187
192
|
# @param start_at [String] Date and time in the history to start from.
|
188
193
|
# @return [Array] array of `BrickFTP::API::History::File`
|
189
194
|
def list_file_history(path:, page: nil, per_page: nil, start_at: nil)
|
@@ -291,13 +296,17 @@ module BrickFTP
|
|
291
296
|
# @see https://brickftp.com/ja/docs/rest-api/file-operations/
|
292
297
|
# @param path [String]
|
293
298
|
# @param page [Integer] Page number of items to return in this request.
|
294
|
-
# @param per_page [Integer] Requested number of items returned per request.
|
299
|
+
# @param per_page [Integer] Requested number of items returned per request.
|
300
|
+
# Maximum: 5000, leave blank for default (strongly recommended).
|
295
301
|
# @param search [String] Only return items matching the given search text.
|
296
|
-
# @param sort_by_path [String] Sort by file name, and value is either asc or desc to indicate normal or reverse sort.
|
297
|
-
#
|
298
|
-
# @param
|
302
|
+
# @param sort_by_path [String] Sort by file name, and value is either asc or desc to indicate normal or reverse sort.
|
303
|
+
# (Note that sort_by[path] = asc is the default.)
|
304
|
+
# @param sort_by_size [String] Sort by file size, and value is either asc or desc to indicate smaller files
|
305
|
+
# first or larger files first, respectively.
|
306
|
+
# @param sort_by_modified_at_datetime [String] Sort by modification time, and value is either asc or desc to
|
307
|
+
# indicate older files first or newer files first, respectively.
|
299
308
|
# @return [Array] array of BrickFTP::API::Folder.
|
300
|
-
def list_folders(path:, page: nil, per_page: nil, search: nil, sort_by_path: nil, sort_by_size: nil, sort_by_modified_at_datetime: nil)
|
309
|
+
def list_folders(path:, page: nil, per_page: nil, search: nil, sort_by_path: nil, sort_by_size: nil, sort_by_modified_at_datetime: nil) # rubocop:disable Metrics/LineLength
|
301
310
|
query = { path: path, page: page, per_page: per_page, search: search }.reject { |_, v| v.nil? }
|
302
311
|
query[:'sort_by[path]'] = sort_by_path if sort_by_path
|
303
312
|
query[:'sort_by[size]'] = sort_by_size if sort_by_size
|
@@ -330,7 +339,7 @@ module BrickFTP
|
|
330
339
|
# @param move_destination [String]
|
331
340
|
# @return [BrickFTP::API::FileMove]
|
332
341
|
def move_file(path:, move_destination:)
|
333
|
-
BrickFTP::API::FileOperation::Move.create(path: path,
|
342
|
+
BrickFTP::API::FileOperation::Move.create(path: path, 'move-destination': move_destination)
|
334
343
|
end
|
335
344
|
|
336
345
|
# Copy a file or folder to the destination provided in the copy_destination parameter.
|
@@ -339,13 +348,13 @@ module BrickFTP
|
|
339
348
|
# @param copy_destination [String]
|
340
349
|
# @return [BrickFTP::API::FileCopy]
|
341
350
|
def copy_file(path:, copy_destination:)
|
342
|
-
BrickFTP::API::FileOperation::Copy.create(path: path,
|
351
|
+
BrickFTP::API::FileOperation::Copy.create(path: path, 'copy-destination': copy_destination)
|
343
352
|
end
|
344
353
|
|
345
354
|
# Delete a file.
|
346
355
|
# @see https://brickftp.com/ja/docs/rest-api/file-operations/
|
347
356
|
# @param file_or_path [BrickFTP::API::File, String] file object or file(folder) path.
|
348
|
-
# @param recursive
|
357
|
+
# @param recursive [Boolean]
|
349
358
|
# @return [Boolean] return true.
|
350
359
|
def delete_file(file_or_path, recursive: false)
|
351
360
|
instantize_file(file_or_path).destroy(recursive: recursive)
|
@@ -355,9 +364,10 @@ module BrickFTP
|
|
355
364
|
# @see https://brickftp.com/ja/docs/rest-api/file-uploading/
|
356
365
|
# @param path [String]
|
357
366
|
# @param source [IO] source `data` (not `path`) to upload
|
367
|
+
# @param chunk_size [Integer] Size of chunk to multi-part upload.
|
358
368
|
# @return [BrickFTP::API::FileUpload]
|
359
|
-
def upload_file(path:, source:)
|
360
|
-
BrickFTP::API::FileOperation::Upload.create(path: path, source: source)
|
369
|
+
def upload_file(path:, source:, chunk_size: nil)
|
370
|
+
BrickFTP::API::FileOperation::Upload.create(path: path, source: source, chunk_size: chunk_size)
|
361
371
|
end
|
362
372
|
|
363
373
|
# Get usage of site.
|
@@ -23,10 +23,10 @@ module BrickFTP
|
|
23
23
|
attr_accessor :logger
|
24
24
|
# Log level
|
25
25
|
# @return [Integer]
|
26
|
-
|
26
|
+
attr_reader :log_level
|
27
27
|
# Log formatter
|
28
28
|
# @return [Logger::Formatter]
|
29
|
-
|
29
|
+
attr_reader :log_formatter
|
30
30
|
# Open timeout
|
31
31
|
# @return [Integer]
|
32
32
|
attr_accessor :open_timeout
|
@@ -39,7 +39,7 @@ module BrickFTP
|
|
39
39
|
|
40
40
|
DEFAULT_PROFILE = 'global'.freeze
|
41
41
|
# Name of storable configurations. (TODO: log_path, log_level, log_formatter)
|
42
|
-
STORABLE_CONFIGURATION_KEYS = %w
|
42
|
+
STORABLE_CONFIGURATION_KEYS = %w[subdomain api_key open_timeout read_timeout].freeze
|
43
43
|
|
44
44
|
STORABLE_CONFIGURATION_KEYS.each do |name|
|
45
45
|
define_method("#{name}=") do |value|
|
@@ -104,7 +104,7 @@ module BrickFTP
|
|
104
104
|
|
105
105
|
private
|
106
106
|
|
107
|
-
attr_reader :inifile
|
107
|
+
attr_reader :inifile
|
108
108
|
|
109
109
|
def load_config_file(config_file_path)
|
110
110
|
@inifile = if config_file_path && File.exist?(config_file_path)
|
@@ -8,7 +8,7 @@ module BrickFTP
|
|
8
8
|
def initialize(response)
|
9
9
|
begin
|
10
10
|
error = JSON.parse(response.body)
|
11
|
-
rescue
|
11
|
+
rescue StandardError
|
12
12
|
error = { 'http-code' => response.code, 'error' => "#{response.message}, #{response.body}" }
|
13
13
|
end
|
14
14
|
|
@@ -80,6 +80,8 @@ module BrickFTP
|
|
80
80
|
|
81
81
|
private
|
82
82
|
|
83
|
+
# FIXME: Metrics/AbcSize, Metrics/MethodLength
|
84
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
83
85
|
def request(method, path, params: {}, headers: {})
|
84
86
|
req = Net::HTTP.const_get(method.to_s.capitalize).new(path, headers)
|
85
87
|
req['User-Agent'] = USER_AGENT
|
@@ -99,21 +101,28 @@ module BrickFTP
|
|
99
101
|
req.body = params.to_json unless params.empty?
|
100
102
|
when params.is_a?(IO)
|
101
103
|
req.body_stream = params
|
102
|
-
req[
|
104
|
+
req['Content-Length'] = params.size
|
103
105
|
end
|
104
106
|
|
105
107
|
start = Time.now
|
106
108
|
begin
|
107
|
-
logger.debug 'Request headers: %{headers}'
|
108
|
-
logger.debug 'Request body: %{body}'
|
109
|
+
logger.debug format('Request headers: %{headers}', headers: req.each_capitalized.map { |k, v| "#{k}: #{v}" })
|
110
|
+
logger.debug format('Request body: %{body}', body: req.body)
|
109
111
|
@conn.request(req).tap do |res|
|
110
|
-
logger.debug 'Response headers: %{headers}'
|
111
|
-
logger.debug 'Response body: %{body}'
|
112
|
+
logger.debug format('Response headers: %{headers}', headers: res.each_capitalized.map { |k, v| "#{k}: #{v}" })
|
113
|
+
logger.debug format('Response body: %{body}', body: res.body)
|
112
114
|
end
|
113
115
|
ensure
|
114
|
-
|
116
|
+
message = format(
|
117
|
+
'Complete %{method} %{path} (%{time} ms)',
|
118
|
+
method: method.upcase,
|
119
|
+
path: path,
|
120
|
+
time: (Time.now - start) * 1000
|
121
|
+
)
|
122
|
+
logger.info message
|
115
123
|
end
|
116
124
|
end
|
125
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
117
126
|
|
118
127
|
def logger
|
119
128
|
BrickFTP.logger
|
@@ -2,7 +2,7 @@ module BrickFTP
|
|
2
2
|
class LogFormatter < Logger::Formatter
|
3
3
|
FORMAT = "severity:%{severity}\tpid:%{pid}\ttime:%{time}\tmessage:%{message}\n".freeze
|
4
4
|
|
5
|
-
def call(severity, time,
|
5
|
+
def call(severity, time, _program_name, message)
|
6
6
|
params = {
|
7
7
|
severity: severity,
|
8
8
|
pid: Process.pid,
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module Utils
|
5
|
+
class ChunkIO
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
attr_reader :io, :chunk_size
|
9
|
+
|
10
|
+
# Wrap IO object.
|
11
|
+
#
|
12
|
+
# @param [IO] io an IO object.
|
13
|
+
# @param [Integer] chunk_size Size of chunk.
|
14
|
+
#
|
15
|
+
def initialize(io, chunk_size: nil)
|
16
|
+
@io = io
|
17
|
+
@chunk_size = chunk_size
|
18
|
+
end
|
19
|
+
|
20
|
+
# Iterate with chunked IO object.
|
21
|
+
#
|
22
|
+
# @yield [chunk] Give a chunk IO object to block.
|
23
|
+
# @yieldparam [StringIO] chunk a chunked IO object.
|
24
|
+
#
|
25
|
+
def each(&block)
|
26
|
+
return enum_for(__method__) unless block
|
27
|
+
|
28
|
+
if chunk_size
|
29
|
+
each_chunk(&block)
|
30
|
+
else
|
31
|
+
whole(&block)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def whole
|
38
|
+
yield io
|
39
|
+
end
|
40
|
+
|
41
|
+
def each_chunk
|
42
|
+
eof = false
|
43
|
+
offset = 0
|
44
|
+
until eof
|
45
|
+
Tempfile.create('chunk-io') do |chunk|
|
46
|
+
copied = IO.copy_stream(io, chunk, chunk_size, offset)
|
47
|
+
eof = copied.zero?
|
48
|
+
next if eof
|
49
|
+
|
50
|
+
offset += copied
|
51
|
+
chunk.rewind
|
52
|
+
|
53
|
+
yield chunk
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/brick_ftp/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- koshigoe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.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.10'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,47 +67,61 @@ dependencies:
|
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '3.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: rubocop
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
75
|
+
version: '0.52'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '0.52'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: simplecov
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0.
|
89
|
+
version: '0.15'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
96
|
+
version: '0.15'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: webmock
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
103
|
+
version: '2.1'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
110
|
+
version: '2.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: yard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.9'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.9'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: deep_hash_transform
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,33 +137,33 @@ dependencies:
|
|
109
137
|
- !ruby/object:Gem::Version
|
110
138
|
version: '1.0'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
140
|
+
name: inifile
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
114
142
|
requirements:
|
115
143
|
- - "~>"
|
116
144
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
145
|
+
version: 3.0.0
|
118
146
|
type: :runtime
|
119
147
|
prerelease: false
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
150
|
- - "~>"
|
123
151
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
152
|
+
version: 3.0.0
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
154
|
+
name: thor
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
128
156
|
requirements:
|
129
157
|
- - "~>"
|
130
158
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
159
|
+
version: 0.19.1
|
132
160
|
type: :runtime
|
133
161
|
prerelease: false
|
134
162
|
version_requirements: !ruby/object:Gem::Requirement
|
135
163
|
requirements:
|
136
164
|
- - "~>"
|
137
165
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
166
|
+
version: 0.19.1
|
139
167
|
description: BrickFTP's REST API client.
|
140
168
|
email:
|
141
169
|
- koshigoeb@gmail.com
|
@@ -144,9 +172,13 @@ executables:
|
|
144
172
|
extensions: []
|
145
173
|
extra_rdoc_files: []
|
146
174
|
files:
|
175
|
+
- ".circleci/config.yml"
|
176
|
+
- ".github/ISSUE_TEMPLATE.md"
|
177
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
147
178
|
- ".gitignore"
|
148
179
|
- ".rspec"
|
149
|
-
- ".
|
180
|
+
- ".rubocop.yml"
|
181
|
+
- ".rubocop_todo.yml"
|
150
182
|
- CHANGELOG.md
|
151
183
|
- Gemfile
|
152
184
|
- LICENSE.txt
|
@@ -194,6 +226,8 @@ files:
|
|
194
226
|
- lib/brick_ftp/configuration.rb
|
195
227
|
- lib/brick_ftp/http_client.rb
|
196
228
|
- lib/brick_ftp/log_formatter.rb
|
229
|
+
- lib/brick_ftp/utils.rb
|
230
|
+
- lib/brick_ftp/utils/chunk_io.rb
|
197
231
|
- lib/brick_ftp/version.rb
|
198
232
|
- lib/brick_ftp/webhook.rb
|
199
233
|
- lib/brick_ftp/webhook/request.rb
|
@@ -209,7 +243,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
243
|
requirements:
|
210
244
|
- - ">="
|
211
245
|
- !ruby/object:Gem::Version
|
212
|
-
version:
|
246
|
+
version: 2.2.0
|
213
247
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
248
|
requirements:
|
215
249
|
- - ">="
|
@@ -217,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
251
|
version: '0'
|
218
252
|
requirements: []
|
219
253
|
rubyforge_project:
|
220
|
-
rubygems_version: 2.
|
254
|
+
rubygems_version: 2.7.3
|
221
255
|
signing_key:
|
222
256
|
specification_version: 4
|
223
257
|
summary: BrickFTP's REST API client.
|