Class: Umbrella::XcodeProjParser

Inherits:
Object
  • Object
show all
Defined in:
lib/umbrellalinter/xcodeprojparser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ XcodeProjParser



13
14
15
16
17
18
19
# File 'lib/umbrellalinter/xcodeprojparser.rb', line 13

def initialize(options)
  @import_files = options.fetch(:import_files)
  @fix = options.fetch(:fix)
  @umbrella_header = options.fetch(:umbrella_header)
  @framework_target_name = options.fetch(:framework_target_name)
  @project_files = {}
end

Instance Attribute Details

#fixObject (readonly)

Returns the value of attribute fix.



7
8
9
# File 'lib/umbrellalinter/xcodeprojparser.rb', line 7

def fix
  @fix
end

#framework_target_nameObject (readonly)

Returns the value of attribute framework_target_name.



7
8
9
# File 'lib/umbrellalinter/xcodeprojparser.rb', line 7

def framework_target_name
  @framework_target_name
end

#import_filesObject (readonly)

Returns the value of attribute import_files.



7
8
9
# File 'lib/umbrellalinter/xcodeprojparser.rb', line 7

def import_files
  @import_files
end

#umbrella_headerObject (readonly)

Returns the value of attribute umbrella_header.



7
8
9
# File 'lib/umbrellalinter/xcodeprojparser.rb', line 7

def umbrella_header
  @umbrella_header
end

Class Method Details

.perform(options) ⇒ Object



9
10
11
# File 'lib/umbrellalinter/xcodeprojparser.rb', line 9

def self.perform(options)
  new(options).perform
end

Instance Method Details

#parseObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/umbrellalinter/xcodeprojparser.rb', line 21

def parse
  project_file_path = ""
  Dir["./**/project.pbxproj"].reject{ |f| f['./Pods'] }.each do |filename|
    project_file_path = filename
    break
  end
  IO.readlines(project_file_path).each do |line|
    if line.include? "in Headers"
      if line.include? "settings = {ATTRIBUTES = (Public"
        filename = line.split(/\/\* (.*?)in Headers \*\//)[1]
        @project_files[filename.chop] =  "Public"
      end
    end
  end
  Umbrella::Validator.new({
    :import_files => @import_files,
    :project_files => @project_files,
    :fix => @fix,
    :project_file_path => project_file_path,
    :umbrella_header => @umbrella_header,
    :framework_target_name => @framework_target_name
  }).validate
end