Sha256: 2234a50095be5b1c0e18c5a94429d68ec663b552ac1ec812da13b339d948bbd6

Contents?: true

Size: 937 Bytes

Versions: 20

Compression:

Stored size: 937 Bytes

Contents

module React
  module ServerRendering
    # Get asset content by reading the compiled file from disk using the generated manifest.yml file
    #
    # This is good for Rails production when assets are compiled to public/assets
    # but sometimes, they're compiled to other directories (or other servers)
    class YamlManifestContainer
      def initialize
        @assets = YAML.load_file(public_asset_path('manifest.yml'))
      end

      def find_asset(logical_path)
        asset_path = @assets[logical_path] || raise("No compiled asset for #{logical_path}, was it precompiled?")
        File.read(public_asset_path(asset_path))
      end

      def self.compatible?
        ::Rails::VERSION::MAJOR == 3
      end

      private

      def public_asset_path(asset_name)
        asset_path = File.join('public', ::Rails.application.config.assets.prefix, asset_name)
        ::Rails.root.join(asset_path)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
react-rails-2.7.1 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.7.0 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.7.0.rc.2 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.7.0.rc.1 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.7.0.rc.0 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.6.2 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.6.1 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.6.0 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.5.0 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.4.7 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.4.6 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.4.5 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.4.4 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.4.4.pre lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.4.3 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.4.2 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.4.1 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.4.0 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.3.1 lib/react/server_rendering/yaml_manifest_container.rb
react-rails-2.3.0 lib/react/server_rendering/yaml_manifest_container.rb