sftp_wrapper 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/continuous-integration-workflow.yml +9 -1
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/sftp_wrapper/curl.rb +9 -11
- data/lib/sftp_wrapper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e165201ad7f2d7cb97746ca0f0e13f4796a1a7fd254ef07158bd7f49837969fd
|
4
|
+
data.tar.gz: 982118802dc86453fc18d0fb927e5cf0673308e2d2c6b232f188ec32accaec48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a59acb94542d3c88e1685fc986a14864e0c62e57c17e354b828e46eec7fdab4226fe71c3fa109cd742a69665f419dec049d259e9d49876a223a8489fbceb225
|
7
|
+
data.tar.gz: 8af2ef626911b7ec3fbcdb66b6686e3e22e0c2eb36a79c2c9176eee97489f4665aa761761f132930553c08b6ed22a2f30ff0f2b56e6609f31623b65f25f06a6e
|
@@ -40,10 +40,18 @@ jobs:
|
|
40
40
|
./configure --disable-libcurl-option --disable-shared --with-libssh2 --with-ssl
|
41
41
|
make
|
42
42
|
sudo make install
|
43
|
-
- name:
|
43
|
+
- name: setup rubygems
|
44
44
|
run: |
|
45
45
|
gem install bundler -v1.17 --force --no-document
|
46
46
|
bundle install
|
47
|
+
- name: rubocop
|
48
|
+
run: |
|
49
|
+
bundle exec rubocop
|
50
|
+
- name: yard
|
51
|
+
run: |
|
52
|
+
bundle exec yard --fail-on-warning
|
53
|
+
- name: run test
|
54
|
+
run: |
|
47
55
|
bundle exec rake
|
48
56
|
release:
|
49
57
|
name: Release Gem
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
Changelog
|
2
2
|
====
|
3
3
|
|
4
|
+
[v0.2.0](https://github.com/koshigoe/sftp_wrapper/releases/tag/v0.2.0)
|
5
|
+
----
|
6
|
+
|
7
|
+
### Breaking Change
|
8
|
+
|
9
|
+
- [#1](https://github.com/koshigoe/sftp_wrapper/pull/1) Change method signature of `SftpWrapper::Curl#initialize`.
|
10
|
+
|
11
|
+
|
4
12
|
[v0.1.0](https://github.com/koshigoe/sftp_wrapper/releases/tag/v0.1.0)
|
5
13
|
----
|
6
14
|
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ Or install it yourself as:
|
|
26
26
|
require 'sftp_wrapper'
|
27
27
|
|
28
28
|
SftpWrapper::OpenSSH.new('localhost', 2222, 'test', 'pass').download('/upload/file', './file')
|
29
|
-
SftpWrapper::Curl.new('localhost', 2222, 'test', 'pass').download('/upload/file', './file')
|
29
|
+
SftpWrapper::Curl.new('localhost', 2222, 'test', 'pass', curl_args: ['--silent', '--insecure']).download('/upload/file', './file')
|
30
30
|
```
|
31
31
|
|
32
32
|
## Development
|
data/lib/sftp_wrapper/curl.rb
CHANGED
@@ -7,7 +7,7 @@ require 'open3'
|
|
7
7
|
module SftpWrapper
|
8
8
|
# The wrapper for curl.
|
9
9
|
class Curl
|
10
|
-
attr_reader :host, :port, :username, :password, :
|
10
|
+
attr_reader :host, :port, :username, :password, :curl_path, :curl_args
|
11
11
|
|
12
12
|
# lookup table of curl errors.
|
13
13
|
CURL_ERRORS = {
|
@@ -23,15 +23,17 @@ module SftpWrapper
|
|
23
23
|
# @param port [Integer] port number of SFTP server
|
24
24
|
# @param username [String] user name of SFTP server
|
25
25
|
# @param password [String] password of SFTP server
|
26
|
-
# @param
|
26
|
+
# @param options [Hash] curl options.
|
27
|
+
# @option options [String] :curl_path path of `curl` command.
|
28
|
+
# @option options [Array<String>] :curl_args command line arguments of `curl`.
|
27
29
|
#
|
28
|
-
def initialize(host, port, username, password,
|
30
|
+
def initialize(host, port, username, password, options = {})
|
29
31
|
@host = host
|
30
32
|
@port = port
|
31
33
|
@username = username
|
32
34
|
@password = password
|
33
|
-
@
|
34
|
-
@
|
35
|
+
@curl_path = options[:curl_path] || 'curl'
|
36
|
+
@curl_args = options[:curl_args] || []
|
35
37
|
end
|
36
38
|
|
37
39
|
# Get remote file.
|
@@ -45,7 +47,7 @@ module SftpWrapper
|
|
45
47
|
def download(source, destination)
|
46
48
|
userinfo = [username, password].map(&ERB::Util.method(:url_encode)).join(':')
|
47
49
|
uri = URI::Generic.build(scheme: 'sftp', userinfo: userinfo, host: host, port: port, path: source)
|
48
|
-
cmd = %W[#{
|
50
|
+
cmd = %W[#{curl_path} -o #{destination}] + curl_args + [uri.to_s]
|
49
51
|
|
50
52
|
execute(*cmd)
|
51
53
|
end
|
@@ -61,17 +63,13 @@ module SftpWrapper
|
|
61
63
|
def upload(source, destination)
|
62
64
|
userinfo = [username, password].map(&ERB::Util.method(:url_encode)).join(':')
|
63
65
|
uri = URI::Generic.build(scheme: 'sftp', userinfo: userinfo, host: host, port: port, path: destination)
|
64
|
-
cmd = %W[#{
|
66
|
+
cmd = %W[#{curl_path} -T #{source}] + curl_args + [uri.to_s]
|
65
67
|
|
66
68
|
execute(*cmd)
|
67
69
|
end
|
68
70
|
|
69
71
|
private
|
70
72
|
|
71
|
-
def build_curl_options
|
72
|
-
curl_options.map { |k, v| ["--#{k.tr('_', '-')}", v] }.flatten
|
73
|
-
end
|
74
|
-
|
75
73
|
def execute(*cmd)
|
76
74
|
_, stderr, status = Open3.capture3(*cmd)
|
77
75
|
|
data/lib/sftp_wrapper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sftp_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka SUZUKI
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|