Sha256: 3bbb3af18558211c62aedb4675ade308ef7f41d6d802bb4e04aaffec2aacc6ce

Contents?: true

Size: 735 Bytes

Versions: 13

Compression:

Stored size: 735 Bytes

Contents

class SmartIoC::BeanLocator
  include SmartIoC::Args

  BEAN_PATTERN = /bean\s+(:[a-zA-z0-9\-\_]+)/

  # @param package_name [Symbol] package name for bean (ex: :repository)
  # @param dir [String] absolute path for directory with bean definitions
  # @return nil
  def locate_beans(package_name, dir)
    check_arg(package_name, :package_name, Symbol)

    Dir.glob(File.join(dir, '**/*.rb')).each do |file_path|
      File.readlines(file_path).each do |line|
        match_data = line.match(BEAN_PATTERN)

        if match_data
          SmartIoC::BeanLocations.add_bean(
            package_name, match_data.captures.first.gsub(':', '').to_sym, file_path
          )
          break
        end
      end
    end

    nil
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
smart_ioc-0.5.2 lib/smart_ioc/bean_locator.rb
smart_ioc-0.5.1 lib/smart_ioc/bean_locator.rb
smart_ioc-0.5.0 lib/smart_ioc/bean_locator.rb
smart_ioc-0.3.9 lib/smart_ioc/bean_locator.rb
smart_ioc-0.4.0 lib/smart_ioc/bean_locator.rb
smart_ioc-0.3.8 lib/smart_ioc/bean_locator.rb
smart_ioc-0.3.7 lib/smart_ioc/bean_locator.rb
smart_ioc-0.3.6 lib/smart_ioc/bean_locator.rb
smart_ioc-0.3.5 lib/smart_ioc/bean_locator.rb
smart_ioc-0.3.2 lib/smart_ioc/bean_locator.rb
smart_ioc-0.3.1 lib/smart_ioc/bean_locator.rb
smart_ioc-0.3.0 lib/smart_ioc/bean_locator.rb
smart_ioc-0.2.5 lib/smart_ioc/bean_locator.rb