Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
ef4dfb29
Commit
ef4dfb29
authored
Nov 06, 2014
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper method Target#c99ext_identifier
parent
93ddfa2a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
target.rb
lib/cocoapods/target.rb
+16
-0
target_spec.rb
spec/unit/target_spec.rb
+15
-0
No files found.
lib/cocoapods/target.rb
View file @
ef4dfb29
...
...
@@ -177,5 +177,21 @@ module Pod
end
#-------------------------------------------------------------------------#
protected
# Transforms the given string into a valid +identifier+ after C99ext
# standard, so that it can be used in source code where escaping of
# ambiguous characters is not applicable.
#
# @param [String] name
# any name, which may contain leading numbers, spaces or invalid
# characters.
#
# @return [String]
#
def
c99ext_identifier
(
name
)
name
.
gsub
(
/^([0-9])/
,
'_\1'
).
gsub
(
/[^a-zA-Z0-9_]/
,
'_'
)
end
end
end
spec/unit/target_spec.rb
View file @
ef4dfb29
...
...
@@ -3,5 +3,20 @@ require File.expand_path('../../spec_helper', __FILE__)
module
Pod
describe
Target
do
describe
'#c99ext_identifier'
do
before
do
@target
=
Target
.
new
end
it
'should mask, but keep leading numbers'
do
@target
.
send
(
:c99ext_identifier
,
'123BananaLib'
).
should
==
'_123BananaLib'
end
it
'should mask invalid chars'
do
@target
.
send
(
:c99ext_identifier
,
'iOS-App BânánàLïb'
).
should
==
'iOS_App_B_n_n_L_b'
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment