Class: AsProject::AbstractRemoteFileTask
Overview
Concrete instances returned from User objects
Instance Attribute Summary collapse
Instance Method Summary
collapse
#fetch, #is_dmg?, #is_exe?, #is_gzip?, #is_swc?, #is_targz?, #is_zip?, #unpack_dmg, #unpack_downloaded_file, #unpack_targz, #unpack_zip
Constructor Details
Returns a new instance of AbstractRemoteFileTask.
81
82
83
84
85
86
|
# File 'lib/tasks/remote_file_task.rb', line 81
def initialize(name, user)
@name = name
@user = user
yield self if block_given?
define
end
|
Instance Attribute Details
Returns the value of attribute extracted_file.
76
77
78
|
# File 'lib/tasks/remote_file_task.rb', line 76
def
@extracted_file
end
|
#mounted_path ⇒ Object
Returns the value of attribute mounted_path.
76
77
78
|
# File 'lib/tasks/remote_file_task.rb', line 76
def mounted_path
@mounted_path
end
|
#name ⇒ Object
Returns the value of attribute name.
76
77
78
|
# File 'lib/tasks/remote_file_task.rb', line 76
def name
@name
end
|
#url ⇒ Object
Returns the value of attribute url.
76
77
78
|
# File 'lib/tasks/remote_file_task.rb', line 76
def url
@url
end
|
Instance Method Details
#clean_path(path) ⇒ Object
153
154
155
156
157
158
|
# File 'lib/tasks/remote_file_task.rb', line 153
def clean_path(path)
if(path.index(' '))
return %{'#{path}'}
end
return path
end
|
#define ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/tasks/remote_file_task.rb', line 88
def define
@uri = URI.parse(url)
downloaded_file = downloaded_file_path
file downloaded_file do |f|
get_remote_file(@uri, downloaded_file)
if( == downloaded_file)
File.chmod(0755, )
end
end
if( != downloaded_file)
if(!Rake::Task.task_defined?())
file => downloaded_file do |f|
if(!File.exists?())
unpack_downloaded_file(downloaded_file, )
File.chmod(0755, )
end
end
end
end
task @name => []
end
|
#downloaded_file_path ⇒ Object
116
117
118
119
120
|
# File 'lib/tasks/remote_file_task.rb', line 116
def downloaded_file_path
parts = @uri.path.split('/')
file = parts.pop
return File.join(@user.downloads, @name.to_s, file)
end
|
#execute(params) ⇒ Object
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/tasks/remote_file_task.rb', line 160
def execute(params)
target = File.basename()
if(!Logger.debug)
puts("#{target} #{params}")
end
system("#{clean_path()} #{params}")
end
|
112
113
114
|
# File 'lib/tasks/remote_file_task.rb', line 112
def
return File.join(@user.downloads, @name.to_s, )
end
|
#get_remote_file(uri, target) ⇒ Object
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/tasks/remote_file_task.rb', line 135
def get_remote_file(uri, target)
if(!File.exists?(target))
puts "Fetching #{uri.to_s} into #{target} now!"
response = fetch(uri.to_s)
File.makedirs(File.dirname(target))
File.open(target, 'wb') do |f|
f.write(response.body)
end
puts ""
puts "Downloaded #{(response.body.size / 1024).to_s} KB"
puts "to: #{target}"
puts ""
end
end
|
#make_downloaded_dir(file) ⇒ Object
122
123
124
125
|
# File 'lib/tasks/remote_file_task.rb', line 122
def make_downloaded_dir(file)
dir = File.dirname(file)
File.makedirs(dir)
end
|
#remote_file_dir ⇒ Object
127
128
129
|
# File 'lib/tasks/remote_file_task.rb', line 127
def remote_file_dir
return File.join(@user.downloads, @name.to_s)
end
|
#remote_location ⇒ Object
131
132
133
|
# File 'lib/tasks/remote_file_task.rb', line 131
def remote_location
return File.join(remote_file_dir, )
end
|