Module: Dependabot::Swift::XcodeFileHelpers
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/swift/xcode_file_helpers.rb
Constant Summary collapse
- XCODEPROJ_SUFFIX =
".xcodeproj/"- XCWORKSPACE_SUFFIX =
".xcworkspace/"- PACKAGE_RESOLVED =
"Package.resolved"
Class Method Summary collapse
Class Method Details
.extract_xcode_scope_dir(path) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dependabot/swift/xcode_file_helpers.rb', line 23 def self.extract_xcode_scope_dir(path) # Find the first occurrence of .xcodeproj/ or .xcworkspace/ xcodeproj_idx = path.index(XCODEPROJ_SUFFIX) xcworkspace_idx = path.index(XCWORKSPACE_SUFFIX) # Determine which match to use (earliest occurrence) match_idx = T.let(nil, T.nilable(Integer)) suffix_len = T.let(0, Integer) if xcodeproj_idx && (xcworkspace_idx.nil? || xcodeproj_idx < xcworkspace_idx) match_idx = xcodeproj_idx suffix_len = XCODEPROJ_SUFFIX.length elsif xcworkspace_idx match_idx = xcworkspace_idx suffix_len = XCWORKSPACE_SUFFIX.length end return nil if match_idx.nil? # Return path up to and including the suffix (minus trailing /) path[0, match_idx + suffix_len - 1] end |
.xcode_resolved_path?(path) ⇒ Boolean
16 17 18 19 20 |
# File 'lib/dependabot/swift/xcode_file_helpers.rb', line 16 def self.xcode_resolved_path?(path) return false unless path.end_with?(PACKAGE_RESOLVED) path.include?(XCODEPROJ_SUFFIX) || path.include?(XCWORKSPACE_SUFFIX) end |