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
1
Merge Requests
1
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
nexedi
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
Hide 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
...
@@ -34,24 +34,33 @@ module Gitlab
# so storing the dn as an escaped String and parsing parts as required
# so storing the dn as an escaped String and parsing parts as required
# with a state machine seems sensible.
# with a state machine seems sensible.
def
initialize
(
*
args
)
def
initialize
(
*
args
)
buffer
=
StringIO
.
new
if
args
.
length
>
1
initialize_array
(
args
)
args
.
each_index
do
|
index
|
else
buffer
<<
"="
if
index
.
odd?
initialize_string
(
args
[
0
])
buffer
<<
","
if
index
.
even?
&&
index
!=
0
end
end
arg
=
args
[
index
]
def
initialize_array
(
args
)
buffer
=
StringIO
.
new
buffer
<<
if
index
<
args
.
length
-
1
||
index
.
odd?
args
.
each_with_index
do
|
arg
,
index
|
self
.
class
.
escape
(
arg
)
if
index
.
even?
# key
else
buffer
<<
","
if
index
>
0
arg
buffer
<<
arg
end
else
# value
buffer
<<
"="
buffer
<<
self
.
class
.
escape
(
arg
)
end
end
end
@dn
=
buffer
.
string
@dn
=
buffer
.
string
end
end
def
initialize_string
(
arg
)
@dn
=
arg
.
to_s
end
##
##
# Parse a DN into key value pairs using ASN from
# Parse a DN into key value pairs using ASN from
# http://tools.ietf.org/html/rfc2253 section 3.
# 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