Sha256: 12c12f6963e81e541df018e660915ae41e3500e1f8c4106c25ed6d68a4d116b1

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

#!/usr/bin/env ruby
require 'optparse'
require 'fidius-cvedb/version'
require 'fileutils'

GEM_BASE = File.expand_path('../../lib', __FILE__)

options = {}

optparse = OptionParser.new do|opts|
  
  opts.banner = "Usage: fidius-cvedb-runner [options]"
  
  opts.on_tail("-f", "--fidius", "Initialize CVE-DB for Usage in FIDIUS C&C-Server") do
    if rails_root?
      rake_tasks
    end
    exit
  end
  
  opts.on_tail("-s", "--standalone", "Initialize CVE-DB standalone version") do
    if rails_root?
      rake_tasks
    end
    exit
  end
  
  opts.on_tail("-h", "--help", "Show this message") do
    puts "GEM_BASE=#{GEM_BASE}"
    puts opts
    exit
  end

  opts.on_tail("-v", "--version", "Show version") do
    puts "FIDIUS CVE-DB, Version #{FIDIUS::Cvedb::VERSION}"
    exit
  end
end

def rake_tasks
  if rails_3?
    puts "It seems like you are using Rails 3. Rake tasks are included via "+
         "Railties and don't need to be symlinked."
  else
    symlink_rake_tasks
  end
end

def symlink_rake_tasks
  Dir.glob(File.join GEM_BASE, 'tasks', '*.rake') do |rake|
    dest = File.join 'lib', 'tasks', File.basename(rake)
    FileUtils.ln_s(rake, dest)
  end
end

def rails_root?
  (File.exists?('config/environment.rb') && File.exists?('app/models'))
end

def rails_3?
  File.exists? 'Gemfile'
end

optparse.parse!

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fidius-cvedb-0.0.6 bin/fidius-cvedb
fidius-cvedb-0.0.5 bin/fidius-cvedb