Module: Steep::Drivers::Utils::EachSignature
- Included in:
- Annotations, Check, PrintInterface, Scaffold, Validate
- Defined in:
- lib/steep/drivers/utils/each_signature.rb
Instance Method Summary collapse
- #each_file_in_dir(suffix, path, &block) ⇒ Object
- #each_ruby_file(source_paths) ⇒ Object
- #each_ruby_source(source_paths, verbose) ⇒ Object
- #each_signature(signature_dirs, verbose) ⇒ Object
Instance Method Details
#each_file_in_dir(suffix, path, &block) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/steep/drivers/utils/each_signature.rb', line 52 def each_file_in_dir(suffix, path, &block) path.children.each do |child| if child.directory? each_file_in_dir(suffix, child, &block) end if child.file? && suffix == child.extname yield child end end end |
#each_ruby_file(source_paths) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/steep/drivers/utils/each_signature.rb', line 38 def each_ruby_file(source_paths) source_paths.each do |path| if path.file? yield path end if path.directory? each_file_in_dir(".rb", path) do |file| yield file end end end end |
#each_ruby_source(source_paths, verbose) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/steep/drivers/utils/each_signature.rb', line 25 def each_ruby_source(source_paths, verbose) each_ruby_file source_paths do |file| begin stdout.puts "Loading Ruby program #{file}..." if verbose if (source = Source.parse(file.read, path: file.to_s, labeling: labeling)) yield source end rescue => exn Steep.logger.error "Error occured on parsing #{file}: #{exn.inspect}" end end end |
#each_signature(signature_dirs, verbose) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/steep/drivers/utils/each_signature.rb', line 5 def each_signature(signature_dirs, verbose) signature_dirs.each do |path| if path.file? stderr.puts "Loading signature #{path}..." if verbose Parser.parse_signature(path.read, name: path).each do |signature| yield signature end end if path.directory? each_file_in_dir(".rbi", path) do |file| stderr.puts "Loading signature #{file}..." if verbose Parser.parse_signature(file.read, name: file).each do |signature| yield signature end end end end end |