class Dependency::Graph
Attributes
podfilelock_path[R]
Public Class Methods
new(options)
click to toggle source
# File lib/dependencyswapper/graph.rb, line 15 def initialize(options) @podfilelock_path = options.fetch(:podfilelock_path) @pods = Array.new() if !File.exist?(@podfilelock_path) puts "The Podfile.lock is missing. We will run pod install so we can generate the dependency graph to swap dependencies." system("pod install") end end
perform(options)
click to toggle source
# File lib/dependencyswapper/graph.rb, line 11 def self.perform(options) new(options).perform end
Public Instance Methods
generate()
click to toggle source
# File lib/dependencyswapper/graph.rb, line 24 def generate pod = nil #Read line by line the Podfile.lock IO.readlines(@podfilelock_path).each do |line| #If we are generating the depdency map of a pod, and we have a pod, # and the line includes a depdendency(we know cause there is a parenthesis determining a version in it), # then we add the dependency name to the pod.dependencies if pod && (line.include?("=") || line.include?("~")) dependency = line.string_between_markers("- ", " (") pod.dependencies.push(dependency) end #At this point we found a Pod, lets build it and add its dependencies to it. We know we found a pod since #the podfile.lock will show only the version. unless line.include?("=") || line.include?("~") # We are going to generate a new pod but we are carrying one already, we will push it to the pods array first before we clear the variable with a new pod. if pod != nil @pods.push(pod) end name = line.string_between_markers("- ", " (") version = line.string_between_markers("(", ")") pod = Dependency::Pod.new({ :name => name, :version => version }) end unless line.include?("(") || line.include?(":") return @pods end end return @pods end