Class: SolrCloud::Connection::ConfigsetAdmin::ZipFileGenerator
- Inherits:
-
Object
- Object
- SolrCloud::Connection::ConfigsetAdmin::ZipFileGenerator
- Defined in:
- lib/solr_cloud/connection/configset_admin.rb
Overview
Pulled from the examples for rubyzip. No idea why it’s not just a part of the normal interface, but I guess I’m not one to judge.
Code taken wholesale from github.com/rubyzip/rubyzip/blob/master/samples/example_recursive.rb
Instance Method Summary collapse
-
#initialize(input_dir, output_file) ⇒ ZipFileGenerator
constructor
Initialize with the directory to zip and the location of the output archive.
-
#write ⇒ Object
Zip the input directory.
Constructor Details
#initialize(input_dir, output_file) ⇒ ZipFileGenerator
Initialize with the directory to zip and the location of the output archive.
89 90 91 92 |
# File 'lib/solr_cloud/connection/configset_admin.rb', line 89 def initialize(input_dir, output_file) @input_dir = input_dir @output_file = output_file end |
Instance Method Details
#write ⇒ Object
Zip the input directory.
95 96 97 98 99 100 |
# File 'lib/solr_cloud/connection/configset_admin.rb', line 95 def write entries = Dir.entries(@input_dir) - %w[. ..] ::Zip::File.open(@output_file, create: true) do |zipfile| write_entries entries, "", zipfile end end |