Code Monkey home page Code Monkey logo

scanner's People

Contributors

krzysztof-gzocha avatar wojteninho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

scanner's Issues

LimitFilter

Say we want to filter first 100 files from a particular directory. I would love to do it as easy as:

s := NewBuilder().
     Files().
     In("/my/photos").
     Limit(100)    
     MustBuild()

for item := range MustScan(s.Scan(context.TODO())) {
    ...
}

Behind the scenes, it should be the new Scanner implementation called LimitScanner which is not a self-sufficient scanner, but act as a wrapper above the concrete scanner.

basicScanner := NewBasicScanner(WithDir("/my/photos"))
limitScanner := NewLimitScanner(basicScanner, 100)

To get familiar with the idea of wrappers check out available wrappers implementations.

Happy to see PR with this feature :-)

ModifiedFilter

What I have in my mind is to have an easy way to filter out files by modification date.
Say for instance we want to filter out files modified since yesterday:

yesterday := time.Now().AddDate(0, 0, -1)

s := NewBuilder().
     Files().
     In("/my/photos").
     Modified(After(yesterday))    
     MustBuild()

for item := range MustScan(s.Scan(context.TODO())) {
    ...
}

Another example is:

yesterday := time.Now().AddDate(0, 0, -1)

s := NewBuilder().
     Files().
     In("/my/photos").
     Modified(Before(yesterday))    
     MustBuild()

One more could be the between two dates:

twoDaysAgo := time.Now().AddDate(0, 0, -2)
yesterday := time.Now().AddDate(0, 0, -1)

s := NewBuilder().
     Files().
     In("/my/photos").
     Modified(Between(twoDaysAgo, yesterday))    
     MustBuild()

Behind the scenes it should be the new implementation of Filter interface, and in the builder calling Modified(...) we should add one more filter.

Check how we eventually combine multiple filters here. Filters comes so far from calls to either Files() or Directories() or Match(...).

Happy to discuss further ๐Ÿ˜„ ๐Ÿ‘

FilesScanner

My use case recently was to iterate through a set of pre-known files and directories. It would be handy to have:

filesScanner := MustScanner(NewFilesScanner(WithFiles("first.go", "second.go")))
dirScanner := MustScanner(NewBasicScanner(WithDirectory("/your/directory/to/scan")))

multiScanner := NewMultiScanner(filesScanner, dirScanner)

FilesScanner should act as a adapter basically to give a way to iterate through fixed set of files following the same interface as the other concrete implementations of Scanner interface.

GoDoc

We are all developers, we don't like to write documentation. But every package is as good as its documentation... According to the Go Report missing go doc is a weakness of the package.

Happy to see an improvement in this area ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.