yard-minitest-spec 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,108 @@
1
+ # encoding: utf-8
2
+
3
+ require 'minitest/spec'
4
+ require 'minitest/autorun'
5
+
6
+ module A
7
+ module B
8
+ class C
9
+ def itest
10
+ 'test instance test'
11
+ end
12
+ def self.ctest
13
+ 'test class test'
14
+ end
15
+ class D
16
+ class E
17
+ def self.test
18
+ 'test e'
19
+ end
20
+ end
21
+ def test
22
+ 'test d'
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ module A::B
30
+ describe 'C#itest' do
31
+ it 'has a new method' do
32
+ C.new.ctest.must_be_instance_of String
33
+ end
34
+ end
35
+ describe 'X#bob' do
36
+ it 'has a new method' do
37
+ A::B::C.ctest.must_be_instance_of String
38
+ end
39
+ end
40
+ describe 'X#bob' do
41
+ it 'new' do
42
+ A::B::C.ctest.must_be_instance_of String
43
+ end
44
+ end
45
+ end
46
+
47
+ describe 'X#bob' do
48
+ it 'old' do
49
+ A::B::C.ctest.must_be_instance_of String
50
+ end
51
+ end
52
+
53
+ describe 'X#bob' do
54
+ it 'has a new method' do
55
+ A::B::C.ctest.must_be_instance_of String
56
+ end
57
+ end
58
+
59
+ describe A::B::C do
60
+ describe ':ctest' do
61
+ it 'has a new method' do
62
+ A::B::C.ctest.must_be_instance_of String
63
+ end
64
+ end
65
+ describe '#itest' do
66
+ it 'has a new method' do
67
+ A::B::C.new.itest.must_be_instance_of String
68
+ end
69
+ end
70
+ describe ':ctest' do
71
+ it 'has a new method' do
72
+ A::B::C.ctest.must_be_instance_of String
73
+ A::B::C.ctest.must_equal 'test class test'
74
+ end
75
+ it 'has a old method' do
76
+ A::B::C.ctest.must_be_instance_of String
77
+ A::B::C.ctest.must_equal 'test class test'
78
+ end
79
+ end
80
+ end
81
+
82
+ describe A do
83
+ describe B do
84
+ describe C do
85
+ describe ':ctest' do
86
+ it 'has a new method' do
87
+ A::B::C.ctest.must_be_instance_of String
88
+ end
89
+ end
90
+ describe '#itest' do
91
+ it 'has a new method' do
92
+ A::B::C.new.itest.must_be_instance_of String
93
+ end
94
+ end
95
+ describe ':ctest' do
96
+ it 'has a new method' do
97
+ A::B::C.ctest.must_be_instance_of String
98
+ A::B::C.ctest.must_equal 'test class test'
99
+ end
100
+ it 'has a old method' do
101
+ A::B::C.ctest.must_be_instance_of String
102
+ A::B::C.ctest.must_equal 'test class test'
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+
@@ -1,37 +1,58 @@
1
1
 
2
2
  class YardMiniTestSpecDescribeHandler < YARD::Handlers::Ruby::Base
3
- VERSION = YardMiniTestSpec::VERSION
4
3
  handles method_call(:describe)
5
4
 
6
5
  def process
7
- objname = statement.parameters.first.jump(:string_content).source
8
- if statement.parameters[1]
9
- src = statement.parameters[1].jump(:string_content).source
10
- objname += (src[0] == "#" ? "" : "::") + src
11
- end
12
- obj = {:spec => owner ? (owner[:spec] || "") : ""}
13
- obj[:spec] += objname
14
- parse_block(statement.last.last, owner: obj)
6
+ meth = statement.method_name(true).to_s
7
+ mod = register ModuleObject.new(namespace, 'spec')
8
+
9
+ name = statement.parameters.first.jump(:string_content).source
10
+ (mod[:bob] ||= []).push name
11
+ parse_block(statement.last.last, owner: mod)
12
+ mod[:bob].pop
15
13
  rescue YARD::Handlers::NamespaceMissingError
16
14
  end
17
15
  end
18
16
 
19
17
  class YardMiniTestSpecItHandler < YARD::Handlers::Ruby::Base
20
- VERSION = YardMiniTestSpec::VERSION
21
18
  handles method_call(:it)
22
19
 
23
20
  def process
24
- return if owner.nil?
25
- obj = P(owner[:spec])
26
- return if obj.is_a?(Proxy)
27
- # ignore comments etc
28
- if statement.last.last.source.chomp.size > 0
29
- (obj[:specifications] ||= []) << {
30
- name: statement.parameters.first.jump(:string_content).source,
31
- file: statement.file,
32
- line: statement.line,
33
- source: statement.last.last.source.chomp
34
- }
21
+ array = owner[:bob].dup
22
+
23
+ if array.size > 1
24
+ last = array.pop
25
+ start = array.join('::')
26
+ if last.match(/\A[A-Z]/)
27
+ name = start + '::' + last
28
+ else
29
+ name = start + last
30
+ end
31
+ else
32
+ name = array[0]
33
+ end
34
+
35
+ if name.match(/:[a-z]([^:]*)/)
36
+ name.gsub!(/:([a-z][^:]*)/, '.\1')
37
+ end
38
+ if obj = YARD::Registry.resolve(namespace, name)
39
+ # ignore :it with empty body
40
+ if statement.last.last.source.chomp.size > 0
41
+ (obj[:specifications] ||= []) << {
42
+ name: statement.parameters.first.jump(:string_content).source,
43
+ file: statement.file,
44
+ line: statement.line,
45
+ source: statement.last.last.source.chomp
46
+ }
47
+ end
48
+ else
49
+ if namespace.root?
50
+ text = "Nothing to describe for #{name}"
51
+ else
52
+ text = "Nothing to describe for #{name} in (#{namespace})"
53
+ end
54
+ log.warn text unless namespace[:duplicate] and namespace[:duplicate][name]
55
+ ( namespace[:duplicate] ||= {} )[name] = true
35
56
  end
36
57
  end
37
58
  end
@@ -1,11 +1,7 @@
1
1
 
2
- class YardMiniTestSpec
3
- VERSION = '0.1.2'
4
- end
5
-
6
2
  begin
7
- YARD::Templates::Engine.register_template_path File.dirname(__FILE__) + '/../templates'
8
- require File.join(File.dirname(__FILE__), 'yard-minitest-spec', 'handler') if RUBY19
9
- rescue
3
+ YARD::Templates::Engine.register_template_path File.dirname(__FILE__) + '/../templates'
4
+ require File.join(File.dirname(__FILE__), 'yard-minitest-spec', 'handler.rb') if RUBY19
5
+ rescue => x
6
+ puts x
10
7
  end
11
-
@@ -25,4 +25,4 @@
25
25
  <% end %>
26
26
  </ul>
27
27
  </div>
28
- <% end %>
28
+ <% end %>
@@ -7,7 +7,7 @@ require 'yard-minitest-spec'
7
7
 
8
8
  Gem::Specification.new do |s|
9
9
  s.name = "yard-minitest-spec"
10
- s.version = YardMiniTestSpec::VERSION
10
+ s.version = '0.1.4'
11
11
 
12
12
  s.summary = "YARD plugin to list MiniTest::Spec specifications inside documentation"
13
13
  s.description = %q{
@@ -17,12 +17,13 @@ Gem::Specification.new do |s|
17
17
  }
18
18
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
19
19
  s.authors = ["G. Allen Morris III"]
20
- s.date = "2012-03-15"
20
+ s.date = "2013-07-01"
21
21
  s.email = "gam3@gam3.net"
22
22
  s.homepage = "http://yardoc.org"
23
23
  s.require_paths = ["lib"]
24
24
  s.rubyforge_project = "yard-minitest-spec"
25
25
  s.rubygems_version = "1.8.11"
26
+ s.files = Dir['ChangeLog']
26
27
  s.files = Dir['lib/*/*.rb'] + Dir['lib/*.rb']
27
28
  s.files += Dir['*.gemspec']
28
29
  s.files += Dir['examples/*']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-minitest-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-15 00:00:00.000000000 Z
12
+ date: 2013-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yard
@@ -37,6 +37,7 @@ files:
37
37
  - lib/yard-minitest-spec/handler.rb
38
38
  - lib/yard-minitest-spec.rb
39
39
  - yard-minitest-spec.gemspec
40
+ - examples/spec_abc.rb
40
41
  - templates/default/method_details/html/specs.erb
41
42
  - templates/default/method_details/setup.rb
42
43
  - templates/default/method_details/text/specs.erb