Sha256: 58c816adc6c96066cb8f8ca7a6af95bee15e36e8b7aa0395ff12683d5430325c

Contents?: true

Size: 969 Bytes

Versions: 10

Compression:

Stored size: 969 Bytes

Contents

module Rbexy
  module Rails
    class RbxDependencyTracker
      def self.supports_view_paths?
        true
      end

      def self.call(name, template, view_paths = nil)
        new(name, template, view_paths).dependencies
      end

      def initialize(name, template, view_paths = nil)
        @name, @template, @view_paths = name, template, view_paths
      end

      def dependencies
        rails_render_helper_dependencies + rbexy_dependencies
      end

      private

      attr_reader :name, :template, :view_paths

      def rails_render_helper_dependencies
        ActionView::DependencyTracker::ERBTracker.call(name, template, view_paths)
      end

      def rbexy_dependencies
        Lexer.new(template, Rbexy.configuration.element_resolver).tokenize
          .select { |t| t[0] == :TAG_DETAILS && t[1][:type] == :component }
          .map { |t| t[1][:component_class] }
          .uniq
          .map(&:template_path)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rbexy-2.0.0.rc5 lib/rbexy/rails/rbx_dependency_tracker.rb
rbexy-2.0.0.rc4 lib/rbexy/rails/rbx_dependency_tracker.rb
rbexy-2.0.0.rc3 lib/rbexy/rails/rbx_dependency_tracker.rb
rbexy-2.0.0.rc2 lib/rbexy/rails/rbx_dependency_tracker.rb
rbexy-2.0.0.rc1 lib/rbexy/rails/rbx_dependency_tracker.rb
rbexy-2.0.0.beta9 lib/rbexy/rails/rbx_dependency_tracker.rb
rbexy-2.0.0.beta8 lib/rbexy/rails/rbx_dependency_tracker.rb
rbexy-2.0.0.beta7 lib/rbexy/rails/rbx_dependency_tracker.rb
rbexy-2.0.0.beta6 lib/rbexy/rails/rbx_dependency_tracker.rb
rbexy-2.0.0.beta5 lib/rbexy/rails/rbx_dependency_tracker.rb