Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
a6a764f7
Commit
a6a764f7
authored
Oct 02, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor initialize method for clarity
parent
b3d61832
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
+20
-11
lib/gitlab/ldap/dn.rb
lib/gitlab/ldap/dn.rb
+20
-11
No files found.
lib/gitlab/ldap/dn.rb
View file @
a6a764f7
...
...
@@ -34,24 +34,33 @@ module Gitlab
# so storing the dn as an escaped String and parsing parts as required
# with a state machine seems sensible.
def
initialize
(
*
args
)
buffer
=
StringIO
.
new
args
.
each_index
do
|
index
|
buffer
<<
"="
if
index
.
odd?
buffer
<<
","
if
index
.
even?
&&
index
!=
0
if
args
.
length
>
1
initialize_array
(
args
)
else
initialize_string
(
args
[
0
])
end
end
arg
=
args
[
index
]
def
initialize_array
(
args
)
buffer
=
StringIO
.
new
buffer
<<
if
index
<
args
.
length
-
1
||
index
.
odd?
self
.
class
.
escape
(
arg
)
else
arg
args
.
each_with_index
do
|
arg
,
index
|
if
index
.
even?
# key
buffer
<<
","
if
index
>
0
buffer
<<
arg
else
# value
buffer
<<
"="
buffer
<<
self
.
class
.
escape
(
arg
)
end
end
@dn
=
buffer
.
string
end
def
initialize_string
(
arg
)
@dn
=
arg
.
to_s
end
##
# Parse a DN into key value pairs using ASN from
# http://tools.ietf.org/html/rfc2253 section 3.
...
...
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