Sha256: 30b9a4ba85f6660ce309e9977e0eb76b892c3fa3a3799404752aef31f104c03a

Contents?: true

Size: 692 Bytes

Versions: 2

Compression:

Stored size: 692 Bytes

Contents

module ActionviewPrecompiler
  class HelperScanner
    def initialize(dir)
      @dir = dir
    end

    def template_renders
      template_renders = []

      each_helper do |fullpath|
        parser = HelperParser.new(fullpath)
        parser.render_calls.each do |render_call|
          virtual_path = render_call.virtual_path

          locals = render_call.locals_keys.map(&:to_s).sort

          template_renders << [virtual_path, locals]
        end
      end

      template_renders.uniq
    end

    private

    def each_helper
      Dir["#{@dir}/**/*_helper.rb"].sort.map do |fullpath|
        next if File.directory?(fullpath)

        yield fullpath
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
actionview_precompiler-0.4.0 lib/actionview_precompiler/helper_scanner.rb
actionview_precompiler-0.3.0 lib/actionview_precompiler/helper_scanner.rb