Class: YkCommand::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.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/yk_command/analyze/dependency_result.rb', line 22

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 unless  !dep.external_source.nil?

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

    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



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/yk_command/analyze/dependency_result.rb', line 50

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|
      if SPECIFICATION_FILTER_KEYS.include?(k)
        map[k] = v
      end
    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



102
103
104
105
106
107
108
109
110
# File 'lib/yk_command/analyze/dependency_result.rb', line 102

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



82
83
84
85
# File 'lib/yk_command/analyze/dependency_result.rb', line 82

def result_json
  find_info_in_lokfile
  @result.to_json
end