carrierwave-scp 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTljODUxMTJjNjFhOGIzYTg2NTcyYmMwMjM0YmEzOTAwYzU4ZTRkYg==
4
+ NTNhNzM1YTYyZDBlOTE5MDNiNTE0MzZlMTBlZDhhZjY3NWRkN2M4Yg==
5
5
  data.tar.gz: !binary |-
6
- OTQ5NmYyMGM5YTlkNzUzNTY4NTM0ZjQwMGNhYmU4ZGM2YTU2OGExZA==
6
+ Y2EwNDVlZDg2NGFjZWYyZjk5MWIxZDFhYWU4N2Y4ZWVhNmFkNGU5YQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTQzM2RlZmE1ODQxYjNmZDQ0MDAyZWMwZjc0ODYzYjY3ZGU4YmUyYmI0MDg4
10
- NDc3ZTNiMGFiMDNmZDY0Y2M1YjU4MjZiNjQxZTM2MjU0NDY4NmExNjVkNDIx
11
- NjdmYzliYjdhMDQ4NGZhMDMyZTZlZmQzZGYxODM1NzVhMjZiNDI=
9
+ MmE0MjZkZTIwZWQ2Y2I4YzdjOWNiNDQ1NzU4MGQyODM5MDBjYzQwYzczNGQ0
10
+ NzM2ZmI5YmQwYzYyMGEwNDRlOGY4N2MyMTRjYTljYzJiZDFhZTNhNDRjOGQx
11
+ YjgwYjczZTU2NjRjMDMwMzUyMjhjYjE3MWQ4MTE3NmNkMGJhNTA=
12
12
  data.tar.gz: !binary |-
13
- ZjI2ZDMwYTc1NDY5ZDNkNmEzOWM3YTY5Y2FlYTYzZmZlYmNkMTg5NDJmYmI2
14
- NTEzMzdmZjJkYzEzNDA0OWI3MDgwMTNkZGExYThjZGNlYzU4NWEwZmE5ODQ3
15
- NGI0YWVmOTRkYzMzZDQ1YzZhYzY0Y2U5N2I2OTRmZmM2ODIyMDI=
13
+ ZTBlZWZhN2QzNmIxNjZlYjk0MzAzYWU4Yjk2MjhhYzc4YzRhMGU3NjBkZDc4
14
+ YmM3MjhjNjc0YWJhZjRjODNjMzAwNjAzYTM2MWJkZDQzN2I5MGE1YmFjYWFi
15
+ MjM4NTZmODZlMDY4M2Y2Nzg1MTIyMzNlMWU2YmI2NjEzMDYyZjU=
@@ -7,7 +7,7 @@ require 'carrierwave-scp/version'
7
7
  class CarrierWave::Uploader::Base
8
8
  add_config :scp_host
9
9
  add_config :scp_user
10
- add_config :scp_passwd
10
+ add_config :scp_options
11
11
  add_config :scp_folder
12
12
 
13
13
  configure do |config|
@@ -1,3 +1,3 @@
1
1
  module CarrierwaveScp
2
- VERSION = "0.0.0"
2
+ VERSION = "0.0.1"
3
3
  end
@@ -24,7 +24,7 @@ module CarrierWave
24
24
  end
25
25
 
26
26
  def read
27
- file.read
27
+ file
28
28
  end
29
29
 
30
30
  def size
@@ -32,15 +32,24 @@ module CarrierWave
32
32
  end
33
33
 
34
34
  def store(new_file)
35
- Net::SCP.upload!(@uploader.scp_host, @uploader.scp_user,
36
- StringIO.new(new_file.read), "#{@uploader.scp_folder}/#{path}",
37
- :password => @uploader.scp_passwd, :recursive => true)
35
+ Net::SSH.start(@uploader.scp_host, @uploader.scp_user, @uploader.scp_options) do |session|
36
+ new_dir = path.split('/')
37
+ new_dir.delete(new_dir[-1])
38
+ new_dir = new_dir.join('/')
39
+ session.exec! "mkdir #{@uploader.scp_folder}/#{new_dir}"
40
+ session.scp.upload! new_file.path, "#{@uploader.scp_folder}/#{path}", :recursive => true
41
+ end
38
42
  end
39
43
 
40
44
  private
41
45
 
42
46
  def file
43
- @file ||= open("scp://#{@uploader.scp_user}:#{@uploader.scp_passwd}@#{@uploader.scp_host}#{@uploader.scp_folder}/#{path}")
47
+ remote_file = nil
48
+ Net::SSH.start(@uploader.scp_host, @uploader.scp_user, @uploader.scp_options) do |session|
49
+ remote_file = session.scp.download!("#{@uploader.scp_folder}/#{path}", nil)
50
+ end
51
+ remote_file
52
+ #@file ||= open("scp://#{@uploader.scp_user}:#{@uploader.scp_options[:password]}@#{@uploader.scp_host}#{@uploader.scp_folder}/#{path}", options)
44
53
  end
45
54
 
46
55
  end #end File
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-scp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Batista da Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-25 00:00:00.000000000 Z
11
+ date: 2013-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave