Class: YkIosCmd::DependencyResult

Inherits:
Object
  • Object
show all
Defined in:
lib/yk_command/analyze/dependency_result.rb

Instance Method Summary collapse

Constructor Details

#initialize(specifications, pod_lock) ⇒ DependencyResult

Returns a new instance of DependencyResult.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/yk_command/analyze/dependency_result.rb', line 20

def initialize(specifications, pod_lock)
  @specifications = specifications
  @pod_lock = pod_lock
  @result = []

  @local_pods = []
  @yk_git_source_pods = []
  @other_git_source_pods = []
  @pod_lock.dependencies.each do |dep|
    next if dep.external_source.nil?

    @local_pods.push dep.name if dep.external_source.include?(:path)

    if dep.external_source.include?(:git)
      if dep.external_source[:git].include?(YK)
        @yk_git_source_pods.push dep.name
      else
        @other_git_source_pods.push dep.name
      end
    end
  end
end

Instance Method Details

#find_info_in_lokfileObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/yk_command/analyze/dependency_result.rb', line 43

def find_info_in_lokfile
  removed_subspecs_dep_list = []
  @pod_lock.pod_names.each do |pn|
    removed_subspecs_dep_list = removed_subspecs_dep_list.push(pn.split('/')[0]).uniq
  end

  # 去重后的 依赖 名字 数组
  removed_subspecs_dep_list.each do |pod_name|
    map = {}
    version = @pod_lock.version(pod_name).version
    spec_repo_name = @pod_lock.spec_repo(pod_name)
    is_local_dependency = @local_pods.include? pod_name
    is_install_from_git_commit = @yk_git_source_pods.include? pod_name
    dep_attribute_in_pod_file = find_info_in_specifications pod_name
    # pp "#{pod_name} #{spec_repo_name} #{version} local:#{is_local_dependency} ,git_commit: #{is_install_from_git_commit}"
    map['name'] = pod_name
    map['version'] = version
    map['is_local_dependency'] = is_local_dependency
    map['is_install_from_git_commit'] = is_install_from_git_commit
    dep_attribute_in_pod_file.each do |k, v|
      map[k] = v if SPECIFICATION_FILTER_KEYS.include?(k)
    end

    @result.push map
  end
end

#find_info_in_specifications(name) ⇒ Object

def is_pod_from_local(name)

local_pods = []
@pod_lock.dependencies.each do |dep|
  next unless dep.name == name && !dep.external_source.nil?
  if dep.external_source.include?(:path)
    local_pods.push dep.name
  end

end
local_pods.include? name

end



89
90
91
92
93
94
95
96
97
# File 'lib/yk_command/analyze/dependency_result.rb', line 89

def find_info_in_specifications(name)
  map = {}
  @specifications.each do |sp|
    next unless sp.name == name

    map = sp.attributes_hash
  end
  map
end

#result_jsonObject



70
71
72
73
# File 'lib/yk_command/analyze/dependency_result.rb', line 70

def result_json
  find_info_in_lokfile
  @result.to_json
end