• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fogfish / iq / 19150632324

06 Nov 2025 09:35PM UTC coverage: 40.252%. First build
19150632324

Pull #26

github

fogfish
improve ci/cd auto versioning
Pull Request #26: Compose AI workflow within the shell

1095 of 2628 new or added lines in 34 files covered. (41.67%)

1119 of 2780 relevant lines covered (40.25%)

0.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.29
/internal/iosystem/source/reader.go
1
//
2
// Copyright (C) 2025 Dmitry Kolesnikov
3
//
4
// This file may be modified and distributed under the terms
5
// of the MIT license.  See the LICENSE file for details.
6
// https://github.com/fogfish/iq
7
//
8

9
package source
10

11
import (
12
        "context"
13
        "io"
14
        "os"
15

16
        "github.com/fogfish/iq/internal/iosystem"
17
)
18

19
// Reader wraps an io.Reader as a single-document Source.
20
// This is useful for integrating with spool.ForEach or other
21
// scenarios where you have an io.Reader and want to use it with Pipeline.
22
//
23
// Example with spool:
24
//
25
//        spool.ForEach(ctx, root, func(ctx, path, r, w) error {
26
//            source := source.NewReaderSource(path, r)
27
//            sink := sink.NewWriterSink(w)
28
//            return pipeline.Run(ctx, source, sink)
29
//        })
30
type Reader struct {
31
        path     string
32
        reader   io.Reader
33
        content  string
34
        consumed bool
35
}
36

37
// NewReader creates a Source that yields a single document from the given reader.
38
func NewReader(path string, r io.Reader) *Reader {
1✔
39
        return &Reader{
1✔
40
                path:    path,
1✔
41
                reader:  r,
1✔
42
                content: iosystem.ContentStream,
1✔
43
        }
1✔
44
}
1✔
45

46
// NewStdin creates a source that reads from os.Stdin.
NEW
47
func NewStdin() *Reader {
×
NEW
48
        return NewReader("stdin", os.Stdin)
×
NEW
49
}
×
50

51
// NewReaderJSON creates a Source that yields a single document from the given reader
52
// with content type application/json. Use this when the reader contains structured JSON data.
NEW
53
func NewReaderJSON(path string, r io.Reader) iosystem.Source {
×
NEW
54
        return &Reader{
×
NEW
55
                path:    path,
×
NEW
56
                reader:  r,
×
NEW
57
                content: iosystem.ContentJSON,
×
NEW
58
        }
×
NEW
59
}
×
60

61
// Next returns the document on first call, then io.EOF.
62
func (s *Reader) Next(ctx context.Context) (*iosystem.Document, error) {
1✔
63
        if s.consumed {
2✔
64
                return nil, io.EOF
1✔
65
        }
1✔
66
        s.consumed = true
1✔
67
        doc := iosystem.NewDocument(s.path, s.reader)
1✔
68
        doc.Type = s.content
1✔
69
        return doc, nil
1✔
70
}
71

72
// Close does nothing since ReaderSource doesn't own the reader.
73
// The reader lifecycle is managed by the caller (e.g., spool).
74
func (s *Reader) Close() error {
1✔
75
        return nil
1✔
76
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc