Module: Pod::Command::Links
- Defined in:
- lib/pod/links.rb
Overview
Links utility that provides functionality around managing CocoaPod links
Constant Summary collapse
- REGISTERED_DB =
Defines the path where the links database is stored (e.g. from pod link)
File.('~/.cocoapods/plugins/link/registered.json')
- LINKED_DB =
Defines the path where per pod links are stored (e.g. from pod link <foo> command)
File.('~/.cocoapods/plugins/link/linked.json')
Class Method Summary collapse
-
.get_link(name) ⇒ Object
Entry point for the ‘pod` hook to check if the current pod project should use a linked pod of installed from the pod requirements.
-
.link(pod) ⇒ Object
Creates a link for the given pod into the current project.
-
.list(linked = false) ⇒ Object
List the links.
-
.print(message) ⇒ Object
Prints a formatted message with the Pod Links prefix.
-
.register ⇒ Object
Register a pod for local development in the current working directory.
-
.unlink(pod) ⇒ Object
Will unlink the give pod from the current pod project.
-
.unregister ⇒ Object
Unregister a pod.
Class Method Details
.get_link(name) ⇒ Object
Entry point for the ‘pod` hook to check if the current pod project should use a linked pod of installed from the pod requirements. In order for a link to be returned the following must hold true:
-
The pod must be registered (e.g. pod link)
-
The current pod project must have linked the registered link (e.g. pod link <name>)
120 121 122 123 124 125 |
# File 'lib/pod/links.rb', line 120 def self.get_link(name) if self.linked_pods.include?(name) return self.get_registered_link name end return nil end |
.link(pod) ⇒ Object
Creates a link for the given pod into the current project. The pod must be registered using ‘pod link`
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/pod/links.rb', line 51 def self.link(pod) # only allow registered links to be used registered_link = self.get_registered_link pod if registered_link.nil? Command::help! "Pod '#{pod}'' is not registered. Did you run `pod link` from the #{pod} directory?" end # add the linked pod linked_pods = [pod] if self.linked_db.has_key?(Dir.pwd) linked_pods = linked_pods.concat self.linked_db[Dir.pwd]['pods'] end self.print "Adding link to '#{pod}' > #{registered_link['path']}" self.write_db(LINKED_DB, self.linked_db, { Dir.pwd => { 'pods' => linked_pods.uniq } }) # install pod from link Pod::Command::Install.run(CLAide::ARGV.new ["--no-repo-update"]) end |
.list(linked = false) ⇒ Object
List the links.
-
If linked is true then list the linked pods in the current project
-
Id linked is false then list the registered links
135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/pod/links.rb', line 135 def self.list(linked = false) if linked self.print "Linked pods:" self.linked_pods.each do |pod| self.print "* #{pod}" end else self.print "Registered pods:" self.registerd_db.each do |pod, link| self.print "* #{pod} > #{link['path']}" end end end |
.print(message) ⇒ Object
Prints a formatted message with the Pod Links prefix
152 153 154 |
# File 'lib/pod/links.rb', line 152 def self.print() UI.puts("Pod #{'Links'.cyan} #{}") end |
.register ⇒ Object
Register a pod for local development in the current working directory. This working directory must have a .podspec defining the pod
26 27 28 29 30 31 32 33 |
# File 'lib/pod/links.rb', line 26 def self.register self.print "Registering '#{self.podspec.name}' > #{Dir.pwd}" self.write_db(REGISTERED_DB, self.registerd_db, { self.podspec.name => { "path" => Dir.pwd } }) end |
.unlink(pod) ⇒ Object
Will unlink the give pod from the current pod project
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/pod/links.rb', line 80 def self.unlink(pod) if self.linked_db.has_key?(Dir.pwd) linked_pods = self.linked_db[Dir.pwd]['pods'] linked_pods.delete(pod) # # Update databased based on link state # if links exist, update list of links # if links do not exist, remove entry # self.print "Removing link to '#{pod}'" if linked_pods.empty? db = self.linked_db db.delete(Dir.pwd) self.write_db(LINKED_DB, db) else self.write_db(LINKED_DB, self.linked_db, { Dir.pwd => { 'pods' => linked_pods } }) end # install pod from repo Pod::Command::Install.run(CLAide::ARGV.new []) end end |
.unregister ⇒ Object
Unregister a pod
38 39 40 41 42 43 |
# File 'lib/pod/links.rb', line 38 def self.unregister self.print "Unregistering '#{self.podspec.name}' > #{Dir.pwd}" db = self.registerd_db db.delete(self.podspec.name) self.write_db(REGISTERED_DB, db) end |