Class: Dragonfly::Job::FetchUrl

Inherits:
Step show all
Defined in:
lib/dragonfly/job.rb

Instance Attribute Summary

Attributes inherited from Step

#args, #job

Instance Method Summary collapse

Methods inherited from Step

abbreviation, basename, #initialize, #inspect, step_name

Constructor Details

This class inherits a constructor from Dragonfly::Job::Step

Instance Method Details

#applyObject


142
143
144
145
146
# File 'lib/dragonfly/job.rb', line 142

def apply
  open(url) do |f|
    job.update(f.read, :name => filename)
  end
end

#filenameObject


139
140
141
# File 'lib/dragonfly/job.rb', line 139

def filename
  @filename ||= File.basename(path) if path[/[^\/]$/]
end

#initObject


130
131
132
# File 'lib/dragonfly/job.rb', line 130

def init
  job.url_attrs[:name] = filename
end

#pathObject


136
137
138
# File 'lib/dragonfly/job.rb', line 136

def path
  @path ||= URI.parse(url).path
end

#urlObject


133
134
135
# File 'lib/dragonfly/job.rb', line 133

def url
  @url ||= (args.first[%r<^\w+://>] ? args.first : "http://#{args.first}")
end