sftp_wrapper 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2e0e228c73646e79c09685f1b70acc11cf5f65ac18c5c2fd37441f3b75c5b2a
4
- data.tar.gz: 0b76e0a5149bbc6d2e79c942121aacc5dcb83069647d95347824777812c452f1
3
+ metadata.gz: e165201ad7f2d7cb97746ca0f0e13f4796a1a7fd254ef07158bd7f49837969fd
4
+ data.tar.gz: 982118802dc86453fc18d0fb927e5cf0673308e2d2c6b232f188ec32accaec48
5
5
  SHA512:
6
- metadata.gz: a66da813d9e6a2519afb0bd9fe2b0c5d40433ca7b63025cf7a53bda52bd3afe40e7230513c081feda33d8d9169c7fdca472ea4ae3a7de702f6045b2c1da07935
7
- data.tar.gz: 6741c93b50de825182c507c62c45b412083094ee355f3f93529d5438ca9b08ed3638dd96905d649258dc88527fa6f37827618d89d5e3a6221932ff87e9a64f57
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: bundle install, run test
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
@@ -4,6 +4,7 @@ AllCops:
4
4
  Metrics/BlockLength:
5
5
  Exclude:
6
6
  - "test/**/*_test.rb"
7
+ - "benchmark/*.rb"
7
8
  - "*.gemspec"
8
9
 
9
10
  Metrics/ClassLength:
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
@@ -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, :curl_command, :curl_options
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 curl_options [Hash] curl options. (e.g. --connect-timeout 1 => connect_timeout: 1)
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, curl_options = {})
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
- @curl_command = curl_options.key?(:command_path) ? curl_options.delete(:command_path) : 'curl'
34
- @curl_options = curl_options
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[#{curl_command} -s --insecure -o #{destination}] + build_curl_options + [uri.to_s]
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[#{curl_command} -s --insecure -T #{source}] + build_curl_options + [uri.to_s]
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
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module SftpWrapper
4
4
  # version number.
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
  end
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.1.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-12 00:00:00.000000000 Z
11
+ date: 2019-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler