Top Level Namespace

Defined Under Namespace

Modules: CheckXcodeXmls Classes: Options, Parser, ShellAdapter, Storyboard, XcodeXml, Xib

Constant Summary collapse

SCRIPT_NAME =
'check-xcode-xmls'.freeze

Instance Method Summary collapse

Instance Method Details

#find_files(ignore_regex_string, base_path, extension) ⇒ Object

Convenience utilities.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/check_xcode_xmls/helpers.rb', line 49

def find_files(ignore_regex_string, base_path, extension)
  file_paths = []
  ignore_regex = Regexp.new(ignore_regex_string) unless ignore_regex_string.nil?
  # puts ignore_regex
  Find.find(base_path) do |path|
    next if File.directory? path
    next if path !~ extension
    if ignore_regex
      next if path =~ ignore_regex
    end

    file_paths << path
  end
  file_paths
end

#parse_xml(check_constraints_identifiers, check_use_autolayout, file) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/check_xcode_xmls/helpers.rb', line 66

def parse_xml(
  check_constraints_identifiers,
  check_use_autolayout,
  file
)
  string = File.open(file, 'r:UTF-8').read
  doc = Nokogiri::XML(string)
  # puts doc.xpath('document').attribute('type')
  result = []

  [Xib,
   Storyboard].each do |item|

    next if file !~ item.extension

    if check_constraints_identifiers
      constraintsValues = item.search_constraints_without_identifiers(file, doc.xpath('document'))
      result += constraintsValues unless constraintsValues.nil?
    end

    if check_use_autolayout
      autolayoutValue = item.check_if_file_uses_autolayout(file, doc.xpath('document'))
      result += autolayoutValue unless autolayoutValue.nil?
    end
  end
  # result = search_constraints_without_identifiers(file, doc.xpath('document'))
  result
end