Class: ZipUpdater
- Inherits:
-
Object
- Object
- ZipUpdater
- Defined in:
- lib/zip_dsl/zip_updater.rb
Instance Method Summary collapse
- #close ⇒ Object
- #content(params) ⇒ Object
- #directory(params) ⇒ Object
- #file(params) ⇒ Object
-
#initialize(from_root, to_root, name) ⇒ ZipUpdater
constructor
A new instance of ZipUpdater.
Constructor Details
#initialize(from_root, to_root, name) ⇒ ZipUpdater
Returns a new instance of ZipUpdater.
5 6 7 8 |
# File 'lib/zip_dsl/zip_updater.rb', line 5 def initialize from_root, to_root, name @from_root = from_root @zipfile = Zip::ZipFile.open("#{to_root}/#{name}") end |
Instance Method Details
#close ⇒ Object
10 11 12 |
# File 'lib/zip_dsl/zip_updater.rb', line 10 def close @zipfile.close end |
#content(params) ⇒ Object
20 21 22 23 24 |
# File 'lib/zip_dsl/zip_updater.rb', line 20 def content params to_dir = params[:to_dir].nil? ? File.dirname(params[:name]) : params[:to_dir] add_or_replace_file params[:name], to_dir, params[:source] end |
#directory(params) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/zip_dsl/zip_updater.rb', line 26 def directory params if params[:from_dir].nil? add_empty_directory params[:to_dir] else if params[:to_dir].nil? to_dir = params[:from_dir] else to_dir = params[:to_dir] end filter = params[:filter].nil? ? "**/*" : params[:filter] add_directory params[:from_dir], to_dir, filter end #Dir["spec/stubs/**/*.*"].each do |name| # if File.file? name # add_or_replace(zipfile, "WEB-INF/spec/stubs/#{name['spec/stubs'.size+1..-1]}", name) # end #end end |
#file(params) ⇒ Object
14 15 16 17 18 |
# File 'lib/zip_dsl/zip_updater.rb', line 14 def file params to_dir = params[:to_dir].nil? ? File.dirname(params[:name]) : strip_dot(params[:to_dir]) add_or_replace_file full_name(params[:name]), "#{to_dir}/#{params[:name]}" end |