Skip to content

Commit

Permalink
[Refactor] Use a commented Regexp in Free-Spacing Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mrackwitz committed Nov 20, 2014
1 parent bc0b2d9 commit 7163b7a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/xcodeproj/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ module Xcodeproj
class Config
require 'set'

KEY_VALUE_PATTERN = /
(
[^=]+ # Any char, but not an assignment operator (non-greedy)
(?: # One or multiple conditional subscripts
\[
[^\]]* # The subscript key
(?:
= # The subscript comparison operator
[^\]]* # The subscript value
)?
\]
)*
)
\s+ # Whitespaces after the key (needed because subscripts
# always end with ']')
= # The assignment operator
(.*) # The value
/x

# @return [Hash{String => String}] The attributes of the settings file
# excluding frameworks, weak_framework and libraries.
#
Expand Down Expand Up @@ -294,7 +313,7 @@ def extract_include(line)
# entry is the value.
#
def extract_key_value(line)
match = line.match(/([^=]*?(?:\[[^\]]*=?[^\]]*\])*)\s+=(.*)/)
match = line.match(KEY_VALUE_PATTERN)
if match
key, value = match[1], match[2]
[key.strip, value.strip]
Expand Down

0 comments on commit 7163b7a

Please sign in to comment.