stepmod-utils 0.3.32 → 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: 0afdaf402a24b51d04d1e128027aad7192606c0861c8f7868bf7495fe4dac2b8
4
- data.tar.gz: f55407b9bd0f6552788fb04908faa513eb337f243c61d1c71a86b16c0097b4b2
3
+ metadata.gz: 5d4cd3a24127e1903a040a5edaa734ccef3adb17b65cce4c213fdcbf3d13ea5a
4
+ data.tar.gz: fe17db00fa97f748853ed5c0de867222a5d5ba16b3c2256a498abe20814d7694
5
5
  SHA512:
6
- metadata.gz: 9f19dcf25d9a16f6be95e7bd26a5358bc392c34757ab691c50a20cc06c052f3bae136bc7ba7a3d77ba927dcadb1857c8bd860d99e141bce26d8f8701ce8245dd
7
- data.tar.gz: 4119a6dcdbc640e6d9bfbbd1d23c983847dd2819a24c10e2539e9e69d4d654e61d349f609b9408180c47c3c19ef2d8c68fee0a424d30c53667023791dd575bce
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,11 +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
- next if File.exist?(destination_path) || !File.exist?(source_path)
92
+ puts "#{Thread.current.object_id}: Starting to copy file from #{source_path} to #{destination_path}"
93
+ next if !system_source_path
66
94
 
67
- FileUtils.cp(source_path, destination_path)
95
+ FileUtils.cp(system_source_path, destination_path)
96
+ puts "#{Thread.current.object_id}: Done copying #{system_source_path} to #{destination_path}"
68
97
  end
69
98
 
70
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.32".freeze
3
+ VERSION = "0.3.34".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stepmod-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.32
4
+ version: 0.3.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-05 00:00:00.000000000 Z
11
+ date: 2023-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby