#!/usr/bin/env ruby require 'rubygems' require 'templater' require 'cucumber/nagios' module CucumberNagiosGenerators extend Templater::Manifold class ProjectGenerator < Templater::Generator def self.source_root File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'project') end def destination_root # takes :name from first_argument File.join(@destination_root, name) end @root = Pathname.new(File.dirname(__FILE__)).parent.join('lib/cucumber/nagios') desc "Generate a new self-contained cucumber-nagios project." first_argument :name, :required => true, :desc => "Project name" file '.gitignore', '.gitignore' file '.bzrignore', '.bzrignore' directory :steps, @root.join('steps'), 'features/steps' directory :features, @root.join('support'), 'features/support', :after => :readme glob! def readme(action) puts <<-README Your new cucumber-nagios project has been generated. To get going, you'll need to bundle gems into the project: $ bundle install It's *highly* recommended you version control your project $ git init ; git add . README end end desc "Generate a cucumber-nagios project." add :project, ProjectGenerator # feature generator class FeatureGenerator < Templater::Generator def self.source_root File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'project', 'lib', 'generators', 'feature') end desc <<-DESC Generate a cucumber feature. Takes a two arguments: cucumber-nagios-gen feature DESC first_argument :site, :required => true, :desc => "Site name" second_argument :feature, :required => true, :desc => "Feature name" template :feature do |template| template.source = "%feature_name%.feature" template.destination = "features/#{site}/#{feature}.feature" end template :step do |template| template.source = "%feature_name%_steps.rb" template.destination = "features/#{site}/steps/#{feature}_steps.rb" end end desc "Generators for a cucumber-nagios project" add :feature, FeatureGenerator end CucumberNagiosGenerators.run_cli Dir.pwd, 'cucumber-nagios-gen', Cucumber::Nagios::VERSION, ARGV