Skip to content

Commit

Permalink
Update show style
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-dG committed Dec 7, 2017
1 parent ffd288a commit 7e38c92
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 34 deletions.
5 changes: 3 additions & 2 deletions src/plugin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ config template file doesn't follow the generic naming convention, we added anot
abstract type GenericPlugin <: Plugin end

function show(io::IO, p::GenericPlugin)
spc = " "
t = split(string(typeof(p)), ".")[end]
println(io, "$t:")

Expand All @@ -78,11 +79,11 @@ function show(io::IO, p::GenericPlugin)
else
dirname(get(p.src)) == DEFAULTS_DIR ? "Default" : get(p.src)
end
println(io, " → Config file: $cfg")
println(io, "$spc→ Config file: $cfg")

n = length(p.gitignore)
s = n == 1 ? "" : "s"
print(io, " $n gitignore entrie$s")
print(io, "$spc$n gitignore entrie$s")
n > 0 && print(io, ": $(join(map(g -> "\"$g\"", p.gitignore), ", "))")
end

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/documenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function show(io::IO, p::Documenter)

n = length(p.assets)
s = n == 1 ? "" : "s"
print(io, " $n asset file$s")
print(io, "$n asset file$s")
if n == 0
println(io)
else
Expand All @@ -76,7 +76,7 @@ function show(io::IO, p::Documenter)

n = length(p.gitignore)
s = n == 1 ? "" : "s"
print(io, " $n gitignore entrie$s")
print(io, "$n gitignore entrie$s")
n > 0 && print(io, ": $(join(map(g -> "\"$g\"", p.gitignore), ", "))")
end

Expand Down
28 changes: 13 additions & 15 deletions src/template.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,26 @@ function show(io::IO, t::Template)
println(io, "Template:")
println(io, "$spc→ User: $(maybe_none(t.user))")
println(io, "$spc→ Host: $(maybe_none(t.host))")
println(io, "$spc→ License: $(maybe_none(t.license))")

# We don't care about authors or license years if there is no license.
if !isempty(t.license)
# TODO: Authors could be split into multiple lines if there are more than one.
# Maybe the authors field of Template should be an array (or Dict, see #4).
println(io, "$spc→ Authors: $(maybe_none(t.authors))")
println(io, "$spc→ License years: $(maybe_none(t.years))")

print(io, "$spc→ License: ")
if isempty(t.license)
println(io, "None")
else
println(io, "$(t.license) ($(t.authors) $(t.years))")
end

println(io, "$spc→ Package directory: $(replace(maybe_none(t.dir), homedir(), "~"))")
println(io, "$spc→ Precompilation enabled: $(t.precompile ? "yes" : "no")")
println(io, "$spc→ Precompilation enabled: $(t.precompile ? "Yes" : "No")")
println(io, "$spc→ Minimum Julia version: v$(t.julia_version)")

print(io, "$spc→ Package dependencies:")
n = length(t.requirements)
s = n == 1 ? "" : "s"
print(io, "$spc$n package requirement$s")

if isempty(t.requirements)
println(io, " None")
else
println(io)
for req in sort(t.requirements)
println(io, "$(spc^2)$req")
end
else
println(io, ": $(join(t.requirements, ", "))")
end

print(io, "$spc→ Git configuration options:")
Expand Down
28 changes: 13 additions & 15 deletions test/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,11 @@ end
Template:
→ User: $me
→ Host: github.com
→ License: MIT
→ Authors: $(gitconfig["user.name"])
→ License years: 2017
→ License: MIT ($(gitconfig["user.name"]) $(Dates.year(now())))
→ Package directory: $pkgdir
→ Precompilation enabled: yes
→ Precompilation enabled: Yes
→ Minimum Julia version: v$VERSION
Package dependencies: None
0 package requirements
→ Git configuration options:
• github.user = $(gitconfig["github.user"])
• user.email = $(gitconfig["user.email"])
Expand All @@ -168,25 +166,23 @@ end
→ Host: github.com
→ License: None
→ Package directory: $pkgdir
→ Precompilation enabled: yes
→ Precompilation enabled: Yes
→ Minimum Julia version: v$VERSION
→ Package dependencies:
• Bar
• Foo
→ 2 package requirements: Bar, Foo
→ Git configuration options:
• github.user = $(gitconfig["github.user"])
• user.email = $(gitconfig["user.email"])
• user.name = $(gitconfig["user.name"])
→ Plugins:
• CodeCov:
→ Config file: None
→ 3 gitignore entries: "*.jl.cov", "*.jl.*.cov", "*.jl.mem"
→ Config file: None
→ 3 gitignore entries: "*.jl.cov", "*.jl.*.cov", "*.jl.mem"
• GitHubPages:
→ 0 asset files
→ 2 gitignore entries: "/docs/build/", "/docs/site/"
→ 0 asset files
→ 2 gitignore entries: "/docs/build/", "/docs/site/"
• TravisCI:
→ Config file: Default
→ 0 gitignore entries
→ Config file: Default
→ 0 gitignore entries
"""
@test text == rstrip(expected)
end
Expand Down Expand Up @@ -294,6 +290,8 @@ end
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
@test LibGit2.getconfig(repo, "user.name", "") == gitconfig["user.name"]
# Note: This test will fail on your system if you've configured Git
# to replace all HTTPS URLs with SSH.
@test LibGit2.url(remote) == "https://github.com/$me/$test_pkg.jl"
@test in("master", branches)
@test !in("gh-pages", branches)
Expand Down

0 comments on commit 7e38c92

Please sign in to comment.