jsdoc-toolkit 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.2.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jsdoc-toolkit}
8
- s.version = "0.1.4"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["ggironda"]
12
- s.date = %q{2009-10-08}
12
+ s.date = %q{2009-10-11}
13
13
  s.description = %q{RubyGem packaged version of jsdoc-toolkit with extra rake tasks for automating doc generation}
14
14
  s.email = %q{gabriel.gironda@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -139,6 +139,7 @@ Gem::Specification.new do |s|
139
139
  "test/generator_test.rb",
140
140
  "test/input/bar/foo.js",
141
141
  "test/input/test.js",
142
+ "test/other_input/qhat.js",
142
143
  "test/test_helper.rb"
143
144
  ]
144
145
  s.homepage = %q{http://github.com/gabrielg/jsdoc-toolkit}
@@ -5,8 +5,10 @@ require 'pathname'
5
5
 
6
6
  module JsDocToolkit
7
7
  class DocTask
8
+ attr_reader :jsdoc_files
8
9
 
9
10
  def initialize(task_name)
11
+ @jsdoc_files = []
10
12
  yield(self)
11
13
  task(task_name) { build }
12
14
  end
@@ -14,16 +16,12 @@ module JsDocToolkit
14
16
  def jsdoc_dir=(path)
15
17
  @jsdoc_dir = Pathname(path)
16
18
  end
17
-
18
- def jsdoc_files=(path)
19
- @jsdoc_files = Pathname(path)
20
- end
21
19
 
22
20
  private
23
21
 
24
22
  def build
25
23
  generator = JsDocToolkit::Generator.new
26
- generator.build(:src_dir => @jsdoc_files.to_s, :doc_dir => @jsdoc_dir.to_s)
24
+ generator.build(:src_files => @jsdoc_files, :doc_dir => @jsdoc_dir.to_s)
27
25
  end
28
26
 
29
27
  end # DocTask
@@ -7,24 +7,22 @@ module JsDocToolkit
7
7
  :verbose => "-v", :unique => "-u"}
8
8
 
9
9
  def build(options)
10
+ src_files, doc_dir = Array(options[:src_files]), Pathname(options[:doc_dir].to_s)
10
11
  raise RuntimeError, "java was not found in your PATH." if `which java 2>/dev/null`.strip.empty?
11
- raise ArgumentError, ":src_dir was not specified" unless options[:src_dir]
12
- raise ArgumentError, ":doc_dir was not specified" unless options[:doc_dir]
13
-
14
- src_dir, doc_dir = Pathname(options[:src_dir]), Pathname(options[:doc_dir])
15
- raise ArgumentError, ":src_dir does not exist" unless src_dir.exist?
16
- raise ArgumentError, ":doc_dir does not exist" unless doc_dir.exist?
17
- run_jsdoc(src_dir, doc_dir)
12
+ raise ArgumentError, ":src_files was not specified or was empty" if src_files.empty?
13
+ raise ArgumentError, ":doc_dir was not specified or does not exist" unless options[:doc_dir] && doc_dir.exist?
14
+
15
+ run_jsdoc(src_files, doc_dir)
18
16
  end
19
17
 
20
18
  private
21
19
 
22
- def run_jsdoc(src_dir, doc_dir)
23
- system("java", "-jar", JsDocJarPath, JsDocJsPath, %Q[-d=#{doc_dir.expand_path}], *merge_defaults_with_src(src_dir))
20
+ def run_jsdoc(src_files, doc_dir)
21
+ system("java", "-jar", JsDocJarPath, JsDocJsPath, %Q[-d=#{doc_dir.expand_path}], *merge_defaults_with_src(src_files))
24
22
  end
25
23
 
26
- def merge_defaults_with_src(src_dir)
27
- DefaultOptions.values + [src_dir.to_s]
24
+ def merge_defaults_with_src(src_files)
25
+ DefaultOptions.values + src_files
28
26
  end
29
27
 
30
28
  end # Generator
@@ -5,7 +5,7 @@ context "a JsDocToolkit::DocTask" do
5
5
  setup do
6
6
  JsDocToolkit::DocTask.new("testing:doc_task") do |doc|
7
7
  doc.jsdoc_dir = 'output'
8
- doc.jsdoc_files = 'input'
8
+ doc.jsdoc_files << 'input'
9
9
  end
10
10
  end
11
11
 
@@ -14,10 +14,13 @@ context "a JsDocToolkit::DocTask" do
14
14
  end.equals("testing:doc_task")
15
15
 
16
16
  should "generate the docs when invoked" do
17
- output_dir = Pathname(__FILE__).parent + "output"
17
+ cur_dir = Dir.pwd
18
+ Dir.chdir(Pathname(__FILE__).parent)
19
+ output_dir = Pathname("output").expand_path
18
20
  output_dir.rmtree if output_dir.exist?
19
21
  output_dir.mkdir
20
22
  Rake::Task["testing:doc_task"].invoke
23
+ Dir.chdir(cur_dir)
21
24
  output_dir.entries.size > 2
22
25
  end
23
26
 
@@ -6,11 +6,14 @@ context "a JsDocToolkit::Generator" do
6
6
  context "with valid arguments and generating docs" do
7
7
 
8
8
  setup do
9
- output_dir = Pathname(__FILE__).parent + "output"
9
+ cur_dir = Dir.pwd
10
+ Dir.chdir(Pathname(__FILE__).parent)
11
+ output_dir = Pathname("output").expand_path
10
12
  output_dir.rmtree if output_dir.exist?
11
13
  output_dir.mkdir
12
14
  generator = JsDocToolkit::Generator.new
13
- generator.build(:src_dir => Pathname(__FILE__).parent + "input", :doc_dir => output_dir)
15
+ generator.build(:src_files => [Pathname(__FILE__).parent + "input", Pathname(__FILE__).parent + "other_input"], :doc_dir => output_dir)
16
+ Dir.chdir(cur_dir)
14
17
  output_dir
15
18
  end
16
19
 
@@ -29,26 +32,22 @@ context "a JsDocToolkit::Generator" do
29
32
  begin
30
33
  original_path = ENV['PATH']
31
34
  ENV['PATH'] = ""
32
- topic.build(:src_dir => Pathname("input"), :doc_dir => Pathname("output"))
35
+ topic.build(:src_files => Pathname("input"), :doc_dir => Pathname("output"))
33
36
  ensure
34
37
  ENV['PATH'] = original_path
35
38
  end
36
39
  end.raises(RuntimeError, /java was not found/)
37
40
 
38
- should "fail if src dir does not exist" do
39
- topic.build(:src_dir => Pathname("bzzzzzzzzzzzt"), :doc_dir => Pathname("output"))
40
- end.raises(ArgumentError, /src_dir does not exist/)
41
-
42
41
  should "fail if doc dir does not exist" do
43
- topic.build(:src_dir => Pathname(__FILE__).parent + "input", :doc_dir => Pathname("bzzzzzzzt"))
44
- end.raises(ArgumentError, /doc_dir does not exist/)
42
+ topic.build(:src_files => Pathname(__FILE__).parent + "input", :doc_dir => Pathname("bzzzzzzzt"))
43
+ end.raises(ArgumentError, /doc_dir was not specified or does not exist/)
45
44
 
46
- should "fail if src dir is not specified" do
45
+ should "fail if src files is not specified" do
47
46
  topic.build(:doc_dir => Pathname("output"))
48
- end.raises(ArgumentError, /src_dir was not specified/)
47
+ end.raises(ArgumentError, /src_files was not specified/)
49
48
 
50
49
  should "fail if doc dir is not specified" do
51
- topic.build(:src_dir => Pathname("input"))
50
+ topic.build(:src_files => Pathname("input"))
52
51
  end.raises(ArgumentError, /doc_dir was not specified/)
53
52
 
54
53
  end # with various modes of build failure
File without changes
@@ -4,8 +4,4 @@ require 'pathname'
4
4
 
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'jsdoc-toolkit'
8
-
9
- at_exit do
10
- Riot.report
11
- end
7
+ require 'jsdoc-toolkit'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsdoc-toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ggironda
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-08 00:00:00 -05:00
12
+ date: 2009-10-11 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -154,6 +154,7 @@ files:
154
154
  - test/generator_test.rb
155
155
  - test/input/bar/foo.js
156
156
  - test/input/test.js
157
+ - test/other_input/qhat.js
157
158
  - test/test_helper.rb
158
159
  has_rdoc: true
159
160
  homepage: http://github.com/gabrielg/jsdoc-toolkit