autodoc 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0989cfe76444a6c585c644685c02a57d28c10386
4
- data.tar.gz: bc53f5170027552ded6804d7d579ba9623306d38
3
+ metadata.gz: 17b75404749690142753e26acbf21f0a6de60e55
4
+ data.tar.gz: f80c464a81660e905980d3d7320e13f456bc23ab
5
5
  SHA512:
6
- metadata.gz: 876a3a38f18353a84e10650afb995186789453e387c730fc270aabb955796a61629d8dd7c3a8abb8d9a0fe49cf0281e3b32298e0d27f11135fa910672ba850c4
7
- data.tar.gz: edce3d786a7ce4199637d3a9e61038e32c61a0ba8f8fdb6b7a5ae0d319cedde849deffd7594b0737a96f88387f1e922145444fd93a0a983043450888343e9e17
6
+ metadata.gz: a73209f5f781748ec290b6cbb3a440011badce544d33168ad88853d3ded1c3d440047a00939abb745b4afac35949e3ebb0fb60a1727b534964edddb6ff5151bb
7
+ data.tar.gz: 0d9b83795d1b0c116804ef78794d9a5de0081cac9f1a6d40cc736be125d8a0fc1637a5854f2cf4f70fd9912fc76fd0429d647ef9f6e3c01dc3472804874597b1
@@ -1,3 +1,6 @@
1
+ ## 0.2.4
2
+ * add Documents class
3
+
1
4
  ## 0.2.3
2
5
  * clean up dependencies & implementation
3
6
 
@@ -1,16 +1,17 @@
1
1
  require "autodoc/configuration"
2
2
  require "autodoc/document"
3
+ require "autodoc/documents"
3
4
  require "autodoc/version"
4
5
  require "autodoc/rspec" if ENV["AUTODOC"]
5
6
 
6
7
  module Autodoc
7
8
  class << self
8
- def contexts
9
- @contexts ||= []
9
+ def documents
10
+ @documents ||= Documents.new
10
11
  end
11
12
 
12
13
  def configuration
13
- @configuration ||= Autodoc::Configuration.new
14
+ @configuration ||= Configuration.new
14
15
  end
15
16
  end
16
17
  end
@@ -7,8 +7,6 @@ module Autodoc
7
7
  new(*args).render
8
8
  end
9
9
 
10
- attr_reader :example
11
-
12
10
  def initialize(context)
13
11
  @context = context
14
12
  end
@@ -0,0 +1,20 @@
1
+ module Autodoc
2
+ class Documents
3
+ def initialize
4
+ @table = Hash.new {|table, key| table[key] = [] }
5
+ end
6
+
7
+ def append(context)
8
+ path = context.example.file_path.gsub(%r<\./spec/requests/(.+)_spec\.rb>, '\1.md')
9
+ key = Autodoc.configuration.base_path + path
10
+ @table[key] << Autodoc::Document.render(context)
11
+ end
12
+
13
+ def write
14
+ @table.each do |pathname, documents|
15
+ pathname.parent.mkpath
16
+ pathname.open("w") {|file| file << documents.join("\n").rstrip + "\n" }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,16 +1,9 @@
1
1
  require "rspec"
2
2
 
3
3
  RSpec.configuration.after(:each, autodoc: true) do
4
- Autodoc.contexts << self.clone
4
+ Autodoc.documents.append(self)
5
5
  end
6
6
 
7
7
  RSpec.configuration.after(:suite) do
8
- table = Autodoc.contexts.group_by {|context| context.example.file_path }
9
- table.each do |path, contexts|
10
- pathname = Autodoc.configuration.base_path + path.gsub("./spec/requests/", "").gsub("_spec.rb", ".md")
11
- pathname.parent.mkpath
12
- pathname.open("w") do |file|
13
- file << contexts.map {|context| Autodoc::Document.render(context) }.join("\n").rstrip + "\n"
14
- end
15
- end
8
+ Autodoc.documents.write
16
9
  end
@@ -1,3 +1,3 @@
1
1
  module Autodoc
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
@@ -111,6 +111,7 @@ files:
111
111
  - lib/autodoc.rb
112
112
  - lib/autodoc/configuration.rb
113
113
  - lib/autodoc/document.rb
114
+ - lib/autodoc/documents.rb
114
115
  - lib/autodoc/rspec.rb
115
116
  - lib/autodoc/template.md.erb
116
117
  - lib/autodoc/version.rb