Module: DemoInstaller

Defined in:
lib/ontomde-core/demoInstaller.rb

Instance Method Summary collapse

Instance Method Details

#installDefaultDemo(scriptFullPath) ⇒ Object

install demonstration

infers demo location and demo name from scriptName and and call proceed. scriptFullPath is expected to have the following structure: <path>/<demoName>/bin/<thisscript> and demo is expected to be in <path>/<demoName>/demo



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ontomde-core/demoInstaller.rb', line 43

def installDefaultDemo(scriptFullPath)
	scriptFullPath=File.expand_path(scriptFullPath)
	dn=File.dirname(scriptFullPath)
	bn=File.basename(scriptFullPath)
	
	target=File.basename(File.dirname(dn))
	source="#{dn}/../demo"
	banner=%{#{bn} installs a demo project in target directory.}

	#puts "target=>#{target}<"
	#puts "source=>#{source}<"
	#puts "banner=>#{banner}<"

	proceed(target,source,banner)
end

#proceed(target, source, banner) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ontomde-core/demoInstaller.rb', line 6

def proceed(target,source,banner)
  options = { }
  options[:target]="#{target}"
  OptionParser.new do |opts|
    opts.banner =banner +<<END

Command syntax:
----------
END
    opts.on("-t","--target DIRECTORY","","target directory where demo project will be installed","default: --target #{options[:target]}" ) do |v|
      options[:target] = v
    end


    # No argument, shows at tail.  This will print an options summary.
    # Try it and see!
    opts.on_tail("-h", "--help", "Show this message") do
      puts opts
      exit
    end
  end.parse!

  if File.exist?(options[:target])
    puts "WARNING: File already exists (#{options[:target]})"
    puts "WARNING: Copy aborted"
  else
    cp_r("#{source}", options[:target] )
    puts "INFO: Project created in #{options[:target]}"
  end
end