Sha256: 05b6e0930c74789a843ddabdc27918e096c3445b2b2c7f8ca4e37bd9a7defb3c

Contents?: true

Size: 1.86 KB

Versions: 13

Compression:

Stored size: 1.86 KB

Contents

module Steep
  module Drivers
    module Utils
      module EachSignature
        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

        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

        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

        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
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
steep-0.9.0 lib/steep/drivers/utils/each_signature.rb
steep-0.8.2 lib/steep/drivers/utils/each_signature.rb
steep-0.8.1 lib/steep/drivers/utils/each_signature.rb
steep-0.8.0 lib/steep/drivers/utils/each_signature.rb
steep-0.7.1 lib/steep/drivers/utils/each_signature.rb
steep-0.7.0 lib/steep/drivers/utils/each_signature.rb
steep-0.6.0 lib/steep/drivers/utils/each_signature.rb
steep-0.5.1 lib/steep/drivers/utils/each_signature.rb
steep-0.5.0 lib/steep/drivers/utils/each_signature.rb
steep-0.4.0 lib/steep/drivers/utils/each_signature.rb
steep-0.3.0 lib/steep/drivers/utils/each_signature.rb
steep-0.2.0 lib/steep/drivers/utils/each_signature.rb
steep-0.1.0 lib/steep/drivers/utils/each_signature.rb