markdown_ruby_documentation 0.22.1 → 0.22.2

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: 695ba171515dca96848ef72e45789206887dc79a
4
- data.tar.gz: 61fa15d573018fb904c0477cefd000eff31159e7
3
+ metadata.gz: 56a7bd11d65604831458ea29a015cd9d36ef4d96
4
+ data.tar.gz: e881c7e5bc63f6916c3ea16950fffbb008384da7
5
5
  SHA512:
6
- metadata.gz: 0f41b7f2e0141c918d1520a960034f706ada5e9d00da6d7692ea4393fdef632d77abcc7cc8472f8124660162b5f4c80fd6e076936e52ab737bdf4b0e13db40fa
7
- data.tar.gz: 8a3ab64e1eeeccc0d74a8092b5b377608b68c46bb036b89bbade86b1b5f8fc6c6587c2070941fc649b591bb6300c51fe0183a72ee701bfc2d57b62688bbf1877
6
+ metadata.gz: a8152ac56862acd3c0eb532cba93f294316251dd7e95349899e797ed3eded08c4b31d7a0a7ffb8c36e115ddff082bfad0536b30a6379d1c1f31851384aa8ee90
7
+ data.tar.gz: 94ac6b99821dccef78b13c16d2d10da7995a60030211500b3091dd6e4bd99a966dcf1486f6cdff2c3f704fd76951aa2b54b35faf174c98d98b9f8238e62a4669
@@ -50,40 +50,39 @@ module MarkdownRubyDocumentation
50
50
  @parser ||= methods.each_with_object({}) do |method, hash|
51
51
  begin
52
52
  @current_method = method
53
- value = parse_erb(insert_method_name(strip_comment_hash(extract_dsl_comment_from_method(method)), method), method)
54
- rescue MethodSource::SourceNotFoundError => e
53
+ value = compile_comment(method)
54
+ rescue MethodSource::SourceNotFoundError
55
55
  @current_method = nil
56
56
  value = false
57
57
  end
58
- if value
59
- hash[method.name] = { text: value, method_object: method }
60
- end
58
+ hash[method.name] = { text: value, method_object: method } if value
61
59
  end
62
60
  end
63
61
 
64
62
  module CommentMacros
65
63
  include Parsing
66
64
  attr_accessor :output_object
67
- # @param [String] str
65
+ # @param [String] method_reference
68
66
  # @example
69
67
  # @return [String] of any comments proceeding a method def
70
- def print_raw_comment(str)
71
- strip_comment_hash(ruby_class_meth_comment(Method.create(str, context: ruby_class)))
68
+ def print_raw_comment(method_reference)
69
+ strip_comment_hash(ruby_class_meth_comment(Method.create(method_reference, context: ruby_class)))
72
70
  end
73
71
 
74
- # @param [String] str
72
+ # @param [String] method_reference
75
73
  # @example
76
74
  # @return [String]
77
- def print_mark_doc_from(str)
78
- method = Method.create(str, context: ruby_class)
79
- parse_erb(insert_method_name(extract_dsl_comment(print_raw_comment(str)), method), method)
75
+ def print_mark_doc_from(method_reference)
76
+ method = Method.create(method_reference, context: ruby_class)
77
+ comment = extract_dsl_comment(print_raw_comment(method_reference))
78
+ compile_comment(method, comment)
80
79
  end
81
80
 
82
- # @param [String] str
81
+ # @param [String] method_reference
83
82
  # @example
84
83
  # @return [Object] anything that the evaluated method would return.
85
- def eval_method(str=current_method)
86
- case (method = Method.create(str, context: ruby_class))
84
+ def eval_method(method_reference=current_method)
85
+ case (method = Method.create(method_reference, context: ruby_class))
87
86
  when ClassMethod
88
87
  method.context.public_send(method.name)
89
88
  when InstanceMethod
@@ -526,6 +525,10 @@ module MarkdownRubyDocumentation
526
525
  end
527
526
  source_code
528
527
  end
528
+
529
+ def compile_comment(method, comment = extract_dsl_comment_from_method(method))
530
+ parse_erb(insert_method_name(strip_comment_hash(comment), method), method)
531
+ end
529
532
  end
530
533
 
531
534
  include CommentMacros
@@ -4,30 +4,30 @@ module MarkdownRubyDocumentation
4
4
  def parse_erb(str, method)
5
5
  filename, lineno = ruby_class_meth_source_location(method)
6
6
  adjusted_lineno = (lineno - ruby_class_meth_comment(method).split("\n").count-1)
7
- ruby_class.module_eval(<<-RUBY, __FILE__, __LINE__+1)
7
+ method.context.module_eval(<<-RUBY, __FILE__, __LINE__+1)
8
8
  def self.get_binding
9
9
  self.send(:binding)
10
10
  end
11
11
  RUBY
12
- ruby_class.send(:define_singleton_method, :current_method) do
12
+ method.context.send(:define_singleton_method, :current_method) do
13
13
  method
14
14
  end
15
15
 
16
- ruby_class.send(:define_singleton_method, :output_object) do
16
+ method.context.send(:define_singleton_method, :output_object) do
17
17
  output_object
18
18
  end
19
19
 
20
- ruby_class.send(:define_singleton_method, :load_path) do
20
+ method.context.send(:define_singleton_method, :load_path) do
21
21
  load_path
22
22
  end
23
23
 
24
- ruby_class.extend(CommentMacros)
24
+ method.context.extend(CommentMacros)
25
25
 
26
26
  erb = ERB.new(str, nil, "-")
27
27
 
28
28
  erb.lineno = adjusted_lineno if erb.respond_to?(:lineno)
29
29
  erb.filename = filename if erb.respond_to?(:filename)
30
- erb.result(ruby_class.get_binding)
30
+ erb.result(method.context.get_binding)
31
31
  rescue => e
32
32
  raise e.class, e.message, ["#{filename}:#{adjusted_lineno}:in `#{method.name}'", *e.backtrace]
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module MarkdownRubyDocumentation
2
- VERSION = "0.22.1"
2
+ VERSION = "0.22.2"
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.22.1
4
+ version: 0.22.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Zeisler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-16 00:00:00.000000000 Z
11
+ date: 2018-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source