Class: ShopifyCLI::Theme::MimeType

Inherits:
Struct
  • Object
show all
Defined in:
lib/shopify_cli/theme/mime_type.rb

Constant Summary collapse

MIME_TYPES =
WEBrick::HTTPUtils::DefaultMimeTypes.merge(
  "liquid" => "text/x-liquid",
)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



6
7
8
# File 'lib/shopify_cli/theme/mime_type.rb', line 6

def name
  @name
end

Class Method Details

.by_filename(filename) ⇒ Object



12
13
14
# File 'lib/shopify_cli/theme/mime_type.rb', line 12

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

Instance Method Details

#javascript?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/shopify_cli/theme/mime_type.rb', line 25

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

#json?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/shopify_cli/theme/mime_type.rb', line 21

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

#text?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/shopify_cli/theme/mime_type.rb', line 17

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

#to_sObject



29
30
31
# File 'lib/shopify_cli/theme/mime_type.rb', line 29

def to_s
  name
end