Module: GitScribe::Check

Included in:
GitScribe
Defined in:
lib/git-scribe/check.rb

Instance Method Summary collapse

Instance Method Details

#check(args = []) ⇒ Object

check that we have everything needed



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/git-scribe/check.rb', line 4

def check(args = [])
  status = {}

  # check for asciidoc
  if !check_can_run('asciidoc')
    info "asciidoc is not present, please install it for anything to work"
    status[:asciidoc] = false
  else
    info "asciidoc - ok"
    status[:asciidoc] = true
  end

  # check for xsltproc
  if !check_can_run('xsltproc --version')
    info "xsltproc is not present, please install it for html generation"
    status[:xsltproc] = false
  else
    info "xsltproc - ok"
    status[:xsltproc] = true
  end

  # check for a2x - should be installed with asciidoc, but you never know
  if !check_can_run('a2x')
    info "a2x is not present, please install it for epub generation"
    status[:a2x] = false
  else
    info "a2x      - ok"
    status[:a2x] = true
  end

  # check for source-highlight
  if !check_can_run('source-highlight --version')
    info "source-highlight is not present, please install it for source code highlighting"
    status[:highlight] = false
  else
    info "highlighting - ok"
    status[:highlight] = true
  end


  # check for fop
  if !check_can_run('fop -v -out list')
    info "fop is not present, please install for PDF generation"
    status[:fop] = false
  else
    info "fop      - ok"
    status[:fop] = true
  end

  # check for kindlegen
  if !check_can_run('kindlegen')
    info "kindlegen is not present, please install for mobi generation"
    status[:mobi] = false
  else
    info "kindlegen - ok"
    status[:mobi] = true
  end


  status
end

#check_can_run(command) ⇒ Object



66
67
68
69
# File 'lib/git-scribe/check.rb', line 66

def check_can_run(command)
  `#{command} 2>&1`
  $?.success?
end