JuliaPackaging / Scratch.jl

Scratch spaces for all your persistent mutable data needs
MIT License
58 stars 11 forks source link

Look in the active project for a UUID if it is not given. #3

Closed fredrikekre closed 3 years ago

fredrikekre commented 3 years ago

This makes top-level usage of @get_scratch! look in the active project for a UUID to use before falling back to the global namespace.

For a motivating example: Typically when you work on a package you have that package activated. In such a case it is very convenient if code running in the REPL behaves similar to how it works inside the package, in particular @get_scratch! will now return a path with the package UUID instead of the global namespace:

julia> using Scratch

julia> Base.active_project()
"/home/fredrik/dev/Scratch/Project.toml"

julia> @get_scratch!("hello-world")
"/home/fredrik/.julia/scratchspaces/6c6a2e73-6563-6170-7368-637461726353/hello-world"

For a package environment without a UUID this patch does not change anything.

codecov[bot] commented 3 years ago

Codecov Report

Merging #3 into master will increase coverage by 7.53%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #3      +/-   ##
==========================================
+ Coverage   53.33%   60.86%   +7.53%     
==========================================
  Files           1        1              
  Lines          60       69       +9     
==========================================
+ Hits           32       42      +10     
+ Misses         28       27       -1     
Impacted Files Coverage Δ
src/Scratch.jl 60.86% <100.00%> (+7.53%) :arrow_up:

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 9b2820f...48e2c2c. Read the comment docs.

staticfloat commented 3 years ago

I'm loving this Fredrik, keep 'em coming!