Class: CocoapodsCatalystSupport::Podfile

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-catalyst-support/command_helpers.rb

Instance Method Summary collapse

Instance Method Details

#ios_podsObject



16
17
18
# File 'lib/cocoapods-catalyst-support/command_helpers.rb', line 16

def ios_pods
  lookup 'ios'
end

#lookup(key) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/cocoapods-catalyst-support/command_helpers.rb', line 40

def lookup key
  results = scan(/^[\s]*#{key}\s+[('|")][\S]*[('|")]/).map do |match|
    match.gsub!('/\s+/', ' ' )
    pod_name = match.split(' ')[1]
    pod_name.gsub! /[('|")]/, ''
    pod_name
  end
  return results
end

#mac_podsObject



20
21
22
# File 'lib/cocoapods-catalyst-support/command_helpers.rb', line 20

def mac_pods
  lookup 'macos'
end

#podsObject



12
13
14
# File 'lib/cocoapods-catalyst-support/command_helpers.rb', line 12

def pods
  lookup 'pod'
end

#validateObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cocoapods-catalyst-support/command_helpers.rb', line 24

def validate
  errors = []
  ios_failures = ios_pods.filter do |pod| !pods.include? pod end
  unless ios_failures.empty?
    errors << "- Unrecognized dependencies for iOS:\n#{ios_failures.map do |pod| "  + #{pod}" end.join("\n") }".red
  end
  
  mac_failures = mac_pods.filter do |pod| !pods.include? pod end
  unless mac_failures.empty?
    errors << "- Unrecognized dependencies for macOS:\n#{mac_failures.map do |pod| "  + #{pod}" end.join("\n") }".red
  end
  
  return errors
end