Sha256: a6e66bc1cd3bcefe7796ce5dc8eaeb3b5904325e3c0a4fd1f577fa1b1b36227c

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 KB

Contents

require 'rake'
require 'optparse'
require 'fileutils'

module DemoInstaller
  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
  
  # 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
  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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ontomde-core-2.0.0 lib/ontomde-core/demoInstaller.rb
ontomde-core-1.0.6 lib/ontomde-core/demoInstaller.rb
ontomde-core-2.0.4 lib/ontomde-core/demoInstaller.rb
ontomde-core-2.0.5 lib/ontomde-core/demoInstaller.rb