Skip to content
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

adds FromReader function #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

darwayne
Copy link

This adds the ability for a user to generate a collection directly from a reader

@codecov
Copy link

codecov bot commented May 13, 2022

Codecov Report

Merging #46 (1bc5515) into master (91e5499) will decrease coverage by 0.29%.
The diff coverage is 72.72%.

@@            Coverage Diff             @@
##           master      #46      +/-   ##
==========================================
- Coverage   99.29%   99.00%   -0.30%     
==========================================
  Files          43       43              
  Lines        1981     2003      +22     
==========================================
+ Hits         1967     1983      +16     
- Misses          7       10       +3     
- Partials        7       10       +3     
Impacted Files Coverage Δ
stix.go 98.53% <72.72%> (-1.09%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 91e5499...1bc5515. Read the comment docs.

@@ -918,6 +920,43 @@ func (c *Collection) getObject(typ STIXType, id Identifier) interface{} {
return obj
}

func FromReader(reader io.Reader, opts ...CollectionOption) (*Collection, error) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add documentation to this function since it's exported.

collection := New(opts...)
buff := bufio.NewReader(reader)
piece, err := buff.Peek(10)
if err != nil && !(err == io.EOF || err == bufio.ErrBufferFull) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests for this since it's checking for specific error cases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants