Sha256: d636d5967df1bd836de8f556930f6d1504f548e5f88671d55729b972d3d40778
Contents?: true
Size: 1.99 KB
Versions: 7
Compression:
Stored size: 1.99 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 generators from: #{path}" if debug? 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
7 entries across 7 versions & 1 rubygems