Sha256: 4021527983262d747d8414d389fc6c01ab56357b399da203bf188da1390f5fb2

Contents?: true

Size: 822 Bytes

Versions: 3

Compression:

Stored size: 822 Bytes

Contents

module RSpec
  module Scaffold
    class DirExpander
      # manages recursively finding ruby files in directories.

      # @param [Pathname] input_dir
      def initialize(input_dir)
        @input_dir = Pathname(input_dir)
      end

      # RSpec::Scaffold::DirExpander.new("/path/to/dir")
      def expand_ruby_files
        # 1. Raise if not a directory
        raise(ArgumentError.new(%Q|"#{file}" is not a directory|)) if !@input_dir.directory?

        # 2. do the expansion of ruby files
        print ">> scanning #{@input_dir} tree for ruby files... "

        @ruby_files_in_tree ||= Dir.glob("#{@input_dir.to_s.gsub(%r'/\z', '')}/**/*.rb")

        puts "done"

        return @ruby_files_in_tree #=> ["/rspec-scaffold/spec/dummy/app/lib/some_service_class.rb"] array of strings
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rspec-scaffold-2.0.1 lib/rspec/scaffold/dir_expander.rb
rspec-scaffold-2.0.0 lib/rspec/scaffold/dir_expander.rb
rspec-scaffold-2.0.0.beta1 lib/rspec/scaffold/dir_expander.rb