GithubHelp home page GithubHelp logo

Comments (6)

colszowka avatar colszowka commented on May 19, 2024

Hey, may I humbly suggest to RTFM :)

Under the Groups section of the Readme there's an explanation on how to define groups. You can do that by supplying a block as well, which will then yield each source file (check the rdoc on the public api of that) to that block, so you could check the path of the file and reject all those that are in your subdirectory.

Hope this helps!

from simplecov.

trans avatar trans commented on May 19, 2024

I did RTFM. And I know about the block and it's seems to me a rather inefficient approach. I was hoping there might be a better way and if not, I would suggest that there should be.

May I humbly suggest you refrain from using RTFM as an answer :)

from simplecov.

colszowka avatar colszowka commented on May 19, 2024

Oh, sorry, since you did not mention the block syntax for group definition, I figured you missed out on it :)

Unfortunately, adding your proposed syntax would require SimpleCov to extend/monkey patch Ruby's String literals to be aware of Path names and also to add the "-" method to String which, even though this method does not exist in MRI right now, would be a very bad practice IMHO since it is a very low-level method name and might be added in future Ruby versions to Strings.

What would be possible would be to create a Subclass for String that has those features, which would result in something like

add_group "Foo", SrcPath('lib/foo') - SrcPath('lib/foo/bar')

I think this looks rather clumsy though and adds unneccessary complexity through obscurity, since the block version might be almost the same, though in a bit more expressive way:

add_group("Foo") {|src| src.filename.include?('lib/foo') and not src.filename.include?('lib/foo/bar') }

from simplecov.

trans avatar trans commented on May 19, 2024

Thanks. Actually I should have peaked at the code a bit more myself. I assumed that the "filter" argument was doing some sort of Dir.glob to segment things. I see now that every path is just going through a selection block in the end. So your block solution is no less efficient. (Is my analysis right?)

It also means that File.fnmatch? syntax can't be used in the filter. Didn't realize that.

Note though you could do:

add_group(group_name, filter_argument=nil, options={}, &filter_proc)

Allowing something like:

add_group "Foo", 'lib/foo', :omit => 'lib/foo/bar'

Or you could take it even further to handle fnmatch globs too:

add_group "FooS", :glob => 'lib/foo/s*.rb'

Food for thought. Thanks again.

from simplecov.

colszowka avatar colszowka commented on May 19, 2024

Yeah, makes sense - maybe this should get refactored to use Ruby's built-in path functionalities like you mentioned. Reopening this as a reminder to investigate :)

from simplecov.

bf4 avatar bf4 commented on May 19, 2024

Closing as stale. Please reopen if this is still an issue. (And take a look at #340 )

from simplecov.

Related Issues (20)

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.