Skip to content
Browse files

tests for checking for deps

  • Loading branch information...
1 parent baec2fe commit 9d6753d711008cc11b69c2070f8eed1a84e4360a @schacon schacon committed Feb 21, 2011
Showing with 51 additions and 14 deletions.
  1. +1 −4 Rakefile
  2. +3 −1 lib/git-scribe.rb
  3. +30 −9 lib/git-scribe/check.rb
  4. +5 −0 lib/git-scribe/cli.rb
  5. +12 −0 test/check_test.rb
View
5 Rakefile
@@ -10,10 +10,7 @@ task :default => :test
desc "Run the test suite"
task :test do
- rg = command?(:rg)
- Dir['test/**/*_test.rb'].each do |f|
- rg ? sh("rg #{f}") : ruby(f)
- end
+ sh('turn test/**/*_test.rb')
end
View
4 lib/git-scribe.rb
@@ -16,6 +16,7 @@ class GitScribe
include Generate
attr_accessor :subcommand, :args, :options
+ attr_reader :info
BOOK_FILE = 'book.asc'
OUTPUT_TYPES = ['pdf', 'epub', 'mobi', 'html', 'site']
@@ -53,7 +54,8 @@ def first_arg(args)
# eventually we'll want to log this or have it retrievable elsehow
def info(message)
- puts message
+ @info ||= []
+ @info << message
end
end
View
39 lib/git-scribe/check.rb
@@ -1,34 +1,55 @@
class GitScribe
module Check
# check that we have everything needed
- def check
+ def check(args = [])
+ status = {}
+
+ # check for git
+ if !check_can_run('git --version')
+ info "git is not present, please install it for anything to work"
+ status[:git] = true
+ else
+ info "git - ok"
+ status[:git] = false
+ end
+
# check for asciidoc
if !check_can_run('asciidoc')
- puts "asciidoc is not present, please install it for anything to work"
+ info "asciidoc is not present, please install it for anything to work"
+ status[:asciidoc] = true
else
- puts "asciidoc - ok"
+ info "asciidoc - ok"
+ status[:asciidoc] = false
end
# check for xsltproc
if !check_can_run('xsltproc --version')
- puts "xsltproc is not present, please install it for html generation"
+ info "xsltproc is not present, please install it for html generation"
+ status[:xsltproc] = true
else
- puts "xsltproc - ok"
+ info "xsltproc - ok"
+ status[:xsltproc] = false
end
# check for a2x - should be installed with asciidoc, but you never know
if !check_can_run('a2x')
- puts "a2x is not present, please install it for epub generation"
+ info "a2x is not present, please install it for epub generation"
+ status[:a2x] = true
else
- puts "a2x - ok"
+ info "a2x - ok"
+ status[:a2x] = false
end
# check for fop
if !check_can_run('fop -version')
- puts "fop is not present, please install for PDF generation"
+ info "fop is not present, please install for PDF generation"
+ status[:fop] = true
else
- puts "fop - ok"
+ info "fop - ok"
+ status[:fop] = false
end
+
+ status
end
def check_can_run(command)
View
5 lib/git-scribe/cli.rb
@@ -55,6 +55,11 @@ def parse_options
opts.description = "generate digital formats"
end
+ command :check do |opts|
+ opts.banner = "Usage: git scribe check"
+ opts.description = "checks for system requirements for doc generation"
+ end
+
@subcommand = opt_parse
@args = ARGV
end
View
12 test/check_test.rb
@@ -0,0 +1,12 @@
+require File.expand_path "../test_helper", __FILE__
+
+context "scribe check tests" do
+ setup do
+ @scribe = GitScribe.new
+ end
+
+ test "scribe can check for programs it needs" do
+ status = @scribe.check
+ assert_equal status.size, 5
+ end
+end

0 comments on commit 9d6753d

Please sign in to comment.
Something went wrong with that request. Please try again.