Class: ArcadiaGemsWizard

Inherits:
Object
  • Object
show all
Defined in:
lib/a-core.rb

Instance Method Summary collapse

Constructor Details

#initialize(_arcadia) ⇒ ArcadiaGemsWizard

Returns a new instance of ArcadiaGemsWizard.



1844
1845
1846
1847
# File 'lib/a-core.rb', line 1844

def initialize(_arcadia)
  @arcadia = _arcadia
  Arcadia.attach_listener(self, NeedRubyGemWizardEvent)
end

Instance Method Details

#on_need_ruby_gem_wizard(_event) ⇒ Object



1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
# File 'lib/a-core.rb', line 1849

def on_need_ruby_gem_wizard(_event)
  # ... todo implamentation
  msg = "Appears that gem : '#{_event.gem_name}' required by : '#{_event.extension_name}' is not installed!\n Do you want to try install it now?" 
  ans = Tk.messageBox('icon' => 'error', 'type' => 'yesno',
    'title' => "(Arcadia) Extensions '#{_event.extension_name}'",
    'message' => msg)
    if  ans == 'yes'
      _event.add_result(self, 'installed'=>try_to_install_gem(_event.gem_name,_event.gem_repository))
    else
      _event.add_result(self, 'installed'=>false)
    end
end

#try_to_install_gem(name, repository = nil, version = '>0') ⇒ Object

def try_to_install_gem(name, repository=nil, version = ‘>0’)

  ret = false
  require 'rubygems/command.rb'
  require 'rubygems/dependency_installer.rb'

  inst.install name, version
  # TODO WIZARD
  # TODO accept repository, too
end


1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
# File 'lib/a-core.rb', line 1872

def try_to_install_gem(name, repository=nil, version = '>0')
  ret = false
  
  sh=ArcadiaSh.new
  cmd = "gem install --remote --include-dependencies #{name}"
  cmd="sudo #{cmd}" if !Arcadia.is_windows?
  cmd+=" --source=#{repository}" if repository
  sh.prepare_exec(cmd)    
  while sh.wait
    Tk.update
    #sleep(1)
  end
  ret=sh.result
  sh.destroy
  Gem.clear_paths
  ret
end