-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for adding subprojects #172
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b738fd7
[Constants] Add file types for xcodeproj and xctest
fabiopelosin a522fda
[Object] Style
fabiopelosin 65de2e0
[AbstractObjectAttribute] Style
fabiopelosin 72009be
[AbstractObjectAttribute] Factor out name conversion
fabiopelosin 06ce4d2
[AbstractObjectAttribute] Validate the keys of reference by keys attr…
fabiopelosin ac344cd
[ObjectDictionary] Style and docs
fabiopelosin 1047a69
[ObjectDictionary] Complete implementation
fabiopelosin c9200e3
[Constants] Add support for mdimporter adn octest
fabiopelosin 2387ccd
[FileReferencesFactory] Add support for adding subprojects
fabiopelosin c80a17c
[Changelog]
fabiopelosin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module Xcodeproj | ||
class Project | ||
module Object | ||
# Converts between camel case names used in the xcodeproj plist files | ||
# and the ruby symbols used to represent them. | ||
# | ||
module NameHelper | ||
# @return [String] The plist equivalent of the given Ruby name. | ||
# | ||
# @param [Symbol, String] name | ||
# The name to convert | ||
# | ||
# @param [Symbol, Nil] type | ||
# The type of conversion. Pass `nil` for normal camel case and | ||
# `:lower` for camel case starting with a lower case letter. | ||
# | ||
# @example | ||
# NameHelper.convert_to_plist(:project_ref) #=> ProjectRef | ||
# | ||
def self.convert_to_plist(name, type = nil) | ||
case name | ||
when :remote_global_id_string | ||
'remoteGlobalIDString' | ||
else | ||
if type == :lower | ||
cache = self.plist_cache[:lower] ||= {} | ||
cache[name] ||= name.to_s.camelize(:lower) | ||
else | ||
cache = self.plist_cache[:normal] ||= {} | ||
cache[name] ||= name.to_s.camelize() | ||
end | ||
end | ||
end | ||
|
||
# @return [Symbol] The Ruby equivalent of the given plist name. | ||
# | ||
# @param [String] name | ||
# The name to convert | ||
# | ||
# @example | ||
# NameHelper.convert_to_ruby('ProjectRef') #=> :project_ref | ||
# | ||
def self.convert_to_ruby(name) | ||
name.to_s.underscore.to_sym | ||
end | ||
|
||
# @return [Hash] A cache for the conversion to the Plist format. | ||
# | ||
# @note A cache is used because this operation is performed for each | ||
# attribute of the project when it is saved and caching it has | ||
# an important performance benefit. | ||
# | ||
def self.plist_cache | ||
@plist_cache ||= {} | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proliferation of ‘helpers’ is ok, but they should be named more semantically. If this helper is responsible for changing case of a string, then I don’t think
NameHelper
really clarifies that. Also, ‘name’ doesn’t seem to be appropriate, isn’t it more like ‘keys’ ?So how about something like
PlistKeyCaseConverter
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@irrationalfab ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is not about keys only but also the attributes of the objects.
PlistCaseConverter
works for meThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, maybe just
CaseConverter
then? ThePlist
part in my suggestion was about the ‘keys being those in the plist’.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍