Skip to content

Rename Zip module to RubyZip #132

@weshatheleopard

Description

@weshatheleopard

Gems that include rubyzip conflict with gems that include zip since both call their main module Zip. A way to separate the two is absolutely necessary if we want to avoid dirty hackery to the tune of:

unless ::Object.const_defined?(:RubyZip, false)
  if ::Object.const_defined?(:Zip, false) then
    if ::Zip.const_defined?(:File, false) then
       puts "DEBUG: RubyZip detected"
      ::RubyZip = ::Zip
    else
       puts "DEBUG: Conflicting Zip detected"
      zip_backup = ::Zip
      ::Zip = nil
      require 'rubygems'
      gem 'rubyzip', :require => 'zip'
      ::RubyZip = ::Zip
      ::Zip = zip_backup
    end
  else
     puts "DEBUG: Zip not detected at all"
    require 'rubygems'
    gem 'rubyzip', :require => 'zip'
    ::RubyZip = ::Zip
  end
end

Note that the main include file should also be renamed to rubyzip.rb, otherwise loading the right gem also turns into a Russian roulette game.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions