fake_ftp 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,4 +2,6 @@
2
2
  pkg/*
3
3
  *.gem
4
4
  .bundle
5
- .DS_Store
5
+ .DS_Store
6
+ .rbenv-version
7
+ .rbenv-gemsets
data/Gemfile.lock CHANGED
@@ -1,21 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fake_ftp (0.0.6)
4
+ fake_ftp (0.0.8)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.1.2)
10
- rake (0.8.7)
11
- rspec (2.5.0)
12
- rspec-core (~> 2.5.0)
13
- rspec-expectations (~> 2.5.0)
14
- rspec-mocks (~> 2.5.0)
15
- rspec-core (2.5.1)
16
- rspec-expectations (2.5.0)
9
+ diff-lcs (1.1.3)
10
+ rake (0.9.2.2)
11
+ rspec (2.7.0)
12
+ rspec-core (~> 2.7.0)
13
+ rspec-expectations (~> 2.7.0)
14
+ rspec-mocks (~> 2.7.0)
15
+ rspec-core (2.7.1)
16
+ rspec-expectations (2.7.0)
17
17
  diff-lcs (~> 1.1.2)
18
- rspec-mocks (2.5.0)
18
+ rspec-mocks (2.7.0)
19
19
 
20
20
  PLATFORMS
21
21
  ruby
@@ -1,5 +1,6 @@
1
1
  require 'socket'
2
2
  require 'thread'
3
+ require 'timeout'
3
4
 
4
5
  module FakeFtp
5
6
  class Server
@@ -71,8 +72,7 @@ module FakeFtp
71
72
  end
72
73
 
73
74
  def is_running?(tcp_port = nil)
74
- service = `lsof -w -n -i tcp:#{tcp_port || port}`
75
- !service.nil? && service != ''
75
+ tcp_port.nil? ? port_is_open?(port) : port_is_open?(tcp_port)
76
76
  end
77
77
 
78
78
  private
@@ -225,5 +225,24 @@ module FakeFtp
225
225
  def active?
226
226
  @mode == :active
227
227
  end
228
+
229
+ private
230
+
231
+ def port_is_open?(port)
232
+ begin
233
+ Timeout::timeout(1) do
234
+ begin
235
+ s = TCPSocket.new("127.0.0.1", port)
236
+ s.close
237
+ return true
238
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
239
+ return false
240
+ end
241
+ end
242
+ rescue Timeout::Error
243
+ end
244
+
245
+ return false
246
+ end
228
247
  end
229
248
  end
@@ -1,3 +1,3 @@
1
1
  module FakeFtp
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,80 +1,57 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fake_ftp
3
- version: !ruby/object:Gem::Version
4
- hash: 17
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 7
10
- version: 0.0.7
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Colin Shield
14
9
  - Eric Saxby
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2011-10-07 00:00:00 -07:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
13
+ date: 2011-11-21 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
23
16
  name: bundler
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &70219908764000 !ruby/object:Gem::Requirement
26
18
  none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 1
33
- - 0
34
- - 10
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
35
22
  version: 1.0.10
36
23
  type: :development
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: rspec
40
24
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *70219908764000
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: &70219908763540 !ruby/object:Gem::Requirement
42
29
  none: false
43
- requirements:
44
- - - ">"
45
- - !ruby/object:Gem::Version
46
- hash: 7
47
- segments:
48
- - 2
49
- version: "2"
30
+ requirements:
31
+ - - ! '>'
32
+ - !ruby/object:Gem::Version
33
+ version: '2'
50
34
  type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: rake
54
35
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *70219908763540
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake
39
+ requirement: &70219908763080 !ruby/object:Gem::Requirement
56
40
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 49
61
- segments:
62
- - 0
63
- - 8
64
- - 7
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
65
44
  version: 0.8.7
66
45
  type: :development
67
- version_requirements: *id003
46
+ prerelease: false
47
+ version_requirements: *70219908763080
68
48
  description: Testing FTP? Use this!
69
- email:
49
+ email:
70
50
  - sax+github@livinginthepast.org
71
51
  executables: []
72
-
73
52
  extensions: []
74
-
75
53
  extra_rdoc_files: []
76
-
77
- files:
54
+ files:
78
55
  - .gitignore
79
56
  - .rvmrc
80
57
  - Gemfile
@@ -91,43 +68,31 @@ files:
91
68
  - spec/models/fake_ftp/file_spec.rb
92
69
  - spec/models/fake_ftp/server_spec.rb
93
70
  - spec/spec_helper.rb
94
- has_rdoc: true
95
71
  homepage: http://rubygems.org/gems/fake_ftp
96
72
  licenses: []
97
-
98
73
  post_install_message:
99
74
  rdoc_options: []
100
-
101
- require_paths:
75
+ require_paths:
102
76
  - lib
103
- required_ruby_version: !ruby/object:Gem::Requirement
77
+ required_ruby_version: !ruby/object:Gem::Requirement
104
78
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
112
- required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
84
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: 23
118
- segments:
119
- - 1
120
- - 3
121
- - 6
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
122
88
  version: 1.3.6
123
89
  requirements: []
124
-
125
90
  rubyforge_project: fake_ftp
126
- rubygems_version: 1.5.3
91
+ rubygems_version: 1.8.11
127
92
  signing_key:
128
93
  specification_version: 3
129
94
  summary: Creates a fake FTP server for use in testing
130
- test_files:
95
+ test_files:
131
96
  - spec/fixtures/invisible_bike.jpg
132
97
  - spec/fixtures/text_file.txt
133
98
  - spec/models/fake_ftp/file_spec.rb