Sha256: 412d28a440a6e5c88af2a6a03025dc3fae7699cbe844dd4b8d761c411c2a4274

Contents?: true

Size: 649 Bytes

Versions: 57

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

57 entries across 57 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.35.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.34.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.33.1 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.33.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.32.1 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.32.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.31.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.30.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.29.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.28.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.27.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.26.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.25.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.24.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.23.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.22.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.21.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.20.1 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.20.0 lib/shopify_cli/theme/mime_type.rb