bin/howitzer in howitzer-1.1.1 vs bin/howitzer in howitzer-2.0.0
- old
+ new
@@ -1,89 +1,114 @@
#!/usr/bin/env ruby
require 'gli'
require_relative '../lib/howitzer/version'
+# Howitzer Command line interface
module HowitzerCli
-
extend GLI::App
synopsis_format :compact
program_desc 'Ruby based framework for acceptance testing'
version Howitzer::VERSION
desc 'Generate new project'
arg_name '<PROJECT NAME>'
command :new do |c|
c.desc 'Integrate Cucumber'
- c.switch [:c, :cucumber] , negatable: false
+ c.switch [:c, :cucumber], negatable: false
c.desc 'Integrate Rspec'
c.switch [:r, :rspec], negatable: false
- c.action do |global_options, options, args|
- if args.size > 0
+ c.desc 'Integrate Turnip'
+ c.switch [:t, :turnip], negatable: false
+
+ c.action do |_global_options, options, args|
+ if !args.empty?
validate_options(options)
load_generators
path_to_dir = File.join(Dir.pwd, args.first)
- puts " * New project directory creation ..."
+ puts ' * New project directory creation ...'
Dir.mkdir(path_to_dir)
puts " Created new './#{args.first}' folder"
Dir.chdir(path_to_dir)
- Howitzer::ConfigGenerator.new
- Howitzer::PagesGenerator.new
- Howitzer::TasksGenerator.new
- Howitzer::EmailsGenerator.new
- Howitzer::RootGenerator.new
- Howitzer::CucumberGenerator.new if options['cucumber']
- Howitzer::RspecGenerator.new if options['rspec']
- puts "[WARN] Extra parameters were skipped" if args.size > 1
+ Howitzer::ConfigGenerator.new(options)
+ Howitzer::WebGenerator.new(options)
+ Howitzer::TasksGenerator.new(options)
+ Howitzer::EmailsGenerator.new(options)
+ Howitzer::RootGenerator.new(options)
+ Howitzer::PrerequisitesGenerator.new(options)
+ if options[:cucumber]
+ Howitzer::CucumberGenerator.new(options)
+ elsif options[:rspec]
+ Howitzer::RspecGenerator.new(options)
+ elsif options['turnip']
+ Howitzer::TurnipGenerator.new(options)
+ end
+ puts '[WARN] Extra parameters were skipped' if args.size > 1
elsif args.size.zero?
- exit_now!("Please specify <PROJECT NAME>", 64)
+ exit_now!('Please specify <PROJECT NAME>', 64)
end
end
end
desc 'Upgrade existing project'
command :update do |c|
c.action do
- check_project_presence
- load_generators
- Howitzer::ConfigGenerator.new
- Howitzer::RootGenerator.new
- Howitzer::CucumberGenerator.new if cucumber_integrated?
- Howitzer::RspecGenerator.new if rspec_integrated?
+ check_project_presence
+ load_generators
+ Howitzer::ConfigGenerator.new
+ Howitzer::WebGenerator.new
+ Howitzer::TasksGenerator.new
+ Howitzer::EmailsGenerator.new
+ Howitzer::PrerequisitesGenerator.new
+ if cucumber_integrated?
+ Howitzer::RootGenerator.new(cucumber: true)
+ Howitzer::CucumberGenerator.new
+ elsif rspec_integrated?
+ Howitzer::RootGenerator.new(rspec: true)
+ Howitzer::RspecGenerator.new
+ elsif turnip_integrated?
+ Howitzer::RootGenerator.new(turnip: true)
+ Howitzer::TurnipGenerator.new
+ end
end
end
- #helpers
+ # helpers
class << self
private
+
def validate_options(options)
- if !options['cucumber'] && !options['rspec']
- exit_now!("Provide --cucumber and/or --rspec option", 64)
- end
+ return if [options[:cucumber], options[:rspec], options[:turnip]].count { |el| el } == 1
+
+ exit_now!('Provide --cucumber, --rspec or --turnip option', 64)
end
def check_project_presence
exit_now!('Current directory is not Howitzer project', 126) unless howitzer_project?
end
def howitzer_project?
- Dir.exists?('pages') && Dir.exists?('config') && File.exists?('boot.rb')
+ (Dir.exist?('web') || Dir.exist?('pages')) && Dir.exist?('config')
end
def load_generators
- Dir[File.join(File.dirname(__FILE__), '..', 'generators', '**', '*_generator.rb')].each{ |f| require File.expand_path(f) }
+ Dir[
+ File.join(__dir__, '..', 'generators', '**', '*_generator.rb')
+ ].each { |f| require File.expand_path(f) }
end
def cucumber_integrated?
- Dir.exists?('features')
+ Dir.exist?('features')
end
def rspec_integrated?
- Dir.exists?('spec')
+ File.exist?('spec/spec_helper.rb') && !File.exist?('spec/turnip_helper.rb')
end
+
+ def turnip_integrated?
+ File.exist?('spec/spec_helper.rb') && File.exist?('spec/turnip_helper.rb')
+ end
end
end
-unless ENV['TEST_MODE']
- exit(HowitzerCli.run(ARGV))
-end
+exit(HowitzerCli.run(ARGV)) unless ENV['TEST_MODE']