Class: Fastlane::Ref::RefPodInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/rocket/ref/ref_pod_info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version, git, git_path, files_h, files_swift, files_m, files_h_name, files_swift_name, files_m_name) ⇒ RefPodInfo

Returns a new instance of RefPodInfo.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 46

def initialize(name, version, git,git_path,files_h,files_swift,files_m,files_h_name,files_swift_name,files_m_name)
   @name=name
   @version=version
   @git=git
   @git_path=git_path
   @files_h=files_h
   @files_swift=files_swift
   @files_m=files_m
   @files_h_name=files_h_name
   @files_swift_name=files_swift_name
   @files_m_name=files_m_name
   @deps = Hash.new
   @reference_errors = Hash.new

end

Instance Attribute Details

#depsObject (readonly)

Returns the value of attribute deps.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def deps
  @deps
end

#files_hObject (readonly)

Returns the value of attribute files_h.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def files_h
  @files_h
end

#files_h_nameObject (readonly)

Returns the value of attribute files_h_name.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def files_h_name
  @files_h_name
end

#files_mObject (readonly)

Returns the value of attribute files_m.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def files_m
  @files_m
end

#files_m_nameObject (readonly)

Returns the value of attribute files_m_name.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def files_m_name
  @files_m_name
end

#files_swiftObject (readonly)

Returns the value of attribute files_swift.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def files_swift
  @files_swift
end

#files_swift_nameObject (readonly)

Returns the value of attribute files_swift_name.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def files_swift_name
  @files_swift_name
end

#gitObject (readonly)

Returns the value of attribute git.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def git
  @git
end

#git_pathObject (readonly)

Returns the value of attribute git_path.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def git_path
  @git_path
end

#nameObject (readonly)

Returns the value of attribute name.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def name
  @name
end

#reference_errorsObject (readonly)

Returns the value of attribute reference_errors.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def reference_errors
  @reference_errors
end

#versionObject (readonly)

Returns the value of attribute version.



33
34
35
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 33

def version
  @version
end

Class Method Details

.analysis(lock_path, pods_path, specs_path) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 94

def self.analysis(lock_path,pods_path,specs_path)

  #生成pod对象
  pods_hash = Hash.new
  pod_list = Dir.glob("#{pods_path}/**")
  pod_list.each do |item|
    pod_name = item.gsub("#{pods_path}/","")
    if  pod_name == "Target Support Files" || 
        pod_name == "Local Podspecs" || 
        pod_name == "Headers" || 
        pod_name == "Pods.xcodeproj" || 
        pod_name == "Manifest.lock"
      next
    end

    #获取版本
    Tools.shell("sed -i ''  \"s/ //g\" \"#{lock_path}\"")
    notes = Tools.return_shell("grep -i '#{pod_name}' '#{lock_path}'")

    notes_tmp = notes.split("(=")
    if notes_tmp.size > 1
      version = notes_tmp[1].split(")").first
    else 
      tmp = notes.split("(")
      tmp.each do |t|
          if t.include?("~")
              next
          end
          if t.include?(")")
              version = t.split(")").first
          end
      end
    end

    #获取git地址
    pod_git_path = "#{specs_path}/#{pod_name}/#{version}/#{pod_name}.podspec.json"
    pod_git = nil
    if File.exist?(pod_git_path)
      json = File.read(pod_git_path)
      json_obj = JSON.parse(json)
      pod_git = json_obj["source"]["git"]
    end

    #找到库的代码文件
    files_h = Dir.glob("#{item}/**/*.h")
    files_swift = Dir.glob("#{item}/**/*.swift")
    files_m = Dir.glob("#{item}/**/*.{m,mm}")
  
    files_h_name = []
    files_h.each do |file|
        files_h_name << File.basename(file)
    end
  
    files_swift_name = []
    files_swift.each do |file|
        files_swift_name << File.basename(file)
    end
  
    files_m_name = []
    files_m.each do |file|
        files_m_name << File.basename(file)
    end

    pod_info = RefPodInfo.new(pod_name,version,pod_git,pod_git_path,files_h,files_swift,files_m,files_h_name,files_swift_name,files_m_name)
    pod_info.string
    pods_hash[pod_name] = pod_info
  end
  return pods_hash
end

.files(pod_hash) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 164

def self.files(pod_hash)
  files_hash = Hash.new
  tmps = []
  pod_hash.keys.each do |key|
    info = pod_hash[key]
    #忽略第三方库
    if info.git == nil
      tmps << info.name
      next
    end
    files = []
    files += info.files_h
    files += info.files_swift
    files += info.files_m
    files_hash[key] = files
  end
  Tools.log("跳过第三方库 => #{tmps}")
  return files_hash
end

.git_paths(pod_hash) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 184

def self.git_paths(pod_hash)
  git_paths = []
  pod_hash.values.each do |pod|
    #忽略第三方库
    if pod.git == nil
      next
    end
    git_paths << pod.git_path
  end
  return git_paths
end

Instance Method Details

#add_deps(pod_name, version, file_path, notes, podspec_quote) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 71

def add_deps(pod_name,version,file_path,notes,podspec_quote)
 dep_info = RefDepInfo.new(pod_name,version,@name,file_path,File.basename(file_path),notes,podspec_quote)
 unless @deps.has_key?(pod_name)
   @deps[pod_name] = []
 end
 @deps[pod_name] << dep_info
end

#add_reference_errors(pod_name, version, file_path, notes, podspec_quote) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 63

def add_reference_errors(pod_name,version,file_path,notes,podspec_quote)
  errors_info = RefDepInfo.new(pod_name,version,@name,file_path,File.basename(file_path),notes,podspec_quote)
  unless @reference_errors.has_key?(pod_name)
    @reference_errors[pod_name] = []
  end
  @reference_errors[pod_name] << errors_info
end

#get_files_h_nameObject



79
80
81
82
83
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 79

def get_files_h_name()
 unless files_h_name.empty?
     Tools.logs("#{@name}的头文件",@files_h_name)
 end
end

#stringObject



85
86
87
88
89
90
91
92
# File 'lib/fastlane/plugin/rocket/ref/ref_pod_info.rb', line 85

def string()
 string = []
 string << "name => #{name}"
 string << "version => #{version}"
 string << "git => #{git}"
 string << "git_path => #{git_path}"
 Tools.logs("#{name}属性",string)
end