Skip to content

Commit 1a045d5

Browse files
authored
Merge pull request #123 from davidanthoff/alt-save
Add save method that returns function that acceps data
2 parents 4aadcda + bc4b09b commit 1a045d5

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/loadsave.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ trying to infer the format from `filename`.
5454
save(s::Union{AbstractString,IO}, data...; options...) =
5555
save(query(s), data...; options...)
5656

57+
function save(s::Union{AbstractString,IO}; options...)
58+
data -> save(s, data; options...)
59+
end
60+
5761
# Forced format
5862
function save{sym}(df::Type{DataFormat{sym}}, f::AbstractString, data...; options...)
5963
libraries = applicable_savers(df)

test/loadsave.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,23 @@ add_saver(format"DUMMY", :Dummy)
111111
end
112112
end
113113

114+
fn2 = string(tempname(), ".dmy")
115+
a |> save(fn2)
116+
117+
# Test for absolute paths
118+
cd(dirname(fn2)) do
119+
fnrel = basename(fn2)
120+
f = query(fnrel)
121+
@test isabspath(filename(f))
122+
@test endswith(filename(f),fn2) # TravisOSX prepends "/private"
123+
f = File(format"DUMMY", fnrel)
124+
@test !(isabspath(filename(f)))
125+
open(f) do s
126+
@test isabspath(get(filename(s)))
127+
@test endswith(get(filename(s)),fn2)
128+
end
129+
end
130+
114131
# Test IO
115132
b = load(query(fn))
116133
@test a == b

0 commit comments

Comments
 (0)