xftp 0.2.1.pre.alpha → 0.3.1

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
  SHA1:
3
- metadata.gz: d82f44266494fe12bc8cf104135f043b3689e2c1
4
- data.tar.gz: 5f5ccac9192ec65a366bc958ee625b31fc582602
3
+ metadata.gz: 94b5dbf5e21b39d3b835ee82e7c5052e2d91b9cd
4
+ data.tar.gz: c8603e1ea11916ebd88643d40f0193058a904639
5
5
  SHA512:
6
- metadata.gz: 1b8ed8dffdf2737832b99cb3849f3bf3c1340da21eb5b49f3385cacae2d0ade0cf3cfdb2e6dc387323d7a11bb40e6768aa8d80ff4b2e963c750e30576d55bbd9
7
- data.tar.gz: 49778fb1e45dc2468e49de0ef63e410b5fe180764f24953631afc5a73ffcef2b37d1ff359e18e8fdaa6e024edd261df828ef033d5436e1603bf162bf5c7203a2
6
+ metadata.gz: 9b8f0d40ae542fece17fa93997d0ed5240c596377a2014e9dc11f36d454618cd9023a13cf23b99c6b2ab23666c184ab1475e531e548a1e7330a3c180f1a04925
7
+ data.tar.gz: e88abe3a98469dfb68b6d95641f0111decba2c0ed33c8a6ec475677a6fbe12a914bbfe9fa9f80c013bea679867ceb0d2e235540724ffdc23332b8bd4a460a5aa
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/vyorkin/xftp.svg)](https://travis-ci.org/vyorkin/xftp)
2
+
1
3
  # xftp
2
4
 
3
5
  Unified interface for ftp/sftp.
@@ -23,20 +23,8 @@ module XFTP
23
23
  end
24
24
  end
25
25
 
26
- config_accessor :logging do
27
- default_logger = lambda do
28
- logger = Logger.new(STDERR)
29
- logger.level = Logger::ERROR
30
- end
31
-
32
- rails_logger = -> { Rails.logger || default_logger.call }
33
- logger = defined?(Rails) ? rails_logger.call : default_logger.call
34
-
35
- {
36
- logger: logger,
37
- verbose: false,
38
- colorize: true
39
- }
26
+ config_accessor :logger do
27
+ defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
40
28
  end
41
29
 
42
30
  config_accessor :ftp do
@@ -0,0 +1,19 @@
1
+ require 'colorize'
2
+
3
+ module XFTP
4
+ module Helpers
5
+ # Provides logging helper methods
6
+ # @api private
7
+ module Logging
8
+ # Appends message to log
9
+ # @param [String] message the log message
10
+ # @param [Symbol] severity the message severity
11
+ # @param [Symbol] color
12
+ # :reek:UtilityFunction:
13
+ def log(message, severity: :info, color: :white)
14
+ text = message.colorize(color)
15
+ XFTP.config.logger.public_send(severity, text)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,4 @@
1
+ require 'xftp/helpers/logging'
1
2
  require 'xftp/dsl/block_evaluator'
2
3
 
3
4
  module XFTP
@@ -6,6 +7,7 @@ module XFTP
6
7
  # @api private
7
8
  class Base
8
9
  include DSL::BlockEvaluator
10
+ include Helpers::Logging
9
11
 
10
12
  attr_reader :uri, :credentials, :settings
11
13
 
@@ -21,9 +23,11 @@ module XFTP
21
23
  # Opens a new connection, evaluates the given block and closes the connection
22
24
  # @param [Proc] callback the callback to operate on a connection session
23
25
  def start(&callback)
26
+ log 'starting'
24
27
  open
25
28
  evaluate(&callback)
26
29
  close
30
+ log 'done'
27
31
  end
28
32
  end
29
33
  end
@@ -13,7 +13,7 @@ module XFTP
13
13
 
14
14
  # Delegate methods which have the same method signature
15
15
  # directly to Net::FTP session
16
- def_delegators :@ftp, :chdir, :mkdir, :rmdir, :close
16
+ def_delegators :@ftp, :chdir, :mkdir, :rmdir
17
17
 
18
18
  # Creates an FTP session adapter instance
19
19
  # @param [URI] uri the remote uri
@@ -54,6 +54,7 @@ module XFTP
54
54
  # @param [String] from the path to move from
55
55
  # @param [String] to the new path to move to
56
56
  def move(from, to:)
57
+ log "moving from #{from} to #{to}..."
57
58
  @ftp.rename(from, to)
58
59
  end
59
60
 
@@ -74,6 +75,7 @@ module XFTP
74
75
  # @param [Integer] block_size the size of file chunk
75
76
  # @see Net::FTP#get
76
77
  def download(from, to: File.basename(from), block_size: Net::FTP::DEFAULT_BLOCKSIZE)
78
+ log "downloading file from #{from} to #{to}..."
77
79
  @ftp.get(from, to, block_size)
78
80
  end
79
81
 
@@ -93,8 +95,17 @@ module XFTP
93
95
 
94
96
  # Opens a new FTP connection and authenticates on the remote server
95
97
  def open
98
+ log 'opening connection...'
96
99
  @ftp.connect(@uri.host, @port)
100
+ log 'connected'
97
101
  @ftp.login(@credentials[:login], @credentials[:password])
102
+ log 'logging in...'
103
+ end
104
+
105
+ # Closes FTP connection
106
+ def close
107
+ log 'closing connection'
108
+ @ftp.close
98
109
  end
99
110
  end
100
111
  end
@@ -66,6 +66,7 @@ module XFTP
66
66
  # @param [String] from the path to move from
67
67
  # @param [String] to the path to move to
68
68
  def move(from, to:, flags: RENAME_OPERATION_FLAGS)
69
+ log "moving from #{from} to #{to}..."
69
70
  @sftp.rename!(remote_path(from), remote_path(to), flags)
70
71
  end
71
72
 
@@ -93,6 +94,7 @@ module XFTP
93
94
  # @param [Hash] options the download operation options
94
95
  # @see Net::SFTP::Operations::Download
95
96
  def download(from, to: File.basename(from), **options)
97
+ log "downloading file from #{from} to #{to}..."
96
98
  remote = remote_path(from)
97
99
  local = (Pathname.pwd + to).to_s
98
100
  @sftp.download!(remote, local, options)
@@ -126,15 +128,18 @@ module XFTP
126
128
 
127
129
  # Closes SFTP (SSH) connection
128
130
  def close
131
+ log 'closing connection'
129
132
  @ssh.close
130
133
  end
131
134
 
132
135
  private
133
136
 
134
137
  def connect
138
+ log 'opening connection...'
135
139
  @ssh = Net::SSH.start(@uri.host, @credentials[:login], @ssh_options)
136
140
  @sftp = Net::SFTP::Session.new @ssh
137
141
  @sftp.connect!
142
+ log 'connected'
138
143
  end
139
144
 
140
145
  # @return [String] a path name relative to the current working directory
@@ -2,11 +2,11 @@ module XFTP
2
2
  # Gem version builder module
3
3
  module VERSION
4
4
  MAJOR = 0
5
- MINOR = 2
5
+ MINOR = 3
6
6
  PATCH = 1
7
- SUFFIX = 'alpha'
7
+ SUFFIX = ''
8
8
 
9
9
  NUMBER = [MAJOR, MINOR, PATCH].compact.join('.')
10
- STRING = "#{NUMBER}-#{SUFFIX}"
10
+ STRING = "#{NUMBER}#{SUFFIX}"
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1.pre.alpha
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasiliy Yorkin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -172,6 +172,26 @@ dependencies:
172
172
  - - ">="
173
173
  - !ruby/object:Gem::Version
174
174
  version: 3.2.21
175
+ - !ruby/object:Gem::Dependency
176
+ name: colorize
177
+ requirement: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - "~>"
180
+ - !ruby/object:Gem::Version
181
+ version: '0.7'
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: 0.7.7
185
+ type: :runtime
186
+ prerelease: false
187
+ version_requirements: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - "~>"
190
+ - !ruby/object:Gem::Version
191
+ version: '0.7'
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 0.7.7
175
195
  description: Unified interface for ftp/sftp protocols, specific protocol is selected
176
196
  by uri scheme
177
197
  email:
@@ -188,6 +208,7 @@ files:
188
208
  - lib/xftp/client.rb
189
209
  - lib/xftp/dsl/block_evaluator.rb
190
210
  - lib/xftp/errors.rb
211
+ - lib/xftp/helpers/logging.rb
191
212
  - lib/xftp/locale/en.yml
192
213
  - lib/xftp/locale/ru.yml
193
214
  - lib/xftp/operations/ftp/glob.rb
@@ -210,14 +231,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
210
231
  version: '0'
211
232
  required_rubygems_version: !ruby/object:Gem::Requirement
212
233
  requirements:
213
- - - ">"
234
+ - - ">="
214
235
  - !ruby/object:Gem::Version
215
- version: 1.3.1
236
+ version: '0'
216
237
  requirements: []
217
238
  rubyforge_project:
218
239
  rubygems_version: 2.2.2
219
240
  signing_key:
220
241
  specification_version: 4
221
- summary: xftp-0.2.1-alpha
242
+ summary: xftp-0.3.1
222
243
  test_files: []
223
244
  has_rdoc: