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.10.1 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.10.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.9.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.8.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.7.4 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.7.3 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.7.2 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.7.1 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.7.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.6.6 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.6.5 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.6.4 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.6.3 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.6.2 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.6.1 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.6.0 lib/shopify_cli/theme/mime_type.rb
shopify-cli-2.5.0 lib/shopify_cli/theme/mime_type.rb