Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Rename to_plist methods on AbstractObject and ObjectDictionary #59

Merged
merged 1 commit into from

3 participants

Michele Fabio Pelosin Eloy Durán
Michele
Collaborator

Since the to_plist methods don't actually create a plist you can write directly to a file, it should not be named as such. Fixes CocoaPods/cocoapods.github.com#11

Note: This breaks backwards compatibility with anyone using to_plist since the method has been removed all together. Not sure if there's a depreciation plan for this.

Fabio Pelosin
Owner

Thanks for the pull! It looks good and can be merged as soon as the dust of the CocoaPods 0.17 release settles.

Fabio Pelosin fabiopelosin merged commit 33e4d41 into from
Fabio Pelosin
Owner

Just tested and CocoaPods is not affected by the changes of this patch.

Michele mtitolo referenced this pull request in CocoaPods/cocoapods.github.com
Closed

AbstractObject to_plist doesn't actually create a plist #11

Eloy Durán
Owner

@mtitolo Thanks for you contributions! You now have commit access to all the CocoaPods tools repos and I’m also sending you an invitation to our Campfire channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 26, 2013
  1. Michele

    Renamed to_plist to to_hash since it will always return a hash, and n…

    mtitolo authored
    …ot a valid plist string (XML, JSON or otherwise).
This page is out of date. Refresh to see the latest.
8 Gemfile.lock
View
@@ -2,14 +2,14 @@ PATH
remote: .
specs:
xcodeproj (0.5.2)
- activesupport (~> 3.2.6)
+ activesupport (~> 3.2.13)
colored (~> 1.2)
GEM
remote: http://rubygems.org/
specs:
- activesupport (3.2.12)
- i18n (~> 0.6)
+ activesupport (3.2.13)
+ i18n (= 0.6.1)
multi_json (~> 1.0)
bacon (1.2.0)
colored (1.2)
@@ -21,7 +21,7 @@ GEM
simplecov (>= 0.7)
thor
github-markup (0.7.5)
- i18n (0.6.4)
+ i18n (0.6.1)
kicker (2.6.1)
listen
listen (0.7.3)
8 lib/xcodeproj/project.rb
View
@@ -186,12 +186,12 @@ def new_from_plist(uuid, objects_by_uuid_plist, root_object = false)
end
end
- # @return [Hash] The plist representation of the project.
+ # @return [Hash] The hash representation of the project.
#
def to_hash
plist = {}
objects_dictionary = {}
- objects.each { |obj| objects_dictionary[obj.uuid] = obj.to_plist }
+ objects.each { |obj| objects_dictionary[obj.uuid] = obj.to_hash }
plist['objects'] = objects_dictionary
plist['archiveVersion'] = archive_version.to_s
plist['objectVersion'] = object_version.to_s
@@ -200,8 +200,6 @@ def to_hash
plist
end
- alias :to_plist :to_hash
-
# Converts the objects tree to a hash substituting the hash
# of the referenced to their UUID reference. As a consequence the hash of
# an object might appear multiple times and the information about their
@@ -251,7 +249,7 @@ def pretty_print
def save_as(projpath)
projpath = projpath.to_s
FileUtils.mkdir_p(projpath)
- Xcodeproj.write_plist(to_plist, File.join(projpath, 'project.pbxproj'))
+ Xcodeproj.write_plist(to_hash, File.join(projpath, 'project.pbxproj'))
end
#-------------------------------------------------------------------------#
13 lib/xcodeproj/project/object.rb
View
@@ -286,11 +286,17 @@ def object_with_uuid(uuid, objects_by_uuid_plist, attribute)
"Please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new"
end
+ # Returns a cascade representation of the object with UUIDs.
+ #
+ # @return [Hash] a hash representation of the project.
+ #
+ # @visibility public
+ #
# @note the key for simple and to_one attributes usually appears only
# if there is a value. To-many keys always appear with an empty
# array.
#
- def to_plist
+ def to_hash
plist = {}
plist['isa'] = isa
@@ -311,12 +317,11 @@ def to_plist
references_by_keys_attributes.each do |attrb|
list = attrb.get_value(self)
- plist[attrb.plist_name] = list.map { |dictionary| dictionary.to_plist }
+ plist[attrb.plist_name] = list.map { |dictionary| dictionary.to_hash }
end
plist
end
- alias :to_hash :to_plist
# Returns a cascade representation of the object without UUIDs.
#
@@ -378,7 +383,7 @@ def pretty_print
# @!group Object methods
def ==(other)
- other.is_a?(AbstractObject) && self.to_plist == other.to_plist
+ other.is_a?(AbstractObject) && self.to_hash == other.to_hash
end
def <=>(other)
2  lib/xcodeproj/project/object_dictionary.rb
View
@@ -108,7 +108,7 @@ def delete(key)
#
# @return [Hash<String => String>]
#
- def to_plist
+ def to_hash
result = {}
each { |key, obj| result[key] = obj.uuid }
result
2  spec/project/object_dictionary_spec.rb
View
@@ -21,7 +21,7 @@ module ProjectSpecs
it "returns the plist representation of the dictionary" do
project_ref_uuid = @dict['projectRef'].uuid
product_group_uuid = @dict['productGroup'].uuid
- @dict.to_plist.should == {
+ @dict.to_hash.should == {
'projectRef' => project_ref_uuid,
'productGroup' => product_group_uuid,
}
4 spec/project/object_spec.rb
View
@@ -83,7 +83,7 @@ module ProjectSpecs
it "merges the class name into the plist representation" do
@object.isa.should == 'PBXFileReference'
- @object.to_plist['isa'].should == 'PBXFileReference'
+ @object.to_hash['isa'].should == 'PBXFileReference'
end
it "sorts by UUID" do
@@ -173,7 +173,7 @@ module ProjectSpecs
it "can serialize itself to a plist" do
@object.name = 'AnObject'
@object.source_tree = 'SOURCE_ROOT'
- @object.to_plist.should == {
+ @object.to_hash.should == {
"isa" => "PBXFileReference",
"name" => "AnObject",
"sourceTree" => "SOURCE_ROOT",
6 spec/project_spec.rb
View
@@ -107,7 +107,7 @@ module ProjectSpecs
#
it "can regenerate the EXACT plist that initialized it" do
plist = Xcodeproj.read_plist(fixture_path("Sample Project/Cocoa Application.xcodeproj/project.pbxproj"))
- generated = @project.to_plist
+ generated = @project.to_hash
diff = Xcodeproj::Differ.diff(generated, plist)
diff.should.be.nil
end
@@ -120,7 +120,7 @@ module ProjectSpecs
obj = @project.new_from_plist(uuid, objects_by_uuid_plist)
attrb = PBXFileReference.simple_attributes.find { |a| a.name == :include_in_index }
attrb.default_value.should == '1'
- obj.to_plist.should == expected
+ obj.to_hash.should == expected
end
extend SpecHelper::TemporaryDirectory
@@ -156,7 +156,7 @@ module ProjectSpecs
"sourceTree" => "SOURCE_ROOT",
"includeInIndex" => "1"
}
- obj.to_plist.should == expected
+ obj.to_hash.should == expected
end
it "generates new UUIDs" do
Something went wrong with that request. Please try again.