Class: Bake::Doc

Inherits:
Object
  • Object
show all
Defined in:
lib/bake/options/showDoc.rb

Class Method Summary collapse

Class Method Details

.installObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/bake/options/showDoc.rb', line 28

def self.install

  docuSource = "https://raw.githubusercontent.com/esrlabs/bake/#{Bake::Version.number}/install-docs/"
  docuTarget = File.dirname(__FILE__)+"/../../../doc/"
  begin
    f = open(docuSource+"files.txt", {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE})
  rescue OpenURI::HTTPError => e
    puts "Could not open #{docuSource}files.txt"
    ExitHelper.exit(0)
  end
  f.each_line do |fileName|
    fileName = fileName[2..-1].strip
    begin
      sourceFile = open(docuSource+fileName, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE})
    puts "[OK]     "+ docuSource+fileName
    rescue OpenURI::HTTPError => e
      puts "[FAILED] "+ docuSource+fileName
    next
    end
    FileUtils.mkdir_p(File.dirname(docuTarget+fileName))
    File.open(docuTarget+fileName, "wb") do |file|
    file.puts sourceFile.read
    end
  end
  ExitHelper.exit(0)
end

.showObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bake/options/showDoc.rb', line 8

def self.show
  if File.exist?(File.dirname(__FILE__)+"/../../../doc/index.html")
    link = File.expand_path(File.dirname(__FILE__)+"/../../../doc/index.html")
  else
    link = "http://esrlabs.github.io/bake"
  end

  if RUBY_PLATFORM =~ /mswin|mingw|cygwin/
    system "start #{link}"
  elsif RUBY_PLATFORM =~ /darwin/
    system "open #{link}"
  elsif RUBY_PLATFORM =~ /linux|bsd/
    system "xdg-open #{link}"
  else
    puts "Please open #{link} manually in your browser."
  end

  ExitHelper.exit(0)
end