Class: Gem::Uncompiler

Inherits:
Object
  • Object
show all
Includes:
UserInteraction
Defined in:
lib/rubygems-compile/uncompiler.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUncompiler

Returns a new instance of Uncompiler.



9
10
11
12
# File 'lib/rubygems-compile/uncompiler.rb', line 9

def initialize
  require 'fileutils'
  @config = Gem.configuration
end

Class Method Details

.uncompile(gem) ⇒ Object



4
5
6
7
# File 'lib/rubygems-compile/uncompiler.rb', line 4

def self.uncompile gem
  @instance ||= Gem::Uncompiler.new
  @instance.uncompile gem
end

Instance Method Details

#gem_filesObject



31
32
33
34
35
# File 'lib/rubygems-compile/uncompiler.rb', line 31

def gem_files
  Dir.glob(File.join(@spec.full_gem_path, '**','*.rbo')).map do |file|
    file.sub /#{@spec.full_gem_path}\//, ''
  end
end

#uncompilation_messageObject



26
27
28
29
# File 'lib/rubygems-compile/uncompiler.rb', line 26

def uncompilation_message
  slash = @config.really_verbose ? '/' : ''
  "Uncompiling #{@spec.full_name}#{slash}"
end

#uncompile(gem) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rubygems-compile/uncompiler.rb', line 14

def uncompile gem
  @spec = gem.is_a?(Gem::Specification) ? gem : gem.spec

  say uncompilation_message if @config.verbose

  gem_files.each do |file|
    absolute_file_path = File.join(@spec.full_gem_path, file)
    FileUtils.rm absolute_file_path
    say "\tAsploded #{file}" if @config.really_verbose
  end
end