Class: Pray::Lockfile

Inherits:
Struct
  • Object
show all
Defined in:
lib/pray/lockfile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prayfile_lock: "1", spec: "0.1", generated_by: Pray::GENERATED_BY, manifest_hash: "", environment: nil, source: [], package: [], target: [], managed_span: []) ⇒ Lockfile

Returns a new instance of Lockfile.



28
29
30
31
32
33
# File 'lib/pray/lockfile.rb', line 28

def initialize(
  prayfile_lock: "1", spec: "0.1", generated_by: Pray::GENERATED_BY,
  manifest_hash: "", environment: nil, source: [], package: [], target: [], managed_span: []
)
  super
end

Instance Attribute Details

#environmentObject

Returns the value of attribute environment

Returns:

  • (Object)

    the current value of environment



24
25
26
# File 'lib/pray/lockfile.rb', line 24

def environment
  @environment
end

#generated_byObject

Returns the value of attribute generated_by

Returns:

  • (Object)

    the current value of generated_by



24
25
26
# File 'lib/pray/lockfile.rb', line 24

def generated_by
  @generated_by
end

#managed_spanObject

Returns the value of attribute managed_span

Returns:

  • (Object)

    the current value of managed_span



24
25
26
# File 'lib/pray/lockfile.rb', line 24

def managed_span
  @managed_span
end

#manifest_hashObject

Returns the value of attribute manifest_hash

Returns:

  • (Object)

    the current value of manifest_hash



24
25
26
# File 'lib/pray/lockfile.rb', line 24

def manifest_hash
  @manifest_hash
end

#packageObject

Returns the value of attribute package

Returns:

  • (Object)

    the current value of package



24
25
26
# File 'lib/pray/lockfile.rb', line 24

def package
  @package
end

#prayfile_lockObject

Returns the value of attribute prayfile_lock

Returns:

  • (Object)

    the current value of prayfile_lock



24
25
26
# File 'lib/pray/lockfile.rb', line 24

def prayfile_lock
  @prayfile_lock
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



24
25
26
# File 'lib/pray/lockfile.rb', line 24

def source
  @source
end

#specObject

Returns the value of attribute spec

Returns:

  • (Object)

    the current value of spec



24
25
26
# File 'lib/pray/lockfile.rb', line 24

def spec
  @spec
end

#targetObject

Returns the value of attribute target

Returns:

  • (Object)

    the current value of target



24
25
26
# File 'lib/pray/lockfile.rb', line 24

def target
  @target
end

Instance Method Details

#canonicalizedObject



35
36
37
38
39
40
41
42
# File 'lib/pray/lockfile.rb', line 35

def canonicalized
  dup.tap do |copy|
    copy.source = source.sort_by(&:name)
    copy.package = package.sort_by { |entry| [entry.name, entry.source.to_s, entry.version] }
    copy.target = target.sort_by(&:name)
    copy.managed_span = managed_span.sort_by { |span| [span.target, span.open_line, span.id] }
  end
end

#equivalent_to?(other) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/pray/lockfile.rb', line 52

def equivalent_to?(other)
  canonicalized == other.canonicalized
end

#file_hashObject



48
49
50
# File 'lib/pray/lockfile.rb', line 48

def file_hash
  Hashing.sha256_prefixed(serialized)
end

#serializedObject



44
45
46
# File 'lib/pray/lockfile.rb', line 44

def serialized
  LockfileIO.lockfile_to_toml(canonicalized)
end