Class: PodAlexandria::Lockfile

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-alexandria/rome/lockfile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Lockfile

Returns a new instance of Lockfile.



5
6
7
# File 'lib/cocoapods-alexandria/rome/lockfile.rb', line 5

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/cocoapods-alexandria/rome/lockfile.rb', line 3

def path
  @path
end

Instance Method Details

#changed_specs(lockfile) ⇒ Object

collect changed specs (changed checksum, checkout or deleted pod)



18
19
20
21
22
23
24
# File 'lib/cocoapods-alexandria/rome/lockfile.rb', line 18

def changed_specs(lockfile)
  changed_checksums = spec_checksums.select { |k,v| v != lockfile.spec_checksums[k] }.keys
  changed_checkout = checkout_options.select { |k,v| v != lockfile.checkout_options[k] }.keys
  deleted_specs = lockfile.spec_checksums.keys - spec_checksums.keys

  changed_checksums.to_set.merge(changed_checksums).merge(deleted_specs)
end

#copy_to(lockfile) ⇒ Object



42
43
44
# File 'lib/cocoapods-alexandria/rome/lockfile.rb', line 42

def copy_to(lockfile)
  FileUtils.copy_file(path, lockfile.path)
end

#deleteObject



46
47
48
# File 'lib/cocoapods-alexandria/rome/lockfile.rb', line 46

def delete
  FileUtils.remove_file(path, true)
end

#exists?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/cocoapods-alexandria/rome/lockfile.rb', line 9

def exists?
  File.file?(path)
end

#matches?(lockfile) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/cocoapods-alexandria/rome/lockfile.rb', line 13

def matches?(lockfile)
  FileUtils.identical?(path, lockfile.path)
end

#specs_affected_by(specs) ⇒ Object

collect affected frameworks (and filter out subspecs)



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cocoapods-alexandria/rome/lockfile.rb', line 27

def specs_affected_by(specs)
  affected = specs

  loop do
    items = pods.select { |s|
      s.is_a?(Hash) && s.values.flatten.any? { |ss| affected.include? ss.split.first }
    }.map { |s| s.keys.first.split.first }

    break if affected.superset? (affected + items)
    affected.merge(items)
  end

  affected = affected & spec_checksums.keys
end