forked from auxesis/cucumber-nagios
/
cucumber-nagios-gen
executable file
·52 lines (40 loc) · 1.44 KB
/
cucumber-nagios-gen
1
2
3
4
5
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env ruby
# attempt to load up the bundled gems, and give an explanatory message if we can't
begin
require File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'environment')
rescue LoadError
puts "You need to bundle gems into your project before you can run this."
puts
puts "To do this, make sure the 'bundler' gem is installed, and run:"
puts
puts " $ gem bundle"
puts
exit 1
end
require 'templater'
module CucumberNagiosGenerators
extend Templater::Manifold
# feature generator
class FeatureGenerator < Templater::Generator
def self.source_root
File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'feature')
end
desc <<-DESC
Generate a cucumber feature. Takes a two arguments:
bin/cucumber-nagios-gen feature <site-name> <feature-name>
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', '0.6.3', ARGV