Skip to content

Commit

Permalink
Simplify destructure
Browse files Browse the repository at this point in the history
  • Loading branch information
00vareladavid committed Feb 3, 2019
1 parent 379ff32 commit 5efe5fe
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/project.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,26 +145,21 @@ read_project(path::String) =
###########
# WRITING #
###########
string(x::Vector{String}) = x
function destructure(project::Project)::Dict
raw = project.other
function entry!(key::String, src::Dict)
if isempty(src)
delete!(raw, key)
else
raw[key] = Dict(string(name) => string(uuid) for (name,uuid) in src)
end
end
entry!(key::String, src) = src === nothing ? delete!(raw, key) : (raw[key] = string(src))
raw = deepcopy(project.other)

should_delete(x::Dict) = isempty(x)
should_delete(x) = x === nothing
entry!(key::String, src) = should_delete(src) ? delete!(raw, key) : (raw[key] = src)

entry!("name", project.name)
entry!("uuid", project.uuid)
entry!("version", project.version)
entry!("name", project.name)
entry!("uuid", project.uuid)
entry!("version", project.version)
entry!("manifest", project.manifest)
entry!("deps", project.deps)
entry!("extras", project.extras)
entry!("compat", project.compat)
entry!("targets", project.targets)
entry!("deps", project.deps)
entry!("extras", project.extras)
entry!("compat", project.compat)
entry!("targets", project.targets)
return raw
end

Expand Down

0 comments on commit 5efe5fe

Please sign in to comment.