Class: Panoramix::Plugin::Wget
- Defined in:
- lib/panoramix/plugin/wget.rb
Instance Attribute Summary collapse
-
#dst ⇒ Object
readonly
Returns the value of attribute dst.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Instance Method Summary collapse
-
#clean ⇒ Object
Action clean fot this task.
-
#created? ⇒ Boolean
Has this instance already been created.
-
#initialize(dst, src, flags) ⇒ Wget
constructor
A new instance of Wget.
-
#needed?(timestamps) ⇒ Boolean
When this instance needs to be executed.
-
#run_default ⇒ Object
Default action for this task.
-
#timestamp ⇒ Object
Return current timestamp.
Methods inherited from Base
Constructor Details
#initialize(dst, src, flags) ⇒ Wget
Returns a new instance of Wget.
12 13 14 15 16 |
# File 'lib/panoramix/plugin/wget.rb', line 12 def initialize(dst, src, flags) @dst = dst @src = src @flags = flags end |
Instance Attribute Details
#dst ⇒ Object (readonly)
Returns the value of attribute dst.
8 9 10 |
# File 'lib/panoramix/plugin/wget.rb', line 8 def dst @dst end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
10 11 12 |
# File 'lib/panoramix/plugin/wget.rb', line 10 def flags @flags end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
9 10 11 |
# File 'lib/panoramix/plugin/wget.rb', line 9 def src @src end |
Instance Method Details
#clean ⇒ Object
Action clean fot this task
38 39 40 |
# File 'lib/panoramix/plugin/wget.rb', line 38 def clean shell "rm -f #{@dst}" end |
#created? ⇒ Boolean
Has this instance already been created
33 34 35 |
# File 'lib/panoramix/plugin/wget.rb', line 33 def created? File.exists?(@dst) end |
#needed?(timestamps) ⇒ Boolean
When this instance needs to be executed
27 28 29 30 |
# File 'lib/panoramix/plugin/wget.rb', line 27 def needed? return true if !created? File.mtime(@dst) < end |
#run_default ⇒ Object
Default action for this task
43 44 45 |
# File 'lib/panoramix/plugin/wget.rb', line 43 def run_default shell "wget -nv #{@flags} #{@src} -O #{@dst}" end |
#timestamp ⇒ Object
Return current timestamp
19 20 21 22 23 24 |
# File 'lib/panoramix/plugin/wget.rb', line 19 def 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 |