paperclip-storage-ftp 1.0.2 → 1.0.3
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.
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -60,19 +60,7 @@ module Paperclip
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def ftp_servers
|
63
|
-
@ftp_servers ||=
|
64
|
-
ftp_servers = []
|
65
|
-
@options[:ftp_servers].each do |config|
|
66
|
-
server = Server.new(
|
67
|
-
:host => config[:host],
|
68
|
-
:user => config[:user],
|
69
|
-
:password => config[:password],
|
70
|
-
:port => config[:port]
|
71
|
-
)
|
72
|
-
ftp_servers << server
|
73
|
-
end
|
74
|
-
ftp_servers
|
75
|
-
end
|
63
|
+
@ftp_servers ||= @options[:ftp_servers].map{|config| Server.new(config) }
|
76
64
|
end
|
77
65
|
|
78
66
|
def primary_ftp_server
|
@@ -12,7 +12,7 @@ module Paperclip
|
|
12
12
|
@@connections.clear
|
13
13
|
end
|
14
14
|
|
15
|
-
attr_accessor :host, :user, :password
|
15
|
+
attr_accessor :host, :user, :password, :passive
|
16
16
|
attr_writer :port
|
17
17
|
|
18
18
|
def initialize(options = {})
|
@@ -50,6 +50,7 @@ module Paperclip
|
|
50
50
|
|
51
51
|
def build_connection
|
52
52
|
connection = Net::FTP.new
|
53
|
+
connection.passive = passive
|
53
54
|
connection.connect(host, port)
|
54
55
|
connection
|
55
56
|
end
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
12
|
gem.name = "paperclip-storage-ftp"
|
13
13
|
gem.require_paths = ["lib"]
|
14
|
-
gem.version = "1.0.
|
14
|
+
gem.version = "1.0.3"
|
15
15
|
|
16
16
|
gem.add_dependency("paperclip")
|
17
17
|
|
@@ -13,17 +13,19 @@ describe Paperclip::Storage::Ftp::Server do
|
|
13
13
|
:host => "ftp.example.com",
|
14
14
|
:user => "user",
|
15
15
|
:password => "password",
|
16
|
-
:port => 2121
|
16
|
+
:port => 2121,
|
17
|
+
:passive => true
|
17
18
|
}
|
18
19
|
server = Paperclip::Storage::Ftp::Server.new(options)
|
19
20
|
server.host.should == options[:host]
|
20
21
|
server.user.should == options[:user]
|
21
22
|
server.password.should == options[:password]
|
22
23
|
server.port.should == options[:port]
|
24
|
+
server.passive.should == options[:passive]
|
23
25
|
end
|
24
26
|
|
25
27
|
it "sets a default port" do
|
26
|
-
server = Paperclip::Storage::Ftp::Server.new
|
28
|
+
server = Paperclip::Storage::Ftp::Server.new
|
27
29
|
server.port.should == Net::FTP::FTP_PORT
|
28
30
|
end
|
29
31
|
end
|
@@ -98,6 +100,7 @@ describe Paperclip::Storage::Ftp::Server do
|
|
98
100
|
it "returns an ftp connection for the given server" do
|
99
101
|
connection = double("connection")
|
100
102
|
Net::FTP.should_receive(:new).and_return(connection)
|
103
|
+
connection.should_receive(:passive=).with(server.passive)
|
101
104
|
connection.should_receive(:connect).with(server.host, server.port)
|
102
105
|
server.build_connection.should == connection
|
103
106
|
end
|
@@ -13,12 +13,14 @@ describe Paperclip::Storage::Ftp do
|
|
13
13
|
{
|
14
14
|
:host => "ftp1.example.com",
|
15
15
|
:user => "user1",
|
16
|
-
:password => "password1"
|
16
|
+
:password => "password1",
|
17
|
+
:port => 2121
|
17
18
|
},
|
18
19
|
{
|
19
20
|
:host => "ftp2.example.com",
|
20
21
|
:user => "user2",
|
21
|
-
:password => "password2"
|
22
|
+
:password => "password2",
|
23
|
+
:passive => true
|
22
24
|
}
|
23
25
|
]
|
24
26
|
})
|
@@ -126,9 +128,11 @@ describe Paperclip::Storage::Ftp do
|
|
126
128
|
attachment.ftp_servers.first.host.should == "ftp1.example.com"
|
127
129
|
attachment.ftp_servers.first.user.should == "user1"
|
128
130
|
attachment.ftp_servers.first.password.should == "password1"
|
131
|
+
attachment.ftp_servers.first.port.should == 2121
|
129
132
|
attachment.ftp_servers.second.host.should == "ftp2.example.com"
|
130
133
|
attachment.ftp_servers.second.user.should == "user2"
|
131
134
|
attachment.ftp_servers.second.password.should == "password2"
|
135
|
+
attachment.ftp_servers.second.passive.should == true
|
132
136
|
end
|
133
137
|
end
|
134
138
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-storage-ftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: paperclip
|
@@ -158,15 +158,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
158
|
- - ! '>='
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
|
+
segments:
|
162
|
+
- 0
|
163
|
+
hash: -1988300321926789163
|
161
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
165
|
none: false
|
163
166
|
requirements:
|
164
167
|
- - ! '>='
|
165
168
|
- !ruby/object:Gem::Version
|
166
169
|
version: '0'
|
170
|
+
segments:
|
171
|
+
- 0
|
172
|
+
hash: -1988300321926789163
|
167
173
|
requirements: []
|
168
174
|
rubyforge_project:
|
169
|
-
rubygems_version: 1.8.
|
175
|
+
rubygems_version: 1.8.25
|
170
176
|
signing_key:
|
171
177
|
specification_version: 3
|
172
178
|
summary: Allow Paperclip attachments to be stored on FTP servers
|