Class: SpmPackageContext

Inherits:
Struct
  • Object
show all
Defined in:
lib/spm_version_updates/spm_package_context.rb

Overview

Carries normalized package facts through version, branch, and revision checks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cache_keyObject

Returns the value of attribute cache_key

Returns:

  • (Object)

    the current value of cache_key



6
7
8
# File 'lib/spm_version_updates/spm_package_context.rb', line 6

def cache_key
  @cache_key
end

#kindObject

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



6
7
8
# File 'lib/spm_version_updates/spm_package_context.rb', line 6

def kind
  @kind
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



6
7
8
# File 'lib/spm_version_updates/spm_package_context.rb', line 6

def name
  @name
end

#normalized_urlObject

Returns the value of attribute normalized_url

Returns:

  • (Object)

    the current value of normalized_url



6
7
8
# File 'lib/spm_version_updates/spm_package_context.rb', line 6

def normalized_url
  @normalized_url
end

#persistent_cache_keyObject

Returns the value of attribute persistent_cache_key

Returns:

  • (Object)

    the current value of persistent_cache_key



6
7
8
# File 'lib/spm_version_updates/spm_package_context.rb', line 6

def persistent_cache_key
  @persistent_cache_key
end

#repository_urlObject

Returns the value of attribute repository_url

Returns:

  • (Object)

    the current value of repository_url



6
7
8
# File 'lib/spm_version_updates/spm_package_context.rb', line 6

def repository_url
  @repository_url
end

#requirementObject

Returns the value of attribute requirement

Returns:

  • (Object)

    the current value of requirement



6
7
8
# File 'lib/spm_version_updates/spm_package_context.rb', line 6

def requirement
  @requirement
end

#resolved_versionObject

Returns the value of attribute resolved_version

Returns:

  • (Object)

    the current value of resolved_version



6
7
8
# File 'lib/spm_version_updates/spm_package_context.rb', line 6

def resolved_version
  @resolved_version
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



6
7
8
# File 'lib/spm_version_updates/spm_package_context.rb', line 6

def source
  @source
end

Instance Method Details

#add_version_tag_lookup(lookups, cache) ⇒ Object



18
19
20
21
# File 'lib/spm_version_updates/spm_package_context.rb', line 18

def add_version_tag_lookup(lookups, cache)
  key = cache_key
  lookups[key] ||= [cache_key, repository_url, persistent_cache_key] unless cache.key?(key)
end

#branchObject



23
24
25
# File 'lib/spm_version_updates/spm_package_context.rb', line 23

def branch
  requirement["branch"]
end

#branch_update?(last_commit) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/spm_version_updates/spm_package_context.rb', line 27

def branch_update?(last_commit)
  last_commit && last_commit != resolved_version
end

#branch_update_warningObject



35
36
37
38
39
40
# File 'lib/spm_version_updates/spm_package_context.rb', line 35

def branch_update_warning
  last_commit = GitOperations.branch_last_commit(repository_url, branch)
  return unless branch_update?(last_commit)

  [branch_warning_message(last_commit), last_commit, "branch: #{branch}"]
end

#branch_warning_message(last_commit) ⇒ Object



31
32
33
# File 'lib/spm_version_updates/spm_package_context.rb', line 31

def branch_warning_message(last_commit)
  "Newer commit available for #{name} (#{branch}): #{last_commit}"
end

#source_lineObject



42
43
44
# File 'lib/spm_version_updates/spm_package_context.rb', line 42

def source_line
  "Source: #{source}" if source
end

#source_suffixObject



46
47
48
# File 'lib/spm_version_updates/spm_package_context.rb', line 46

def source_suffix
  source ? " (#{source})" : ""
end