Sha256: 3349c26273e634a3eaa8181009531ed64c8cb2f1dd39f977b6e70061fdddc864

Contents?: true

Size: 867 Bytes

Versions: 5

Compression:

Stored size: 867 Bytes

Contents

require "rack"
require "ember_cli/errors"

module EmberCli
  module Deploy
    class File
      def initialize(app)
        @app = app
      end

      def mountable?
        true
      end

      def to_rack
        Rack::File.new(app.dist_path.to_s, rack_headers)
      end

      def index_html
        if index_file.exist?
          index_file.read
        else
          check_for_error_and_raise!
        end
      end

      private

      attr_reader :app

      def rack_headers
        {
          "Cache-Control" => Rails.configuration.static_cache_control,
        }
      end

      def check_for_error_and_raise!
        app.check_for_errors!

        raise BuildError.new <<-MSG
          EmberCLI failed to generate an `index.html` file.
        MSG
      end

      def index_file
        app.dist_path.join("index.html")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ember-cli-rails-0.8.1 lib/ember_cli/deploy/file.rb
ember-cli-rails-0.8.0 lib/ember_cli/deploy/file.rb
ember-cli-rails-0.7.4 lib/ember_cli/deploy/file.rb
ember-cli-rails-0.7.3 lib/ember_cli/deploy/file.rb
ember-cli-rails-0.7.2 lib/ember_cli/deploy/file.rb