Class: Debian::Build::Uploader
- Inherits:
-
Object
- Object
- Debian::Build::Uploader
- Includes:
- FileUtils
- Defined in:
- lib/debian/build/uploader.rb
Constant Summary collapse
- @@default =
Uploader.new
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#incoming ⇒ Object
Returns the value of attribute incoming.
-
#login ⇒ Object
Returns the value of attribute login.
-
#nickname ⇒ Object
TODO nickname could be used to determinate incoming and host.
Class Method Summary collapse
Instance Method Summary collapse
- #dupload(*changes_files) ⇒ Object
-
#initialize ⇒ Uploader
constructor
A new instance of Uploader.
- #lock(&block) ⇒ Object
- #lock_file ⇒ Object
- #rsync(target_directory, *files) ⇒ Object
- #ssh_target ⇒ Object
Constructor Details
#initialize ⇒ Uploader
Returns a new instance of Uploader.
14 15 16 |
# File 'lib/debian/build/uploader.rb', line 14 def initialize self.incoming = '/var/lib/debarchiver/incoming' end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
10 11 12 |
# File 'lib/debian/build/uploader.rb', line 10 def host @host end |
#incoming ⇒ Object
Returns the value of attribute incoming.
10 11 12 |
# File 'lib/debian/build/uploader.rb', line 10 def incoming @incoming end |
#login ⇒ Object
Returns the value of attribute login.
12 13 14 |
# File 'lib/debian/build/uploader.rb', line 12 def login @login end |
#nickname ⇒ Object
TODO nickname could be used to determinate incoming and host
9 10 11 |
# File 'lib/debian/build/uploader.rb', line 9 def nickname @nickname end |
Class Method Details
.default ⇒ Object
47 |
# File 'lib/debian/build/uploader.rb', line 47 def self.default; @@default end |
Instance Method Details
#dupload(*changes_files) ⇒ Object
33 34 35 36 |
# File 'lib/debian/build/uploader.rb', line 33 def dupload(*changes_files) = ['-t', nickname] if nickname sh *["dupload", , changes_files].flatten.compact end |
#lock(&block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/debian/build/uploader.rb', line 18 def lock(&block) raise "No defined host, can't create lock file in ssh" unless host begin sh "ssh #{ssh_target} touch #{lock_file}" yield ensure sh "ssh #{ssh_target} rm -f #{lock_file}" end end |
#lock_file ⇒ Object
29 30 31 |
# File 'lib/debian/build/uploader.rb', line 29 def lock_file File.join(self.incoming, "debarchiver.lock") end |
#rsync(target_directory, *files) ⇒ Object
42 43 44 |
# File 'lib/debian/build/uploader.rb', line 42 def rsync(target_directory, *files) sh "rsync -av #{files.join(' ')} #{ssh_target}:#{incoming}/#{target_directory}" end |
#ssh_target ⇒ Object
38 39 40 |
# File 'lib/debian/build/uploader.rb', line 38 def ssh_target login ? "#{login}@#{host}" : host end |