check_dependencies 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d40642847f90cebc65c4ef8d8d217be71076fe4800806a38017aa570047d746
4
- data.tar.gz: 51595dc74b3f9da40feed01fef61e1b10ac3d769c0bff05d6f78bf72d1f8a1be
3
+ metadata.gz: 1fb8b26b9005629605058ec5c8bab1abafd474107992ebd5cfdca9e5e1f3a624
4
+ data.tar.gz: 6ed9df32bf09af0007ca87663e8caa8b6698079873d8a9cc925ca9b62fa60543
5
5
  SHA512:
6
- metadata.gz: 4c2d083d05ff7cd1540fb327155d4da81558ee50b64acda8ef5a87a9bc87c8ba115d7971c47bd618c5b2a6a5827fbcb1f70be4ee4fc028637f214a90adfa872c
7
- data.tar.gz: cdae703f7455e9f5f501ad9120bec8c680c6850301d409a18cde91d49d271022d4501897a54527ab77d8486cbea1c024796ea4de62538e1b398f743352127ff2
6
+ metadata.gz: e64aa448f87110dd4d5508a60d3dc9273c23fd5b2caa86abc43f4c2d93156169588f7b8aab8d28380f599fde7c1cfed6ce17311c061b5dad6074af2b6b72c1ce
7
+ data.tar.gz: 1050e3d07adde27b8b7018210ed14ac8d294b00f45b4349f4eba4634f0e9af1af4a4eac084dfb355c46b413180433e7aab7570a7e71642a19043153f33c686f4
@@ -244,7 +244,13 @@ def red(text); colorize(text, 31); end
244
244
  def green(text); colorize(text, 32); end
245
245
 
246
246
  def read_json_array_from_file_as_set(file_path)
247
- # 确保文件存在
247
+ # 检查 file_path 是否为 nil 或不是字符串
248
+ unless file_path.is_a?(String)
249
+ # 可以在这里抛出异常或返回一个空的 Set
250
+ raise ArgumentError, "file_path must be a String" unless file_path.is_a?(String)
251
+ return Set.new
252
+ end
253
+
248
254
  if File.exist?(file_path)
249
255
  # 读取文件内容
250
256
  file_content = File.read(file_path)
@@ -253,26 +259,28 @@ def read_json_array_from_file_as_set(file_path)
253
259
  # 将数组转换为 Set 并返回
254
260
  return json_array.to_set
255
261
  else
256
- puts "File not found: #{file_path}"
257
- exit
262
+ # 文件不存在时,也可以选择抛出异常或返回一个空的 Set
263
+ puts "File not found: #{file_path}" # 或者使用 raise "File not found: #{file_path}"
264
+ return Set.new
258
265
  end
259
- rescue JSON::ParserError => e
260
- puts "Error parsing JSON from #{file_path}: #{e.message}"
261
- exit
262
266
  end
263
267
 
264
268
  def compare_podfile_locks(old_lock_path, new_lock_path, config_path = nil)
265
- config_set = read_json_array_from_file_as_set(config_path)
266
269
 
267
270
  old_pods = read_local_podfile_lock(old_lock_path)
268
271
  new_pods = read_local_podfile_lock(new_lock_path)
269
272
 
270
273
  old_unique_deps = find_shortest_paths(extract_unique_dependencies(old_pods)).to_set
271
274
  new_unique_deps = find_shortest_paths(extract_unique_dependencies(new_pods)).to_set
272
- if !config_set.empty?
273
- old_unique_deps = old_unique_deps.select { |dep| config_set.include?(dep.split('/').first) }
274
- new_unique_deps = new_unique_deps.select { |dep| config_set.include?(dep.split('/').first) }
275
+
276
+ unless config_path.nil?
277
+ config_set = read_json_array_from_file_as_set(config_path)
278
+ if !config_set.empty?
279
+ old_unique_deps = old_unique_deps.select { |dep| config_set.include?(dep.split('/').first) }
280
+ new_unique_deps = new_unique_deps.select { |dep| config_set.include?(dep.split('/').first) }
281
+ end
275
282
  end
283
+
276
284
  only_in_old = old_unique_deps - new_unique_deps
277
285
  only_in_new = new_unique_deps - old_unique_deps
278
286
 
Binary file
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "check_dependencies"
3
- spec.version = "0.1.7"
3
+ spec.version = "0.1.8"
4
4
  spec.authors = ["ITxiansheng"]
5
5
  spec.email = ["itxiansheng@gmail.com"]
6
6
 
@@ -244,7 +244,13 @@ def red(text); colorize(text, 31); end
244
244
  def green(text); colorize(text, 32); end
245
245
 
246
246
  def read_json_array_from_file_as_set(file_path)
247
- # 确保文件存在
247
+ # 检查 file_path 是否为 nil 或不是字符串
248
+ unless file_path.is_a?(String)
249
+ # 可以在这里抛出异常或返回一个空的 Set
250
+ raise ArgumentError, "file_path must be a String" unless file_path.is_a?(String)
251
+ return Set.new
252
+ end
253
+
248
254
  if File.exist?(file_path)
249
255
  # 读取文件内容
250
256
  file_content = File.read(file_path)
@@ -253,26 +259,28 @@ def read_json_array_from_file_as_set(file_path)
253
259
  # 将数组转换为 Set 并返回
254
260
  return json_array.to_set
255
261
  else
256
- puts "File not found: #{file_path}"
257
- exit
262
+ # 文件不存在时,也可以选择抛出异常或返回一个空的 Set
263
+ puts "File not found: #{file_path}" # 或者使用 raise "File not found: #{file_path}"
264
+ return Set.new
258
265
  end
259
- rescue JSON::ParserError => e
260
- puts "Error parsing JSON from #{file_path}: #{e.message}"
261
- exit
262
266
  end
263
267
 
264
268
  def compare_podfile_locks(old_lock_path, new_lock_path, config_path = nil)
265
- config_set = read_json_array_from_file_as_set(config_path)
266
269
 
267
270
  old_pods = read_local_podfile_lock(old_lock_path)
268
271
  new_pods = read_local_podfile_lock(new_lock_path)
269
272
 
270
273
  old_unique_deps = find_shortest_paths(extract_unique_dependencies(old_pods)).to_set
271
274
  new_unique_deps = find_shortest_paths(extract_unique_dependencies(new_pods)).to_set
272
- if !config_set.empty?
273
- old_unique_deps = old_unique_deps.select { |dep| config_set.include?(dep.split('/').first) }
274
- new_unique_deps = new_unique_deps.select { |dep| config_set.include?(dep.split('/').first) }
275
+
276
+ unless config_path.nil?
277
+ config_set = read_json_array_from_file_as_set(config_path)
278
+ if !config_set.empty?
279
+ old_unique_deps = old_unique_deps.select { |dep| config_set.include?(dep.split('/').first) }
280
+ new_unique_deps = new_unique_deps.select { |dep| config_set.include?(dep.split('/').first) }
281
+ end
275
282
  end
283
+
276
284
  only_in_old = old_unique_deps - new_unique_deps
277
285
  only_in_new = new_unique_deps - old_unique_deps
278
286
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check_dependencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITxiansheng
@@ -57,6 +57,7 @@ files:
57
57
  - bin/check_dependencies
58
58
  - bin/console
59
59
  - bin/setup
60
+ - check_dependencies-0.1.7.gem
60
61
  - check_dependencies.gemspec
61
62
  - gem_env_install.sh
62
63
  - lib/check_dependencies.rb