Sha256: c242ff84adb7f8f6859a2deab1fa2d6e007aa6ec5792c4efd3c8269616da0fb2
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
# require the generators def require_generators *generator_list req = RSpec::Generator::Require generator_list.each do |name, generators| case name when Hash req.parse_generator_hash name when Symbol req.require_all_generators and return if name == :all if !generators || generators.empty? req.require_generator! name else req.parse_generator_list name, generators end else raise ArgumentError, "required generator(s) must be stated either using a symbol or array of symbols" end end end alias :require_generator :require_generators module RSpec::Generator module Require class << self attr_accessor :lib def debug? RSpec::Generator.debug? end def parse_generator_hash hash parse_generator_list hash.keys.first, hash.values.flatten end def parse_generator_list name, generators if generators.empty? require_generator! name else generators.each do |generator_name| require_generator! name, generator_name end end end def require_all_generators name=nil raise Error, "lib must be set to lib directory for RSpec::Generator::Require" if !lib base_path = File.join(lib, 'generators') path = name ? File.join(base_path, name) : base_path path = File.expand_path path puts "require_all: #{path}" require_all path end def require_generator! name, generator=nil require_all_generators(name) and return if generator == :all file = (require_file_name name, generator) puts "Loading generator: #{file}" if debug? require file end def require_file_name name, name_space=nil File.join('generators', name.to_s, "#{name_space}", "#{name_space || name}_generator") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
generator-spec-0.7.0 | lib/generator-spec/rspec/generator/require.rb |