Class: TYCiCore::TYDependencies

Inherits:
Object
  • Object
show all
Defined in:
lib/tuya/ci/core/dependencies.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ TYDependencies

Returns a new instance of TYDependencies.



6
7
8
9
# File 'lib/tuya/ci/core/dependencies.rb', line 6

def initialize(path)
  @path = path
  @content = ''
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/tuya/ci/core/dependencies.rb', line 4

def content
  @content
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/tuya/ci/core/dependencies.rb', line 4

def path
  @path
end

Instance Method Details

#analysisObject



31
32
33
34
35
36
37
38
# File 'lib/tuya/ci/core/dependencies.rb', line 31

def analysis
  content = File.read @path

  podfile_lock = TYPodFileLock.new content

  analysis = TYPodAnalyse.new podfile_lock
  analysis.sorted_pods
end

#sort_pods(pods) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tuya/ci/core/dependencies.rb', line 11

def sort_pods(pods)
  if File.exist? @path
    lock_pods = analysis
    pods_hash = Hash.new
    pods.each do |pod|
      pods_hash[pod["name"]] = pod
    end
    result = []
    lock_pods.each do |lock_pod|
      if pods_hash.keys.include? lock_pod
        result.push pods_hash[lock_pod]
      end
    end
    result
  else
    puts "Can not find file: #{@path}".red
    pods
  end
end