ftp_sync 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@ require 'fileutils'
9
9
  # newer than that timestamp, or only download files newer than their local copy.
10
10
  class FtpSync
11
11
 
12
- attr_accessor :verbose, :server, :user, :password
12
+ attr_accessor :verbose, :server, :user, :password, :passive
13
13
 
14
14
  # Creates a new instance for accessing a ftp server
15
15
  # requires +server+, +user+, and +password+ options
@@ -23,6 +23,7 @@ class FtpSync
23
23
  @ignore = options[:ignore]
24
24
  @recursion_level = 0
25
25
  @verbose = options[:verbose] || false
26
+ @passive = options[:passive] || false
26
27
  end
27
28
 
28
29
  # Recursively pull down files
@@ -167,6 +168,7 @@ class FtpSync
167
168
  private
168
169
  def connect!
169
170
  @connection = Net::FTP.new(@server)
171
+ @connection.passive = @passive
170
172
  @connection.login(@user, @password)
171
173
  log "Opened connection to #{@server}"
172
174
  end
@@ -191,4 +193,4 @@ class FtpSync
191
193
  def log(msg)
192
194
  puts msg if @verbose
193
195
  end
194
- end
196
+ end
@@ -36,6 +36,12 @@ class FtpSyncTest < Test::Unit::TestCase
36
36
  assert_equal 'user', @ftp.user
37
37
  assert_equal 'pass', @ftp.password
38
38
  end
39
+
40
+ def test_can_initialize_with_params_and_options
41
+ assert_equal false, @ftp.passive
42
+ @ftp = FtpSync.new('test.server', 'user', 'pass', :passive => true)
43
+ assert_equal true, @ftp.passive
44
+ end
39
45
 
40
46
  def test_can_set_verbose
41
47
  @ftp.verbose = true
@@ -43,6 +49,13 @@ class FtpSyncTest < Test::Unit::TestCase
43
49
  @ftp.verbose = false
44
50
  assert_equal false, @ftp.verbose
45
51
  end
52
+
53
+ def test_can_set_passive
54
+ @ftp.passive = true
55
+ assert_equal true, @ftp.passive
56
+ @ftp.passive = false
57
+ assert_equal false, @ftp.passive
58
+ end
46
59
 
47
60
  def test_setting_an_ignore_object
48
61
  ftp = FtpSync.new('localhost', 'user', 'pass', { :ignore => Ignore.new })
@@ -5,7 +5,7 @@ module Net
5
5
  @@listing_overrides = {}
6
6
 
7
7
  class << self
8
-
8
+
9
9
  def ftp_src
10
10
  @ftp_src ||= File.join(Dir.tmpdir, 'munkey_ftp_src')
11
11
  end
@@ -104,6 +104,14 @@ module Net
104
104
 
105
105
  def close; end
106
106
 
107
+ def passive
108
+ @passive ||= false
109
+ end
110
+
111
+ def passive=(val)
112
+ @passive = val
113
+ end
114
+
107
115
  private
108
116
  def src_path(p)
109
117
  File.join(self.class.ftp_src, p)
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftp_sync
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 4
9
- - 2
10
- version: 0.4.2
8
+ - 3
9
+ version: 0.4.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - jebw
@@ -15,18 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-11-30 00:00:00 +00:00
17
+ date: 2012-11-04 00:00:00 +00:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: net-ftp-list
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 9
30
27
  segments:
31
28
  - 2
32
29
  - 1
@@ -45,8 +42,6 @@ extra_rdoc_files:
45
42
  files:
46
43
  - lib/ftp_sync.rb
47
44
  - README.rdoc
48
- - test/ftp_sync_test.rb
49
- - test/net/ftp.rb
50
45
  has_rdoc: true
51
46
  homepage: http://github.com/jebw/ftp_sync
52
47
  licenses: []
@@ -61,27 +56,23 @@ rdoc_options:
61
56
  require_paths:
62
57
  - lib
63
58
  required_ruby_version: !ruby/object:Gem::Requirement
64
- none: false
65
59
  requirements:
66
60
  - - ">="
67
61
  - !ruby/object:Gem::Version
68
- hash: 3
69
62
  segments:
70
63
  - 0
71
64
  version: "0"
72
65
  required_rubygems_version: !ruby/object:Gem::Requirement
73
- none: false
74
66
  requirements:
75
67
  - - ">="
76
68
  - !ruby/object:Gem::Version
77
- hash: 3
78
69
  segments:
79
70
  - 0
80
71
  version: "0"
81
72
  requirements: []
82
73
 
83
74
  rubyforge_project:
84
- rubygems_version: 1.3.7
75
+ rubygems_version: 1.3.6
85
76
  signing_key:
86
77
  specification_version: 3
87
78
  summary: Library for syncing files and dirs with ftp servers