Class: ZipUpdater
- Inherits:
-
Object
- Object
- ZipUpdater
- Defined in:
- lib/zip_dsl/zip_updater.rb
Instance Attribute Summary collapse
-
#from_dir ⇒ Object
readonly
Returns the value of attribute from_dir.
Instance Method Summary collapse
- #close ⇒ Object
- #content(params) ⇒ Object
- #directory(params) ⇒ Object
- #file(params) ⇒ Object
-
#initialize(name, from_dir) ⇒ ZipUpdater
constructor
A new instance of ZipUpdater.
Constructor Details
#initialize(name, from_dir) ⇒ ZipUpdater
Returns a new instance of ZipUpdater.
6 7 8 9 |
# File 'lib/zip_dsl/zip_updater.rb', line 6 def initialize name, from_dir @from_dir = from_dir @zipfile = Zip::ZipFile.open(name) end |
Instance Attribute Details
#from_dir ⇒ Object (readonly)
Returns the value of attribute from_dir.
4 5 6 |
# File 'lib/zip_dsl/zip_updater.rb', line 4 def from_dir @from_dir end |
Instance Method Details
#close ⇒ Object
11 12 13 |
# File 'lib/zip_dsl/zip_updater.rb', line 11 def close @zipfile.close end |
#content(params) ⇒ Object
21 22 23 24 25 |
# File 'lib/zip_dsl/zip_updater.rb', line 21 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
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/zip_dsl/zip_updater.rb', line 27 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
15 16 17 18 19 |
# File 'lib/zip_dsl/zip_updater.rb', line 15 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 |