stepmod-utils 0.3.33 → 0.3.34

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5f7acac9019851b25ebb422edd329f4eb94926619330d6e668f6b15043022ad
4
- data.tar.gz: b78786ab56c61b2db0168e95e2bfdddeef597b95d61f2de7ef518a52c96ede8d
3
+ metadata.gz: 5d4cd3a24127e1903a040a5edaa734ccef3adb17b65cce4c213fdcbf3d13ea5a
4
+ data.tar.gz: fe17db00fa97f748853ed5c0de867222a5d5ba16b3c2256a498abe20814d7694
5
5
  SHA512:
6
- metadata.gz: 7b98ed913144b1c570d0ef21cb61ec40497862e12d46eed97edf781426f669674c8a915e17e557ab0ce1907a43e6e915f3402910f26cd54f1763fe8a7efdca62
7
- data.tar.gz: 34e2019fe8b382a52452d21d6829a0868a86cacbe2796a470d3f21acfdc8bc5c23223a3a0ac517380a889397afa7193a98cb3f00745b9de2a7ae3257b09d3552
6
+ metadata.gz: 7dab877d377c83d22a08dffceb223c3a7c502b353bd89756829c7fc39341c57758276731623e3e013879c0a329f9bb00de19eb5daa869a8653cd2d48f3987115
7
+ data.tar.gz: ea50ab5f75131fc5474fb21adb8aaf7692dd48da61e453c754ac762fb76dde78948c0bbe9588f5f9750347d370189c56683481daa0c94fe57c77f10838c548a4
@@ -31,6 +31,31 @@ def all_express_files(stepmod_dir)
31
31
  files.filter { |file| File.exist?(file) }
32
32
  end
33
33
 
34
+ # On MacOS File.exist? was behaving case sensitive while on
35
+ # Github Actions it was behaving as case in-sensitive, e.g
36
+ # File.exist?(`../resource_docs/geometric_and_topological_representation/RationalLRsurf.gif`)
37
+ # was returning true on MacOS and false on Github Action runner. Because
38
+ # the original filepath was `geometric_and_topological_representation/RationalLRSurf.gif` (notice the capital `S` for Surf.gif)
39
+ # So this method is to find the actual path of the file based on
40
+ # downcased name of the file,
41
+ #
42
+ # Example:
43
+ #
44
+ # Given `../resource_docs/geometric_and_topological_representation/RationalLRsurf.gif`
45
+ # return `../resource_docs/geometric_and_topological_representation/RationalLRSurf.gif`
46
+ # It will return nil if the file does not exist
47
+ def file_system_path(filepath, filename_cache)
48
+ dir = File.dirname(filepath)
49
+ filename = File.basename(filepath)
50
+
51
+ return filename_cache[dir][filepath.downcase] if filename_cache[dir]
52
+
53
+ files = Dir.glob(File.join(dir, "*")).map { |f| [f.downcase, f] }.to_h
54
+ filename_cache[dir] = files
55
+
56
+ filename_cache[dir][filepath.downcase]
57
+ end
58
+
34
59
  MAX_THREADS = 1 #[2, Concurrent.processor_count].max * 2
35
60
  MAX_QUEUE_SIZE = MAX_THREADS * 4
36
61
  # https://github.com/ruby-concurrency/concurrent-ruby/blob/master/docs-source/thread_pools.md
@@ -42,6 +67,7 @@ MAX_QUEUE_SIZE = MAX_THREADS * 4
42
67
  # )
43
68
 
44
69
  files = all_express_files(stepmod_dir)
70
+ filename_cache = {}
45
71
 
46
72
  files.each do |file|
47
73
  puts "#{Thread.current.object_id}: Processing #{file}"
@@ -60,13 +86,14 @@ files.each do |file|
60
86
 
61
87
  result[:images_references].each do |source, destination|
62
88
  source_path = File.join(stepmod_dir, "data", source)
89
+ system_source_path = file_system_path(source_path, filename_cache)
63
90
  destination_path = File.join(File.dirname(file), destination)
64
91
 
65
92
  puts "#{Thread.current.object_id}: Starting to copy file from #{source_path} to #{destination_path}"
66
- next if File.exist?(destination_path) || !File.exist?(source_path)
93
+ next if !system_source_path
67
94
 
68
- FileUtils.cp(source_path, destination_path)
69
- puts "#{Thread.current.object_id}: Done copying #{source_path} to #{destination_path}"
95
+ FileUtils.cp(system_source_path, destination_path)
96
+ puts "#{Thread.current.object_id}: Done copying #{system_source_path} to #{destination_path}"
70
97
  end
71
98
 
72
99
  puts "#{Thread.current.object_id}: Done processing #{File.basename(file)} => #{annotated_file_path}."
@@ -1,5 +1,5 @@
1
1
  module Stepmod
2
2
  module Utils
3
- VERSION = "0.3.33".freeze
3
+ VERSION = "0.3.34".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stepmod-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.33
4
+ version: 0.3.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.