markdown_ruby_documentation 0.17.0 → 0.18.0

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: e6efdd722d791f9efbff121bc7c2d40c7681a50d
4
- data.tar.gz: 18a19452892e4518de5dc935f1a3051ad82da877
3
+ metadata.gz: 5484a31074ad298be30096b5729d76e4a2a7c611
4
+ data.tar.gz: 53dc2af956510bf4bf3cab3becf41e06f3fbba33
5
5
  SHA512:
6
- metadata.gz: 5e2e2bebb7da2bb5b740f18a3aa7372b308bef611b83e29c8165a7c35794333f0c176a9b59fb11d2a18a25fbd2d5c077ca1fddd85324bfefa8f424f440db1410
7
- data.tar.gz: 7c34cec3b8fa422ba5fd3970e00c7c464ff12e1635da6826c13561e56d3abe69bd582e5de59ff1f924295d089f8ee3fd308567fd39c81c0c84f8a2253233bc74
6
+ metadata.gz: fbf4b4d5c3e3d4ec5716106a3ce681b750e6955ba689abba45c22dff162e1e5a0004000115cb03e2abc205e5df2aa03bf67bc9c404e6a11082e92b767c729056
7
+ data.tar.gz: 3a52f13a3efca8829128addabb9f7a3edc519a4ab93cc3d417d9a4833be9354ef7068b14421b622aee06e939f3f0ecb050854a2a819711d05d4d0efd4439ae1c
data/README.md CHANGED
@@ -119,6 +119,7 @@ Converts case statements and if statements to bulleted markdown
119
119
  * constants_with_name_and_value, options: proc(replacement, match, opt={})
120
120
  * remove_memoized_vars, options: proc(replacement, match)
121
121
  * rescue_format, options: proc(replacement, match)
122
+ * boolean_blocks, options: proc(replacement, match)
122
123
 
123
124
 
124
125
  #### `format_link`
@@ -124,6 +124,7 @@ module MarkdownRubyDocumentation
124
124
  :ruby_case_statement_to_md,
125
125
  :ruby_operators_to_english,
126
126
  :nil_check_readable,
127
+ :boolean_blocks,
127
128
  :question_mark_method_format,
128
129
  :symbol_to_proc,
129
130
  :methods_as_local_links,
@@ -131,7 +132,7 @@ module MarkdownRubyDocumentation
131
132
  :constants_with_name_and_value,
132
133
  :remove_memoized_vars,
133
134
  :comment_format,
134
- :rescue_format
135
+ :rescue_format,
135
136
  ]
136
137
 
137
138
  def ruby_to_markdown(*args)
@@ -159,6 +160,13 @@ module MarkdownRubyDocumentation
159
160
  ruby_source
160
161
  end
161
162
 
163
+ def boolean_blocks(source_code=print_method_source, proc: false)
164
+ gsub_replacement(source_code, {
165
+ /(.*)\.any\?\s*do\s\|.*\|/ => "Are there any \\1 where\n",
166
+ /(.*)\.all\?\s*do\s\|.*\|/ => "Do all \\1 have\n",
167
+ }, proc: proc)
168
+ end
169
+
162
170
  def rescue_format(source_code=print_method_source, proc: false)
163
171
  gsub_replacement(source_code, {
164
172
  /=>\s.*/ => "",
@@ -376,7 +384,7 @@ module MarkdownRubyDocumentation
376
384
  method_to_class: {},
377
385
  proc: false)
378
386
  ruby_source.gsub(MethodLink::RUBY_METHOD_REGEX) do |match|
379
- if is_a_method_on_ruby_class?(match)
387
+ if is_a_method_on_ruby_class?(match, method_to_class[match.to_sym] || ruby_class)
380
388
  replacement = MethodLink.new(match: match,
381
389
  ruby_class: ruby_class,
382
390
  call_on_title: call_on_title,
@@ -488,8 +496,8 @@ module MarkdownRubyDocumentation
488
496
  source_code = source_code.gsub(/[a-z_?!0-9]+:/, &block)
489
497
  end
490
498
 
491
- def is_a_method_on_ruby_class?(method)
492
- [*ruby_class.public_instance_methods, *ruby_class.private_instance_methods].include?(remove_quotes(method).to_sym)
499
+ def is_a_method_on_ruby_class?(method, klass=ruby_class)
500
+ [*klass.public_instance_methods, *klass.private_instance_methods].include?(remove_quotes(method).to_sym)
493
501
  end
494
502
 
495
503
  def remove_quotes(string)
@@ -1,3 +1,3 @@
1
1
  module MarkdownRubyDocumentation
2
- VERSION = "0.17.0"
2
+ VERSION = "0.18.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_ruby_documentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Zeisler