Class: Razor::Rake::FTP::Push
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Razor::Rake::FTP::Push
- Defined in:
- lib/razor/rake/ftp_push.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#port ⇒ Object
Returns the value of attribute port.
-
#url_base ⇒ Object
Returns the value of attribute url_base.
Instance Method Summary collapse
- #define_task ⇒ Object
- #generate_options ⇒ Object
-
#initialize(hostname, name = 'ftp:push') {|_self| ... } ⇒ Push
constructor
A new instance of Push.
Constructor Details
#initialize(hostname, name = 'ftp:push') {|_self| ... } ⇒ Push
Returns a new instance of Push.
21 22 23 24 25 26 27 28 29 |
# File 'lib/razor/rake/ftp_push.rb', line 21 def initialize(hostname, name='ftp:push') @name = name @hostname = hostname @dir = '' @port = nil @url_base = '/' yield self if block_given? define_task end |
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
18 19 20 |
# File 'lib/razor/rake/ftp_push.rb', line 18 def dir @dir end |
#port ⇒ Object
Returns the value of attribute port.
17 18 19 |
# File 'lib/razor/rake/ftp_push.rb', line 17 def port @port end |
#url_base ⇒ Object
Returns the value of attribute url_base.
19 20 21 |
# File 'lib/razor/rake/ftp_push.rb', line 19 def url_base @url_base end |
Instance Method Details
#define_task ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/razor/rake/ftp_push.rb', line 31 def define_task task(@name) { hl = HighLine.new host = [@hostname] host << @port if @port ftp = Net::FTP.new(*host) begin username = hl.ask("FTP Username : ") psswd = hl.ask("Password : ", String) { |q| q.echo = false } ftp.login(username, psswd) ftp.chdir @dir ftp.rm_contents '.' Dir.mktmpdir { |tmp| Razor.generate(, '.', tmp) ftp.put_contents tmp } ensure ftp.close end } end |
#generate_options ⇒ Object
53 54 55 56 57 |
# File 'lib/razor/rake/ftp_push.rb', line 53 def { :url_base => @url_base } end |