Sha256: 08d8da0fd3d4ba703c478e4e431f2960ea7af949b814cda19d513039ffc6e972

Contents?: true

Size: 649 Bytes

Versions: 9

Compression:

Stored size: 649 Bytes

Contents

# frozen_string_literal: true
require "webrick"

module ShopifyCli
  module Theme
    class MimeType < Struct.new(:name)
      MIME_TYPES = WEBrick::HTTPUtils::DefaultMimeTypes.merge(
        "liquid" => "text/x-liquid",
      )

      class << self
        def by_filename(filename)
          new(WEBrick::HTTPUtils.mime_type(filename.to_s, MIME_TYPES))
        end
      end

      def text?
        /text/.match?(name) || json? || javascript?
      end

      def json?
        name == "application/json"
      end

      def javascript?
        name == "application/javascript"
      end

      def to_s
        name
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shopify-cli-2.4.0 lib/shopify-cli/theme/mime_type.rb
shopify-cli-2.3.0 lib/shopify-cli/theme/mime_type.rb
shopify-cli-2.2.2 lib/shopify-cli/theme/mime_type.rb
shopify-cli-2.2.1 lib/shopify-cli/theme/mime_type.rb
shopify-cli-2.2.0 lib/shopify-cli/theme/mime_type.rb
shopify-cli-2.1.0 lib/shopify-cli/theme/mime_type.rb
shopify-cli-2.0.2 lib/shopify-cli/theme/mime_type.rb
shopify-cli-2.0.1 lib/shopify-cli/theme/mime_type.rb
shopify-cli-2.0.0 lib/shopify-cli/theme/mime_type.rb