olek-paperclipftp 0.1.0.1 → 0.1.0.2

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.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/paperclipftp.rb +20 -7
  3. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0.1
1
+ 0.1.0.2
data/lib/paperclipftp.rb CHANGED
@@ -4,7 +4,7 @@ module Paperclip
4
4
  def self.extended base
5
5
  require 'net/ftp'
6
6
  base.instance_eval do
7
- @ftp_credentials = parse_credentials
7
+ @ftp_credentials = parse_credentials(@options[:ftp_credentials])
8
8
  end
9
9
  end
10
10
 
@@ -84,12 +84,6 @@ module Paperclip
84
84
 
85
85
  private
86
86
 
87
- def parse_credentials
88
- creds = YAML.load_file(File.join(RAILS_ROOT,"config","paperclipftp.yml"))
89
- creds = creds.stringify_keys
90
- (creds[RAILS_ENV] || creds).symbolize_keys
91
- end
92
-
93
87
  def file_size(remote_path)
94
88
  ftp.size(remote_path)
95
89
  rescue Net::FTPPermError => e
@@ -100,6 +94,25 @@ module Paperclip
100
94
  raise e
101
95
  end
102
96
 
97
+ def parse_credentials creds
98
+ creds = find_credentials(creds).stringify_keys
99
+ (creds[Rails.env] || creds).symbolize_keys
100
+ end
101
+
102
+ def find_credentials creds
103
+ case creds
104
+ when File
105
+ YAML::load(ERB.new(File.read(creds.path)).result)
106
+ when String, Pathname
107
+ YAML::load(ERB.new(File.read(creds)).result)
108
+ when Hash
109
+ creds
110
+ else
111
+ raise ArgumentError, "Credentials are not a path, file, or hash."
112
+ end
113
+ end
114
+
115
+
103
116
  end
104
117
  end
105
118
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: olek-paperclipftp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 69
4
+ hash: 67
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
9
  - 0
10
- - 1
11
- version: 0.1.0.1
10
+ - 2
11
+ version: 0.1.0.2
12
12
  platform: ruby
13
13
  authors:
14
14
  - Damian Caruso
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-04-20 00:00:00 -04:00
19
+ date: 2011-04-21 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency