Class: SolrCloud::Connection::ConfigsetAdmin::ZipFileGenerator

Inherits:
Object
  • Object
show all
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

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

#writeObject

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