class Panoramix::Plugin::Wget
Attributes
dst[R]
flags[R]
src[R]
Public Class Methods
new(dst, src, flags)
click to toggle source
# File lib/panoramix/plugin/wget.rb, line 12 def initialize(dst, src, flags) @dst = dst @src = src @flags = flags end
Public Instance Methods
clean()
click to toggle source
Action clean fot this task
# File lib/panoramix/plugin/wget.rb, line 38 def clean shell "rm -f #{@dst}" end
created?()
click to toggle source
Has this instance already been created
# File lib/panoramix/plugin/wget.rb, line 33 def created? File.exists?(@dst) end
needed?(timestamps)
click to toggle source
When this instance needs to be executed
# File lib/panoramix/plugin/wget.rb, line 27 def needed? timestamps return true if !created? File.mtime(@dst) < timestamp end
run_default()
click to toggle source
Default action for this task
# File lib/panoramix/plugin/wget.rb, line 43 def run_default shell "wget -nv #{@flags} #{@src} -O #{@dst}" end
timestamp()
click to toggle source
Return current timestamp
# File lib/panoramix/plugin/wget.rb, line 19 def timestamp return Time.at 0 unless created? remote_time = shell("wget #{@flags} --spider -S #{@src} 2>&1 | grep Last-Modified", true)[:out] remote_time = remote_time.split("Last-Modified: ").last remote_time = Time.parse(remote_time) end