Class: BooticCli::Themes::FSTheme::ThemeAsset

Inherits:
Struct
  • Object
show all
Defined in:
lib/bootic_cli/themes/fs_theme.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fileObject

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



15
16
17
# File 'lib/bootic_cli/themes/fs_theme.rb', line 15

def file
  @file
end

#file_nameObject

Returns the value of attribute file_name

Returns:

  • (Object)

    the current value of file_name



15
16
17
# File 'lib/bootic_cli/themes/fs_theme.rb', line 15

def file_name
  @file_name
end

#updated_onObject

Returns the value of attribute updated_on

Returns:

  • (Object)

    the current value of updated_on



15
16
17
# File 'lib/bootic_cli/themes/fs_theme.rb', line 15

def updated_on
  @updated_on
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/bootic_cli/themes/fs_theme.rb', line 20

def ==(other)
  if other.digest.to_s == '' # api theme asset without a digest set
    # puts "Other has no digest, so comparing dates: #{self.updated_on.to_i} vs #{other.updated_on.to_i}"
    return self.updated_on.to_i == other.updated_on.to_i
  end

  # file sizes may differ as they are served by CDN (that shrinks them)
  # puts "Comparing FSTheme vs other digest:\n#{digest}\n#{other.digest}"
  self.digest == other.digest # self.file_size == other.file_size
end

#bodyObject



16
# File 'lib/bootic_cli/themes/fs_theme.rb', line 16

def body; @body ||= file.read; end

#digestObject



18
# File 'lib/bootic_cli/themes/fs_theme.rb', line 18

def digest; @digest ||= Digest::MD5.hexdigest(body); end

#file_sizeObject



17
# File 'lib/bootic_cli/themes/fs_theme.rb', line 17

def file_size; body.length; end