Class: Slicecraft::Delivery
Instance Attribute Summary
Attributes inherited from Syncer
#path, #settings
Instance Method Summary
collapse
Methods inherited from Syncer
#build_path, #initialize, #project_name
Instance Method Details
#add_folder_to_zipfile(zipfile, folder) ⇒ Object
92
93
94
95
96
|
# File 'lib/slicecraft.rb', line 92
def add_folder_to_zipfile(zipfile, folder)
Dir["#{path}/#{folder}/**/**"].each do |file|
zipfile.add(file.sub(path+'/',''),file)
end
end
|
#hashed_path ⇒ Object
110
111
112
|
# File 'lib/slicecraft.rb', line 110
def hashed_path
super + '/zip'
end
|
#process ⇒ Object
74
75
76
77
|
# File 'lib/slicecraft.rb', line 74
def process
zip
sync
end
|
#result_url ⇒ Object
106
107
108
|
# File 'lib/slicecraft.rb', line 106
def result_url
super + '/source.zip'
end
|
#sync ⇒ Object
114
115
116
117
118
|
# File 'lib/slicecraft.rb', line 114
def sync
system "rsync -ave ssh #{zip_path} #{settings['user']}@#{settings['url']}:#{"#{settings['preview_path']}#{hashed_path}"}"
FileUtils.rm_rf zip_path if File.exists? zip_path
FileUtils.rm_rf build_path if File.exists? build_path
end
|
#zip ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/slicecraft.rb', line 79
def zip
if File.exists?('zip/source.zip')
File.delete('zip/source.zip')
else
FileUtils.mkdir('zip') unless File.exists?('zip')
end
Zip::ZipFile.open(zip_file, Zip::ZipFile::CREATE) do |zipfile|
add_folder_to_zipfile(zipfile, 'source')
add_folder_to_zipfile(zipfile, 'build')
end
FileUtils.chmod(0644, zip_file)
end
|
#zip_file ⇒ Object
102
103
104
|
# File 'lib/slicecraft.rb', line 102
def zip_file
File.join(zip_path, 'source.zip')
end
|
#zip_path ⇒ Object
98
99
100
|
# File 'lib/slicecraft.rb', line 98
def zip_path
"#{@path}/zip/"
end
|