yard-link_stdlib 0.1.2 → 0.1.3

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: 35b7b23700c4d77f2a017aa1881974617980d255
4
- data.tar.gz: 475ee0d06dfc6d358398e59eb6a80bccc09b8e8c
3
+ metadata.gz: 3334c95ebde62bc497aaab158361d28cb88bcb3e
4
+ data.tar.gz: 04117641eaf696120948d32d3e23354308e33d77
5
5
  SHA512:
6
- metadata.gz: 9b2b26d8c1f3facd41e9b171d48138672a2cd8db0b166faf099ebafb3fffb2cae93150b9947f2a8660e195285b3d10e7fb86f062fc4a221fcf18ff51a5086809
7
- data.tar.gz: ea374fb3df62ffcac1e5af88277bd7f96af1b0d8c9df342e801a84f67862a0895671f2e53f309c13f112a4944e3f9883f5a1f784afd4052ef0206bf36ded7fe5
6
+ metadata.gz: f5c660eb08a0a7656e305771d7603788b8396bec4221ee2c3030137e7ad7cfbef4682ee3a481fe62b84b3a0cd8b6972abfdc82d0fda9f39ea9ed778f161eb113
7
+ data.tar.gz: 227aa9d466ab557c835d84c581d205b79dbe993dd62fea51c868e03b0b9a8f60418944257ea20003717b060fb2fd56e2ad2dcd4e5a14a2764c0012a72275d8cd
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -294,7 +294,14 @@ class LinkStdlib < Command
294
294
  exit true
295
295
  end
296
296
 
297
- terms = args.map { |arg| Regexp.new arg }
297
+ terms = args.map { |arg|
298
+ begin
299
+ Regexp.new arg
300
+ rescue RegexpError => error
301
+ Regexp.new \
302
+ Regexp.escape( YARD::LinkStdlib.normalize_name( arg ) )
303
+ end
304
+ }
298
305
 
299
306
  log.debug "Terms:\n " + terms.map( &:to_s ).join( "\n " )
300
307
 
@@ -64,6 +64,31 @@ module LinkStdlib
64
64
  }.freeze
65
65
 
66
66
 
67
+ # Names of valid Ruby operator methods. Used to form
68
+ # {OPERATOR_METHOD_NAME_REGEXP_FRAGMENT}.
69
+ #
70
+ # @return [::Array<::String>]
71
+ #
72
+ OPERATOR_METHOD_NAMES = \
73
+ (
74
+ %w([] []= ** ~ ~ @+ @- * / % + - >> << & ^ |) +
75
+ %w(<= < > >= <=> == === != =~ !~)
76
+ ).map( &:freeze )
77
+
78
+
79
+ # {Regexp} source fragment that matches a Ruby operator method name.
80
+ #
81
+ # Used in {.normalize_name} to swap out '.' separators for '::' in operator
82
+ # methods.
83
+ #
84
+ # @return [::String]
85
+ #
86
+ OPERATOR_METHOD_NAME_REGEXP_FRAGMENT = \
87
+ OPERATOR_METHOD_NAMES.
88
+ map { |op_name| "(?:#{ Regexp.escape op_name })" }
89
+ .join '|'
90
+
91
+
67
92
  # Singleton Methods
68
93
  # ==========================================================================
69
94
 
@@ -267,6 +292,10 @@ module LinkStdlib
267
292
  # YARD::LinkStdlib.normalize_name 123
268
293
  # #=> raise TypeError, %(`name` must be a String, given Fixnum: 123)
269
294
  #
295
+ # @example Handle operator singleton methods separated by '.'
296
+ # YARD::LinkStdlib.normalize_name 'Dir.[]'
297
+ # #=> 'Dir::[]'
298
+ #
270
299
  # @param [::String] name
271
300
  # Code object name, as it may appear in YARD.
272
301
  #
@@ -278,14 +307,15 @@ module LinkStdlib
278
307
  "`name` must be a String, given #{ name.class }: #{ name.inspect }"
279
308
  end
280
309
 
281
- # Strip off any leading `::`
282
- if name.start_with? '::'
283
- name = name[ 2..-1 ]
284
- end
285
-
286
310
  # Stdlib rdoc uses `ClassOrModule::class_method` format for class methods,
287
- # so we want to convert to that
288
- name.sub /\.(\w+[\?\!]?)\z/, '::\1'
311
+ # so we want to convert to that, and strip off any leading '::'
312
+ name.
313
+ # Strip off any leading '::'
314
+ sub( /\A::/, '' ).
315
+ # Convert most singleton methods using '.' to '::' (except operators)
316
+ sub( /\.(\w+[\?\!]?)\z/, '::\1' ).
317
+ # Convert operator singleton methods using '.' to '::'
318
+ sub( /\.(#{ OPERATOR_METHOD_NAME_REGEXP_FRAGMENT })\z/, '::\1' )
289
319
  end # .normalize_name
290
320
 
291
321
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-link_stdlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-13 00:00:00.000000000 Z
11
+ date: 2019-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard