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
ac165121
Commit
ac165121
authored
Nov 20, 2019
by
Furkan Ayhan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace OpenStruct in Ansi2json converter
parent
69268559
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
5 deletions
+66
-5
lib/gitlab/ci/ansi2json/converter.rb
lib/gitlab/ci/ansi2json/converter.rb
+2
-5
lib/gitlab/ci/ansi2json/result.rb
lib/gitlab/ci/ansi2json/result.rb
+22
-0
spec/lib/gitlab/ci/ansi2json/result_spec.rb
spec/lib/gitlab/ci/ansi2json/result_spec.rb
+42
-0
No files found.
lib/gitlab/ci/ansi2json/converter.rb
View file @
ac165121
...
...
@@ -37,16 +37,13 @@ module Gitlab
flush_current_line
# TODO: replace OpenStruct with a better type
# https://gitlab.com/gitlab-org/gitlab/issues/34305
OpenStruct
.
new
(
Gitlab
::
Ci
::
Ansi2json
::
Result
.
new
(
lines:
@lines
,
state:
@state
.
encode
,
append:
append
,
truncated:
truncated
,
offset:
start_offset
,
size:
stream
.
tell
-
start_offset
,
total:
stream
.
size
stream:
stream
)
end
...
...
lib/gitlab/ci/ansi2json/result.rb
0 → 100644
View file @
ac165121
# frozen_string_literal: true
# Convertion result object class
module
Gitlab
module
Ci
module
Ansi2json
class
Result
attr_reader
:lines
,
:state
,
:append
,
:truncated
,
:offset
,
:size
,
:total
def
initialize
(
lines
:,
state
:,
append
:,
truncated
:,
offset
:,
stream
:)
@lines
=
lines
@state
=
state
@append
=
append
@truncated
=
truncated
@offset
=
offset
@size
=
stream
.
tell
-
offset
@total
=
stream
.
size
end
end
end
end
end
spec/lib/gitlab/ci/ansi2json/result_spec.rb
0 → 100644
View file @
ac165121
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Ci
::
Ansi2json
::
Result
do
let
(
:stream
)
{
StringIO
.
new
(
'hello'
)
}
let
(
:state
)
{
Gitlab
::
Ci
::
Ansi2json
::
State
.
new
(
nil
,
stream
.
size
)
}
let
(
:offset
)
{
0
}
let
(
:params
)
do
{
lines:
[],
state:
state
,
append:
false
,
truncated:
false
,
offset:
offset
,
stream:
stream
}
end
subject
{
described_class
.
new
(
params
)
}
describe
'#size'
do
before
do
stream
.
seek
(
5
)
# move stream cursor to the end
end
context
'when offset is at the start'
do
let
(
:offset
)
{
0
}
it
'returns the full size'
do
expect
(
subject
.
size
).
to
eq
(
5
)
end
end
context
'when offset is not zero'
do
let
(
:offset
)
{
2
}
it
'returns the remaining size'
do
expect
(
subject
.
size
).
to
eq
(
3
)
end
end
end
describe
'#total'
do
it
'returns size of stread'
do
expect
(
subject
.
total
).
to
eq
(
5
)
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