Skip to content

Commit

Permalink
[Config] Append the extension to included xcconfigs
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopelosin committed Jul 1, 2013
1 parent c5948a6 commit f5631aa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
21 changes: 19 additions & 2 deletions lib/xcodeproj/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ def ==(other)
# @return [String] The serialized internal data.
#
def to_s(prefix = nil)
[includes.map { |i| "#include \"#{i}\""} +
to_hash(prefix).sort_by(&:first).map { |k, v| "#{k} = #{v}" }].join("\n")
include_lines = includes.map { |path| "#include \"#{normalized_xcconfig_path(path)}\""}
settings = to_hash(prefix).sort_by(&:first).map { |k, v| "#{k} = #{v}" }
[include_lines + settings].join("\n")
end

# Writes the serialized representation of the internal data to the given
Expand Down Expand Up @@ -266,6 +267,22 @@ def extract_key_value(line)
end
end

# Normalizes the given path to an xcconfing file to be used in includes,
# appending the extension if necessary.
#
# @param [String] path
# The path of the file which will be included in the xcconfig.
#
# @return [String] The normalized path.
#
def normalized_xcconfig_path(path)
if File.extname(path) == '.xcconfig'
path
else
"#{path}.xcconfig"
end
end

#-------------------------------------------------------------------------#

end
Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

require 'rubygems'
require 'bacon'
require 'pretty_bacon'
require 'bacon'
require 'mocha-on-bacon'
require 'pretty_bacon'
require 'pathname'

ROOT = Pathname.new(File.expand_path('../../', __FILE__))
Expand Down

0 comments on commit f5631aa

Please sign in to comment.