Class: Registry::Gem

Inherits:
Download show all
Defined in:
lib/radiant/extension/script.rb

Instance Attribute Summary

Attributes inherited from Installer

#name, #path, #url

Instance Method Summary collapse

Methods inherited from Download

#filename, #initialize, #install

Methods inherited from Installer

#copy_to_vendor_extensions, #initialize, #install, #migrate, #update

Methods inherited from Action

#file_utils, #rake, #tasks_include?

Constructor Details

This class inherits a constructor from Registry::Download

Instance Method Details

#downloadObject



189
190
191
192
193
194
195
196
197
198
# File 'lib/radiant/extension/script.rb', line 189

def download
  # Don't download the gem if it's already installed
  extension = gem_name(filename)
  begin
    gem extension
  rescue ::Gem::LoadError
    super
    `gem install #{extension}`
  end
end

#gem_name(name) ⇒ Object



185
186
187
# File 'lib/radiant/extension/script.rb', line 185

def gem_name(name)
  name.gsub(/-\d+\.\d+\.\d+(.+)?\.gem/, '')
end

#unpackObject



200
201
202
203
204
205
206
# File 'lib/radiant/extension/script.rb', line 200

def unpack
  output = nil
  cd(Dir.tmpdir) do
    output = `gem unpack #{gem_name(filename)}`
  end
  self.path = output.match(/'(.*)'/)[1]
end