Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Config] Sort by setting name when serliazing to a string.

  • Loading branch information...
commit 5c2489377b88e544b9a1d1c29a52b63ac8307287 1 parent 954b782
Eloy Durán alloy authored
Showing with 14 additions and 3 deletions.
  1. +5 −0 Rakefile
  2. +4 −3 lib/xcodeproj/config.rb
  3. +5 −0 spec/config_spec.rb
5 Rakefile
View
@@ -209,6 +209,11 @@ task :dump_xcodeproj => 'ext:cleanbuild' do
puts result.to_yaml
end
+desc 'Install dependencies'
+task :bootstrap do
+ sh 'bundle install'
+end
+
desc "Run all specs"
task :spec => 'spec:all'
7 lib/xcodeproj/config.rb
View
@@ -47,16 +47,17 @@ def initialize(xcconfig_hash_or_file = {})
# @!group Serialization
- # Serializes the internal data in the xcconfig format.
+ # Sorts the internal data by setting name and serializes it in the xcconfig
+ # format.
#
# @example
#
# config = Config.new('PODS_ROOT' => '"$(SRCROOT)/Pods"', 'OTHER_LDFLAGS' => '-lxml2')
- # config.to_s # => "PODS_ROOT = \"$(SRCROOT)/Pods\"\nOTHER_LDFLAGS = -lxml2"
+ # config.to_s # => "OTHER_LDFLAGS = -lxml2\nPODS_ROOT = \"$(SRCROOT)/Pods\""
#
# @return [String] The serialized internal data.
def to_s
- to_hash.map { |key, value| "#{key} = #{value}" }.join("\n")
+ to_hash.sort_by(&:first).map { |k, v| "#{k} = #{v}" }.join("\n")
end
# @return [void] Writes the serialized representation of the internal data
5 spec/config_spec.rb
View
@@ -50,6 +50,11 @@
@config.to_s.should.be.equal "OTHER_LDFLAGS = -framework Foundation"
end
+ it "sorts the internal data by setting name when serializing with #to_s" do
+ config = Xcodeproj::Config.new('Y' => '2', 'Z' => '3', 'X' => '1')
+ config.to_s.should == "X = 1\nY = 2\nZ = 3"
+ end
+
it "can be serialized with #to_hash" do
@config.to_hash.should.be.equal @hash
end
Please sign in to comment.
Something went wrong with that request. Please try again.