Class: Dependency::Graph
- Inherits:
-
Object
- Object
- Dependency::Graph
- Defined in:
- lib/dependencyswapper/graph.rb
Instance Attribute Summary collapse
-
#podfilelock_path ⇒ Object
readonly
Returns the value of attribute podfilelock_path.
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(options) ⇒ Graph
constructor
A new instance of Graph.
Constructor Details
#initialize(options) ⇒ Graph
Returns a new instance of Graph.
15 16 17 18 19 20 21 22 |
# File 'lib/dependencyswapper/graph.rb', line 15 def initialize() @podfilelock_path = .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 |
Instance Attribute Details
#podfilelock_path ⇒ Object (readonly)
Returns the value of attribute podfilelock_path.
9 10 11 |
# File 'lib/dependencyswapper/graph.rb', line 9 def podfilelock_path @podfilelock_path end |
Class Method Details
.perform(options) ⇒ Object
11 12 13 |
# File 'lib/dependencyswapper/graph.rb', line 11 def self.perform() new().perform end |
Instance Method Details
#generate ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# 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 |