Class: Xcodeproj::Project
- Inherits:
-
Object
- Object
- Xcodeproj::Project
- Defined in:
- lib/xccache/xcodeproj/pkg.rb,
lib/xccache/xcodeproj/group.rb,
lib/xccache/xcodeproj/target.rb,
lib/xccache/xcodeproj/project.rb,
lib/xccache/xcodeproj/build_configuration.rb,
lib/xccache/xcodeproj/pkg_product_dependency.rb,
lib/xccache/xcodeproj/file_system_synchronized_root_group.rb
Defined Under Namespace
Modules: Object
Constant Summary collapse
Instance Method Summary collapse
- #add_pkg(hash) ⇒ Object
- #add_xccache_pkg ⇒ Object
- #dir ⇒ Object
- #display_name ⇒ Object
- #get_pkg(name) ⇒ Object
- #get_target(name) ⇒ Object
- #has_pkg?(hash) ⇒ Boolean
- #has_xccache_pkg? ⇒ Boolean
- #non_xccache_pkgs ⇒ Object
- #pkgs ⇒ Object
- #relative_path ⇒ Object
- #remove_pkgs(&block) ⇒ Object
- #xccache_config_group ⇒ Object
- #xccache_pkg ⇒ Object
Instance Method Details
#add_pkg(hash) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/xccache/xcodeproj/project.rb', line 40 def add_pkg(hash) pkg_hash = XCCache::Lockfile::Pkg.from_h(hash) pkg_hash["relative_path"] = pkg_hash.relative_path_from_dir(dir).to_s if pkg_hash.key == "path_from_root" Log.info("Add package #{pkg_hash.id.bold} to project #{display_name.bold}") cls = pkg_hash.local? ? XCLocalSwiftPackageReference : XCRemoteSwiftPackageReference ref = new(cls) custom_keys = ["path_from_root"] pkg_hash.each { |k, v| ref.send("#{k}=", v) unless custom_keys.include?(k) } root_object.package_references << ref ref end |
#add_xccache_pkg ⇒ Object
53 54 55 56 |
# File 'lib/xccache/xcodeproj/project.rb', line 53 def add_xccache_pkg sandbox_path = XCCache::Config.instance.spm_proxy_sandbox add_pkg("relative_path" => sandbox_path.relative_path_from(path.parent).to_s) end |
#dir ⇒ Object
15 16 17 |
# File 'lib/xccache/xcodeproj/project.rb', line 15 def dir path.parent end |
#display_name ⇒ Object
7 8 9 |
# File 'lib/xccache/xcodeproj/project.rb', line 7 def display_name relative_path.to_s end |
#get_pkg(name) ⇒ Object
69 70 71 |
# File 'lib/xccache/xcodeproj/project.rb', line 69 def get_pkg(name) pkgs.find { |p| p.slug == name } end |
#get_target(name) ⇒ Object
65 66 67 |
# File 'lib/xccache/xcodeproj/project.rb', line 65 def get_target(name) targets.find { |t| t.name == name } end |
#has_pkg?(hash) ⇒ Boolean
31 32 33 34 |
# File 'lib/xccache/xcodeproj/project.rb', line 31 def has_pkg?(hash) pkg_hash = XCCache::Lockfile::Pkg.from_h(hash) pkgs.any? { |p| p.id == pkg_hash.id } end |
#has_xccache_pkg? ⇒ Boolean
36 37 38 |
# File 'lib/xccache/xcodeproj/project.rb', line 36 def has_xccache_pkg? pkgs.any?(&:xccache_pkg?) end |
#non_xccache_pkgs ⇒ Object
27 28 29 |
# File 'lib/xccache/xcodeproj/project.rb', line 27 def non_xccache_pkgs pkgs.reject(&:xccache_pkg?) end |
#pkgs ⇒ Object
19 20 21 |
# File 'lib/xccache/xcodeproj/project.rb', line 19 def pkgs root_object.package_references end |
#relative_path ⇒ Object
11 12 13 |
# File 'lib/xccache/xcodeproj/project.rb', line 11 def relative_path @relative_path ||= path.relative_path_from(Pathname(".").) end |
#remove_pkgs(&block) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/xccache/xcodeproj/project.rb', line 58 def remove_pkgs(&block) pkgs.select(&block).each do |pkg| Log.info("(-) Remove #{pkg.display_name.red} from package refs of project #{display_name.bold}") pkg.remove_from_project end end |
#xccache_config_group ⇒ Object
73 74 75 |
# File 'lib/xccache/xcodeproj/project.rb', line 73 def xccache_config_group self["xccache.config"] || new_group("xccache.config") end |
#xccache_pkg ⇒ Object
23 24 25 |
# File 'lib/xccache/xcodeproj/project.rb', line 23 def xccache_pkg pkgs.find(&:xccache_pkg?) end |