niftp 1.0.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -39,8 +39,16 @@ forced timeouts. FTP Secure (FTPS) is also supported.
39
39
  * **password**: The password, if required by the host (default: "").
40
40
  * **port**: The port for the host (default: 21).
41
41
  * **ftps**: Set to true if connecting to a FTP Secure server (default: false).
42
- * **retries**: The number of times to re-try the given FTP commands upon any
43
- exception, before raising the exception (Default: 1).
42
+ * **tries**: The number of times to try the given FTP commands upon any
43
+ exception, before raising the exception (Default: 2, meaning it will *retry
44
+ once* upon any exception).
45
+ * **sleep**: The number of seconds to sleep in between tries (default: 1).
46
+ * **on**: An array of errors to limit when the code block is retried
47
+ (default: StandardError). See the
48
+ [retryable](https://github.com/nfedyashev/retryable) gem for usage details
49
+ * **matching**: An exception message regex to limit when the code block is
50
+ retried (default: /.*/). See the
51
+ [retryable](https://github.com/nfedyashev/retryable) gem for usage details
44
52
  * **timeout**: The number of seconds to wait before timing out (default: 5).
45
53
  Use 0 to disable the timeout.
46
54
  * **passive**: Set to false to prevent a connection in passive mode (default:
@@ -48,10 +56,9 @@ forced timeouts. FTP Secure (FTPS) is also supported.
48
56
 
49
57
  ## Caveats
50
58
 
51
- Based on the way the [retryable]("https://github.com/nfedyashev/retryable")
52
- gem works, any FTP commands will be retried at least once upon any
53
- exception. Setting the :retries option to 0 will raise a runtime error. I'm
54
- fine with this for now as I prefer this behavior.
59
+ Setting the :tries option to 0 will raise a runtime error, otherwise the
60
+ codeblock would never execute.
61
+
55
62
 
56
63
  ## Testing
57
64
 
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ Rake::RDocTask.new do |rdoc|
17
17
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
18
18
 
19
19
  rdoc.rdoc_dir = 'rdoc'
20
- rdoc.title = "service_helpers #{version}"
20
+ rdoc.title = "NiFTP #{version}"
21
21
  rdoc.rdoc_files.include('README*')
22
22
  rdoc.rdoc_files.include('lib/**/*.rb')
23
23
  end
data/lib/niftp.rb CHANGED
@@ -14,10 +14,12 @@ module NiFTP
14
14
  # See the README for available options and examples.
15
15
  def ftp(host, options = {}, &block)
16
16
  options.reverse_merge!(:username => "", :password => "", :port => 21,
17
- :ftps => false, :retries => 1, :timeout => 5,
18
- :passive => true)
19
- raise "The :retries option must be > 0." if options[:retries] < 1
20
- retryable(:tries => options[:retries]) do
17
+ :ftps => false, :tries => 2, :sleep => 1,
18
+ :on => StandardError, :matching => /.*/,
19
+ :timeout => 5, :passive => true)
20
+ raise "The :tries option must be > 0." if options[:tries] < 1
21
+ retryable(:tries => options[:tries], :sleep => options[:sleep],
22
+ :on => options[:on], :matching => options[:matching]) do
21
23
  ftp = options[:ftps] ? Net::FTPFXPTLS.new : Net::FTP.new
22
24
  ftp.passive = options[:passive]
23
25
  begin
@@ -34,4 +36,4 @@ module NiFTP
34
36
  end
35
37
 
36
38
  # Alias for those that prefer a conventional module name.
37
- Niftp = NiFTP
39
+ Niftp = NiFTP
data/lib/niftp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module NiFTP
2
- VERSION = "1.0.3"
2
+ VERSION = "2.0.0"
3
3
  end
data/niftp.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
 
29
29
  # Dependencies
30
30
  s.add_dependency "ftpfxp", ">= 0.0.4"
31
- s.add_dependency "retryable", ">= 1.2"
31
+ s.add_dependency "retryable", ">= 1.3"
32
32
  s.add_dependency "activesupport", ">= 2.0"
33
33
  s.add_dependency "i18n", ">= 0.5"
34
34
  s.add_development_dependency "shoulda", ">= 2.11"
data/test/niftp_test.rb CHANGED
@@ -14,8 +14,8 @@ class NiFTPTest < Test::Unit::TestCase
14
14
  assert_equal Niftp, NiFTP
15
15
  end
16
16
 
17
- should "raise a runtime errors if the :retries option is less than 1" do
18
- assert_raise(RuntimeError) { @object.ftp(@host, { :retries => 0 }) }
17
+ should "raise a runtime errors if the :tries option is less than 1" do
18
+ assert_raise(RuntimeError) { @object.ftp(@host, { :tries => 0 }) }
19
19
  end
20
20
 
21
21
  should "connect to the FTP server with the default port" do
@@ -63,25 +63,25 @@ class NiFTPTest < Test::Unit::TestCase
63
63
  @object.ftp(@host)
64
64
  end
65
65
 
66
- should "retry once (by default) when an exception is raised" do
67
- Net::FTP.expects(:new).once.returns(@ftp)
68
- assert_raise(RuntimeError) do
69
- @object.ftp(@host) { |ftp_client| raise "testing retryable gem"}
70
- end
66
+ should "use the retryable defauls when they're not explicitly set" do
67
+ Net::FTP.stubs(:new => @ftp)
68
+ @object.expects(:retryable).with(:tries => 2, :sleep => 1,
69
+ :on => StandardError, :matching => /.*/)
70
+ @object.ftp(@host) { }
71
71
  end
72
72
 
73
- should "use the :retries option instead of the default" do
74
- Net::FTP.expects(:new).times(2).returns(@ftp)
73
+ should "use the :tries option instead of the default" do
74
+ Net::FTP.expects(:new).times(3).returns(@ftp)
75
75
  assert_raise(RuntimeError) do
76
- @object.ftp(@host, {:retries => 2 }) do |ftp_client|
76
+ @object.ftp(@host, {:tries => 3 }) do |ftp_client|
77
77
  raise "testing retryable gem"
78
78
  end
79
79
  end
80
80
  end
81
81
 
82
82
  should "close the FTP connection when there is an exception" do
83
- Net::FTP.expects(:new).once.returns(@ftp)
84
- @ftp.expects(:close).times(1)
83
+ Net::FTP.expects(:new).times(2).returns(@ftp)
84
+ @ftp.expects(:close).times(2)
85
85
  assert_raise(RuntimeError) do
86
86
  @object.ftp(@host) { |ftp_client| raise "testing close"}
87
87
  end
metadata CHANGED
@@ -1,116 +1,112 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: niftp
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
4
5
  prerelease:
5
- version: 1.0.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Christopher R. Murphy
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-21 00:00:00 -04:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2012-07-12 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: ftpfxp
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2157248480 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
24
21
  version: 0.0.4
25
22
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: retryable
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2157248480
25
+ - !ruby/object:Gem::Dependency
26
+ name: retryable
27
+ requirement: &2157247860 !ruby/object:Gem::Requirement
31
28
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: "1.2"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '1.3'
36
33
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: activesupport
40
34
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2157247860
36
+ - !ruby/object:Gem::Dependency
37
+ name: activesupport
38
+ requirement: &2157247280 !ruby/object:Gem::Requirement
42
39
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "2.0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '2.0'
47
44
  type: :runtime
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: i18n
51
45
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *2157247280
47
+ - !ruby/object:Gem::Dependency
48
+ name: i18n
49
+ requirement: &2157246680 !ruby/object:Gem::Requirement
53
50
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0.5"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0.5'
58
55
  type: :runtime
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: shoulda
62
56
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *2157246680
58
+ - !ruby/object:Gem::Dependency
59
+ name: shoulda
60
+ requirement: &2157246120 !ruby/object:Gem::Requirement
64
61
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: "2.11"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '2.11'
69
66
  type: :development
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: mocha
73
67
  prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *2157246120
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: &2157245600 !ruby/object:Gem::Requirement
75
72
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: "0.9"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0.9'
80
77
  type: :development
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: xml-simple
84
78
  prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *2157245600
80
+ - !ruby/object:Gem::Dependency
81
+ name: xml-simple
82
+ requirement: &2157245080 !ruby/object:Gem::Requirement
86
83
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: "1.0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '1.0'
91
88
  type: :development
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: rake
95
89
  prerelease: false
96
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *2157245080
91
+ - !ruby/object:Gem::Dependency
92
+ name: rake
93
+ requirement: &2157244500 !ruby/object:Gem::Requirement
97
94
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: "0.8"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0.8'
102
99
  type: :development
103
- version_requirements: *id008
100
+ prerelease: false
101
+ version_requirements: *2157244500
104
102
  description: NiFTP makes Ruby's decidedly un-nifty Net::FTP library easier to use.
105
- email:
103
+ email:
106
104
  - chmurph2+git@gmail.com
107
105
  executables: []
108
-
109
106
  extensions: []
110
-
111
- extra_rdoc_files:
107
+ extra_rdoc_files:
112
108
  - README.md
113
- files:
109
+ files:
114
110
  - .gitignore
115
111
  - Gemfile
116
112
  - MIT-LICENSE
@@ -121,34 +117,31 @@ files:
121
117
  - niftp.gemspec
122
118
  - test/niftp_test.rb
123
119
  - test/test_helper.rb
124
- has_rdoc: true
125
120
  homepage: https://github.com/chmurph2/NiFTP
126
121
  licenses: []
127
-
128
122
  post_install_message:
129
- rdoc_options:
123
+ rdoc_options:
130
124
  - --include=examples --main README.md
131
- require_paths:
125
+ require_paths:
132
126
  - lib
133
- required_ruby_version: !ruby/object:Gem::Requirement
127
+ required_ruby_version: !ruby/object:Gem::Requirement
134
128
  none: false
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: "0"
139
- required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
134
  none: false
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: "0"
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
145
139
  requirements: []
146
-
147
140
  rubyforge_project: niftp
148
- rubygems_version: 1.6.2
141
+ rubygems_version: 1.8.17
149
142
  signing_key:
150
143
  specification_version: 3
151
144
  summary: NiFTP makes Ruby's decidedly un-nifty Net::FTP library easier to use.
152
- test_files:
145
+ test_files:
153
146
  - test/niftp_test.rb
154
147
  - test/test_helper.rb