Module: FactoryList
- Defined in:
- lib/factory_list.rb,
lib/factory_list/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.3"
Class Method Summary collapse
Class Method Details
.list ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/factory_list.rb', line 8 def list dirs = ::FactoryBot.definition_file_paths.map(&:to_s) dirs.each do |dir| puts "dir: #{dir}" Dir.glob('**/*.rb', File::FNM_DOTMATCH, base: dir).each do |file| puts "file: #{file}" file_path = File.join(dir, file) File.open(file_path, 'r') do |f| tokens = ::Ripper.tokenize(f.read) tokens.each_with_index do |token, i| if token == 'factory' factory = tokens[i + 3] puts "\tfactory: #{factory}" elsif token == 'trait' trait = tokens[i + 3] puts "\t\ttrait: #{trait}" end end end end end end |