markdown_ruby_documentation 0.21.0 → 0.21.1

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: 94cf45206406b64001109a7c6d3ab7ae25558135
4
- data.tar.gz: 45986afae8718ada4c88ca45f6aa8c3985c505dd
3
+ metadata.gz: 3779e78fb8a38de3bccb66c1720364fd3046b1d5
4
+ data.tar.gz: 20e8cc52b0064550321725d7bca00809a35347a7
5
5
  SHA512:
6
- metadata.gz: 18f90760acfe91488781e2a1a06d4b7f4b1deb83c7839bd81d6be1e91626ff8a24470dde8d59e883d6fb4de42ec1e47de011cec15114808eb1ac374ff4c6f94d
7
- data.tar.gz: d2c99a00987c550646e368e1e84399a860c3bf416b816c865496c7a903bf6d1f1f5d596c8c944e55ae2ed2a70c28b198aa15950d23c9b227dd80d266fb3a4fb4
6
+ metadata.gz: fa2ee231bd40b97f8f3e16b427da2f555ee47694acbbe8c14617e8b077e71a8d0783d8f88b15b1934be02dbbebb2716245ef34c9ca3d1d14f255541a888b1f25
7
+ data.tar.gz: f99c57df386e547070bd4160c1184d20e666bdbf31d4edfd24c0360b02080747d44b3b15a9adc89e9f3f4a3c0e8f00cd7687dc9850bdef5038deb3a0975d146d
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.1
3
+ - 2.4
4
4
  before_install: gem install bundler -v 1.10.6
@@ -17,7 +17,7 @@ module MarkdownRubyDocumentation
17
17
 
18
18
  def self.format(value)
19
19
  case value
20
- when Fixnum
20
+ when Numeric
21
21
  ActiveSupport::NumberHelper.number_to_delimited(value)
22
22
  when String
23
23
  value.inspect
@@ -25,14 +25,16 @@ module MarkdownRubyDocumentation
25
25
  batches = subjects.each_slice(parallel_config.fetch(:in_threads, 2))
26
26
  threads = []
27
27
  batches.each do |batch|
28
- threads << Thread.new(batch) do |(_batch)|
29
- Array[_batch].flatten.map do |subject|
30
- progressbar.title = subject.fetch(:class).name.ljust(left_padding)
31
- Page.new(subject_class: subject.fetch(:class),
32
- subject_location: subject.fetch(:file_path).to_s,
33
- output_object: output_object,
34
- erb_methods_class: erb_methods_class,
35
- load_path: load_path).call.tap { progressbar.increment }
28
+ threads << Thread.new(batch) do |inner_batch|
29
+ Array[inner_batch].flatten.map do |subject|
30
+ progressbar.title = subject.fetch(:class).name.ljust(left_padding)
31
+ Page.new(
32
+ subject_class: subject.fetch(:class),
33
+ subject_location: subject.fetch(:file_path).to_s,
34
+ output_object: output_object,
35
+ erb_methods_class: erb_methods_class,
36
+ load_path: load_path
37
+ ).call.tap { progressbar.increment }
36
38
  end
37
39
  end
38
40
  end
@@ -8,21 +8,37 @@ module MarkdownRubyDocumentation
8
8
  end
9
9
 
10
10
  def title
11
- ancestors = subject.ancestors.select do |klass|
12
- klass.is_a?(Class) && ![BasicObject, Object, subject].include?(klass)
13
- end.sort_by { |klass| klass.name }
14
- [format_class(subject), *ancestors.map { |a| create_link(a) }].join(" < ")
11
+ [format_class(subject), *ancestors_links].join(" < ")
15
12
  end
16
13
 
17
14
  def summary
18
- descendants = ObjectSpace.each_object(Class).select { |klass| klass < subject && !klass.name.include?("InstanceToClassMethods") }.sort_by { |klass| klass.name }
19
-
20
- descendants_links = descendants.map { |d| create_link(d) }.join(", ")
21
- "Descendants: #{descendants_links}" if descendants.count >= 1
15
+ "Descendants: #{descendants_links.join(", ")}" if descendants.present?
22
16
  end
23
17
 
24
18
  private
25
19
 
20
+ def ancestors_links
21
+ ancestors.map(&method(:create_link))
22
+ end
23
+
24
+ def descendants_links
25
+ descendants.map(&method(:create_link))
26
+ end
27
+
28
+ def descendants
29
+ @descendants ||= begin
30
+ ObjectSpace.each_object(Class).select do |klass|
31
+ klass.try!(:name) && klass < subject && !(klass.name.to_s.include?("InstanceToClassMethods"))
32
+ end.sort_by(&:name)
33
+ end
34
+ end
35
+
36
+ def ancestors
37
+ subject.ancestors.select do |klass|
38
+ klass.is_a?(Class) && ![BasicObject, Object, subject].include?(klass)
39
+ end.sort_by(&:name)
40
+ end
41
+
26
42
  def create_link(klass)
27
43
  erb_methods_class.link_to_markdown(klass.to_s, title: format_class(klass))
28
44
  end
@@ -68,12 +68,7 @@ module MarkdownRubyDocumentation
68
68
 
69
69
  def get_line_number(file, word)
70
70
  return unless file && word
71
- count = 0
72
- file_or_result = File.open(file, "r") { |file| file.each_line { |line|
73
- count += 1
74
- return count if line =~ /^[\s]*#{word}/
75
- }}
76
- file_or_result.is_a?(File) ? nil : file_or_result
71
+ `grep -nr -m 1 "^[\s]*#{word}" #{file}`.match(/#{file}:(\d*)/).to_a[1].try!(:to_i)
77
72
  end
78
73
 
79
74
  def look_for_class_macro_comment(method)
@@ -88,13 +83,7 @@ module MarkdownRubyDocumentation
88
83
  end
89
84
 
90
85
  def extract_dsl_comment(comment_string)
91
- if (v = when_start_and_end(comment_string))
92
- v
93
- elsif (x = when_only_start(comment_string))
94
- x
95
- else
96
- ""
97
- end
86
+ [when_start_and_end(comment_string), when_only_start(comment_string), ""].compact.first
98
87
  end
99
88
 
100
89
  def when_start_and_end(comment_string)
@@ -1,3 +1,3 @@
1
1
  module MarkdownRubyDocumentation
2
- VERSION = "0.21.0"
2
+ VERSION = "0.21.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_ruby_documentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Zeisler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2018-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  requirements: []
162
162
  rubyforge_project:
163
- rubygems_version: 2.5.1
163
+ rubygems_version: 2.6.14
164
164
  signing_key:
165
165
  specification_version: 4
166
166
  summary: Allows creating business or technical documentation that can stays automatically