Class: Fontist::GoogleImportSource

Inherits:
ImportSource
  • Object
show all
Defined in:
lib/fontist/google_import_source.rb

Overview

Import source for Google Fonts

Tracks the specific commit, API version, and family information for fonts imported from Google Fonts.

Note: Google Fonts filenames are NOT versioned because Google Fonts is a live service that always provides the latest version. The commit_id is tracked in import_source for metadata and update detection only.

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Equality check based on commit ID

Parameters:

  • other (Object)

    The object to compare

Returns:

  • (Boolean)

    true if objects are equal



60
61
62
63
64
# File 'lib/fontist/google_import_source.rb', line 60

def ==(other)
  return false unless other.is_a?(GoogleImportSource)

  commit_id == other.commit_id
end

#differentiation_keynil

Returns nil - Google Fonts formulas use simple filenames

Google Fonts is a live service, so formulas always point to the latest version. The commit_id is stored for metadata only.

Returns:

  • (nil)

    No differentiation needed for Google Fonts



29
30
31
# File 'lib/fontist/google_import_source.rb', line 29

def differentiation_key
  nil
end

#outdated?(new_source) ⇒ Boolean

Checks if this import source is older than the provided new source

Parameters:

Returns:

  • (Boolean)

    true if this source is outdated



37
38
39
40
41
42
43
44
45
46
# File 'lib/fontist/google_import_source.rb', line 37

def outdated?(new_source)
  return false unless new_source.is_a?(GoogleImportSource)
  return false unless commit_id && new_source.commit_id

  # Compare commit IDs - different commits mean potential update
  commit_id != new_source.commit_id
rescue StandardError => e
  Fontist.ui.error("Error comparing Google import sources: #{e.message}")
  false
end

#to_sString

Returns a human-readable string representation

Returns:

  • (String)

    String representation for debugging/logging



51
52
53
54
# File 'lib/fontist/google_import_source.rb', line 51

def to_s
  "Google Fonts (commit: #{commit_id&.slice(0,
                                            7)}, family: #{family_id}, API: #{api_version})"
end