Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
wookay committed Aug 29, 2015
1 parent 3d05813 commit ca82626
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/PageDown.jl
@@ -1,7 +1,7 @@
module PageDown

export Page, next!, prev!, go!, first!, last!
export clear, proper
export clear, proper, imgcat
export @page, @current, @next, @prev, @go, @first, @last, @step, @open

__precompile__(true)
Expand All @@ -16,6 +16,7 @@ type Page
Page(pages::AbstractArray, start::Int, step::Int) = new(pages, start, step, Dict(), length(pages))
Page(pages::AbstractArray, start::Int, step::Int, option::Dict) = new(pages, start, step, option, length(pages))
Page(pages::AbstractArray, option::Pair...) = new(pages, 1, 1, Dict(option), length(pages))
Page(pages::AbstractArray, option::Dict) = new(pages, 1, 1, option, length(pages))
end

function next!(page::Page)
Expand Down Expand Up @@ -77,15 +78,16 @@ end

function zzal(tup::Tuple{Page,Array})
page,slides = tup
img = haskey(page.option, "IMG") ? page.option["IMG"] : "IMG"
imgcat = "../images/imgcat.go"
ispath(imgcat) && for slide in slides
img = haskey(page.option, :IMG) ? page.option[:IMG] : "IMG"
imgcmd = haskey(page.option, :imgcmd) ? page.option[:imgcmd] : "go run ../images/imgcat.go "
imgfolder = haskey(page.option, :imgfolder) ? page.option[:imgfolder] : "../images/"
for slide in slides
isa(slide, Base.Markdown.MD) && for content in slide.content
isa(content, Base.Markdown.List) && for item in content.items
for el in item
if startswith(el, img)
zz,image = split(el, "$img ")
run(`go run $imgcat ../images/$image`)
run(`$imgcmd $imgfolder$image`)
end
end
end
Expand All @@ -96,6 +98,7 @@ end

function open(page::Page, site::Int)
counter = 0
opencmd = haskey(page.option, :opencmd) ? page.option[:opencmd] : "open"
for slide in page |> proper |> slides
isa(slide, Base.Markdown.MD) && for content in slide.content
isa(content, Base.Markdown.List) && for item in content.items
Expand All @@ -104,7 +107,7 @@ function open(page::Page, site::Int)
if isa(m, RegexMatch)
counter += 1
if counter == site
run(`open $(m.match)`)
@osx_only run(`$opencmd $(m.match)`)
return
end
end
Expand Down
19 changes: 19 additions & 0 deletions test/page.jl
Expand Up @@ -34,4 +34,23 @@ last!(page)
@open 1
Base.Markdown.term(STDOUT, @first)

pages = ["1", "2", "3", "4", "5"]
page = Page(pages, 1, 1, Dict())

option = Dict(:IMG=>"IMG", :imgcmd=>"ls", :imgcat=>"", :imgfolder=>"", :opencmd=>"echo")
using Base.Markdown
pages = [md"""
# img
- IMG sample.png
"""]
page = Page(pages, option)
@next

pages = [md"""
# github
- http://github.com
"""]
page = Page(pages, option)
@open 1

end
Binary file added test/sample.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ca82626

Please sign in to comment.