Class: JsdocHelper::Rake::Task::Runner

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/jsdoc_helper/rake/task/runner.rb

Overview

Holds the arguments for, and runs, jsdoc-toolkit

Constant Summary collapse

DEFAULT_TOOLKIT =

The default jsdoc-toolkit to use

JsdocHelper.path('ext', 'jsdoc-toolkit')
DEFAULT_ARGS =

Default arguments

{
  :toolkit => DEFAULT_TOOLKIT,
  :files => FileList[File.join(%w(lib ** *.js))],
  :template => "templates/jsdoc",
  :out => FileList['doc'],
  :options => ""
}

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Runner

Create a new Runner, with arguments that will be merged with the defaults



24
25
26
# File 'lib/jsdoc_helper/rake/task/runner.rb', line 24

def initialize(args={})
  @args = default_args.merge(args)
end

Instance Method Details

#commandObject

Return the command that the runner will run



39
40
41
# File 'lib/jsdoc_helper/rake/task/runner.rb', line 39

def command
  "#{jsrun} #{jsdoc} #{files} -t=#{template} -d=#{out} #{options}".strip
end

#run(opts = {}) ⇒ Object

Run jsdoc-toolkit. If :return_string => true is passed, the function will return any messages that it would have otherwise sent to stdout



29
30
31
32
33
34
35
36
# File 'lib/jsdoc_helper/rake/task/runner.rb', line 29

def run(opts={})
  msg = toolkit == DEFAULT_TOOLKIT ? '' : "using #{toolkit}"
  
  puts msg unless msg.empty?
  system command
  
  msg.empty? || !opts[:return_string] ? true : msg
end