Module: GDM::Editor

Defined in:
lib/gdm/repo.rb

Class Method Summary collapse

Class Method Details

.donwload(filename, url, ext = 'zip') ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/gdm/repo.rb', line 55

def donwload(filename, url, ext = 'zip')
  filename_ext = "#{filename}.#{ext}"
  puts "downloading #{filename_ext}"

  ::File.open(filename_ext, 'wb') do |file|
    file.write(Net::HTTP.get(URI(url)))
  end unless File.exists?(filename_ext)

  puts "#{filename_ext} downloaded"

  unzip(filename_ext, filename)
end

.installObject



78
79
80
81
# File 'lib/gdm/repo.rb', line 78

def install
  windows_install if ::GDM::Platform.windows?
  linux_install if ::GDM::Platform.linux?
end

.linux_installObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gdm/repo.rb', line 33

def linux_install
  t1 = Thread.new do
    filename = ::GDM::Platform.linux_editor_filename
    url = ::GDM::Repo::CURRENT[:linux]
    donwload(filename, url)
  end

  t2 = Thread.new do
    filename = ::GDM::Platform.linux_server_filename
    url = ::GDM::Repo::CURRENT[:server]
    donwload(filename, url)
  end

  t3 = Thread.new do
    filename = ::GDM::Platform.linux_headless_filename
    url = ::GDM::Repo::CURRENT[:headless]
    donwload(filename, url)
  end

  [t1, t2, t3].map(&:join)
end

.unzip(zipname, filename) ⇒ Object



68
69
70
71
72
73
74
75
76
# File 'lib/gdm/repo.rb', line 68

def unzip(zipname, filename)
  ::Zip::File.open(zipname).each do |file|
    file.extract(filename) unless File.exists?(filename)
  end

  File.chmod(0777, filename) if ::GDM::Platform.linux?

  puts("#{filename} unziped")
end

.windows_installObject



27
28
29
30
31
# File 'lib/gdm/repo.rb', line 27

def windows_install
  filename = ::GDM::Platform.windows_editor_filename
  url = ::GDM::Repo::CURRENT[:windows]
  donwload(filename, url)
end