ripper-tags 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ripper-tags.rb +18 -8
- data/lib/ripper-tags/parser.rb +19 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c08d7efdfd064f08e9ddfe9f04764ef7ff8c416b
|
4
|
+
data.tar.gz: 81a55c49ef2731f5df43c5d6b19293af677a82f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1d0a697a94f42071a7b1046ea5e979b21b927dd85821ff8a66047fb8fc77b8cfbb32c7e3ca4c337b421d4f13e4732d83847e47e0261c3d81a32a0fec09ff34
|
7
|
+
data.tar.gz: 5e3b0c4915d6761a30c3d146fd18a74c149621931b67c15920ca74875f67c4f1ceee5e1a2f5a8da887eebe441f661abd65a19dc78a6abbced149472896b28cb1
|
data/lib/ripper-tags.rb
CHANGED
@@ -9,7 +9,7 @@ require 'ripper-tags/vim_formatter'
|
|
9
9
|
require 'ripper-tags/json_formatter'
|
10
10
|
|
11
11
|
module RipperTags
|
12
|
-
def self.version() "0.
|
12
|
+
def self.version() "0.5.0" end
|
13
13
|
|
14
14
|
FatalError = Class.new(RuntimeError)
|
15
15
|
|
@@ -35,17 +35,24 @@ module RipperTags
|
|
35
35
|
class ForgivingOptionParser < OptionParser
|
36
36
|
attr_accessor :ignore_unsupported_options
|
37
37
|
|
38
|
-
def
|
39
|
-
argv
|
38
|
+
def load_options_file(file)
|
39
|
+
@argv.unshift(*File.readlines(file).flat_map { |line|
|
40
|
+
line.strip!.match(/(=|\s)/)
|
41
|
+
($1 == "" || $1 == "=") ? line : line.split(/\s+/, 2)
|
42
|
+
})
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def parse_in_order(argv = default_argv, *)
|
40
48
|
exceptions = []
|
41
|
-
|
49
|
+
@argv = argv
|
42
50
|
|
43
|
-
|
51
|
+
loop do
|
44
52
|
begin
|
45
|
-
|
53
|
+
super
|
46
54
|
break
|
47
55
|
rescue OptionParser::InvalidOption => err
|
48
|
-
argv -= err.args
|
49
56
|
exceptions << err
|
50
57
|
end
|
51
58
|
end
|
@@ -54,7 +61,7 @@ module RipperTags
|
|
54
61
|
raise exceptions.first
|
55
62
|
end
|
56
63
|
|
57
|
-
|
64
|
+
argv
|
58
65
|
end
|
59
66
|
end
|
60
67
|
|
@@ -151,6 +158,9 @@ module RipperTags
|
|
151
158
|
exit 1
|
152
159
|
end
|
153
160
|
end
|
161
|
+
opts.on_tail("--options=FILE", "Read additional options from file") do |file|
|
162
|
+
opts.load_options_file(file)
|
163
|
+
end
|
154
164
|
opts.on_tail("--ignore-unsupported-options", "Don't fail when unsupported options given, just skip them") do
|
155
165
|
opts.ignore_unsupported_options = true
|
156
166
|
end
|
data/lib/ripper-tags/parser.rb
CHANGED
@@ -71,9 +71,9 @@ class Parser < Ripper
|
|
71
71
|
"has_one", "has_many",
|
72
72
|
"belongs_to", "has_and_belongs_to_many",
|
73
73
|
"scope", "named_scope",
|
74
|
-
"public_class_method", "private_class_method",
|
74
|
+
"public_class_method", "private_class_method", "protected_class_method",
|
75
75
|
"public", "protected", "private",
|
76
|
-
/^attr_(accessor|reader|writer)$/
|
76
|
+
/^[mc]?attr_(accessor|reader|writer)$/
|
77
77
|
on_method_add_arg([:fcall, name], args[0])
|
78
78
|
when "delegate"
|
79
79
|
on_delegate(*Array(args[0])[1..-1])
|
@@ -171,21 +171,25 @@ class Parser < Ripper
|
|
171
171
|
[:alias, args[1][0], args[2][0], line] if args[1] && args[2]
|
172
172
|
when "define_method"
|
173
173
|
[:def, args[1][0], line]
|
174
|
-
when "public_class_method", "private_class_method", "private", "public", "protected"
|
174
|
+
when "public_class_method", "private_class_method", "protected_class_method", "private", "public", "protected"
|
175
175
|
access = name.sub("_class_method", "")
|
176
|
+
klass = name == access ? nil : 'self'
|
177
|
+
procedure = :def_with_access
|
176
178
|
|
177
|
-
if args[1][
|
178
|
-
|
179
|
+
if args[1][0].is_a?(String)
|
180
|
+
procedure = :redefine_access
|
181
|
+
method_name = args[1][0]
|
182
|
+
elsif args[1][1] == 'self'
|
179
183
|
method_name = args[1][2]
|
180
184
|
else
|
181
185
|
klass = nil
|
182
186
|
method_name = args[1][1]
|
183
187
|
end
|
184
188
|
|
185
|
-
[
|
189
|
+
[procedure, klass, method_name, access, line]
|
186
190
|
when "scope", "named_scope"
|
187
191
|
[:rails_def, :scope, args[1][0], line]
|
188
|
-
when /^attr_(accessor|reader|writer)$/
|
192
|
+
when /^[mc]?attr_(accessor|reader|writer)$/
|
189
193
|
gen_reader = $1 != 'writer'
|
190
194
|
gen_writer = $1 != 'reader'
|
191
195
|
args[1..-1].inject([]) do |gen, arg|
|
@@ -457,6 +461,14 @@ end
|
|
457
461
|
:access => access
|
458
462
|
end
|
459
463
|
|
464
|
+
def on_redefine_access(klass, name, access, line)
|
465
|
+
ns = (@namespace.empty? ? 'Object' : @namespace.join('::'))
|
466
|
+
singleton = @is_singleton || klass == 'self'
|
467
|
+
full_name = "#{ns}#{singleton ? '.' : '#'}#{name}"
|
468
|
+
tag = @tags.select { |t| t[:full_name] == full_name }.last
|
469
|
+
tag[:access] = access if tag
|
470
|
+
end
|
471
|
+
|
460
472
|
def on_rails_def(kind, name, line)
|
461
473
|
ns = (@namespace.empty?? 'Object' : @namespace.join('::'))
|
462
474
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ripper-tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aman Gupta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: fast, accurate ctags generator for ruby source code using Ripper
|
14
14
|
email:
|