#!/usr/bin/env ruby USAGE = <<-END calagator: setup Calagator in a new or existing Rails applicaton Usage: calagator new APP_PATH [options] calagator install calagator new: generates a new Rails app and install Calagator into it Options: --dummy # Generates an app suitable for use in spec/dummy for Calagator # development and testing In the case of `calagator new`, all other options will be passed along to `rails new`; see `rails new --help` for supported options. To generate an app using a specific Rails version, e.g. for 4.2.1: calagator _4.2.1_ new my_great_calendar calagator install: install Calagator into an existing Rails application Options: none END TEMPLATE_PATH = File.expand_path("../../rails_template.rb", __FILE__) command = ARGV.shift case command when /_\d+\.\d+\.\d+_/, 'new' system "rails #{command} #{ARGV.join(' ')} -m #{TEMPLATE_PATH} --skip-bundle" when 'install' system "bundle exec rake rails:template LOCATION=#{TEMPLATE_PATH}" else puts USAGE end