ripper-tags 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTY5YzNjZGUwOTNkOGMwMzM0NTY1MjE3ZDc4MDkyNjVkNjM2ZDBhNw==
4
+ Yzc2MzlhZjllZTM4NTk1OWMzNmU3ZjkyNDIxNjVmYTk1NmJiOGJhZA==
5
5
  data.tar.gz: !binary |-
6
- MWM1M2IzYTk2ODgyZjEwZjQ5ODVlZDYzN2E1Nzc1NGEzOWRmYTI0Ng==
6
+ ZDlmM2U4YmUyNzZkMGY3OTkxNTRmNWRjMGQxZTk1YjQzN2NiZGZlZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDM5MWNkMjk2Y2YxODE2ZTMxODcyY2I3ODcwN2M1YmY5ODFjZGU1ZWI3Mjhj
10
- YmIzMzAwMDcyZWM0ZmMxZTA3MTkxYTA0ODk1N2MwY2EwMzUxMTZmZDg1ZDQz
11
- YzljYWE2NzEzZDY1YTVlOGQ0MDViNjJmYzBlMzJkNmYzZThkOTU=
9
+ Zjg2MDJmOTg4Y2UwYTA4MzI0ZDUwNWEzYWY3ZGZkYmE5ZTQ5YTRkN2FkMWZm
10
+ MmQ1ODdmNmZhNWYwYzA1MzM4ZWY1OWNlMTU2M2VmNjI3MWNiYWVlZGJhY2M3
11
+ MTEzNGQ3NDQ1ZmUyOGVlNjRlM2I0Njc4YzdjN2M3ZjNiOWQ3YjU=
12
12
  data.tar.gz: !binary |-
13
- ZWU2ZDQ5Nzc0MzAyNjNjYjI0YjU5MTczMjRkMDUwZTJiZWRhN2Y2Y2YwYmQz
14
- Yzg5MDg3MDJkOTMzNzIyMmI2ZjQzNzliYmIwMzIyNzliNzYzMWQxNjFlZTMz
15
- MDAxNzVlZjk2YmRjMDlhYTZiYTAzMDRkYjViNjFjYTNlNDgwZGI=
13
+ NGY3N2YxMzU0NDM2MmIyNjRiZGU4MmUwNThmYzE2YjVjMWFlMjdmMzMwMTkx
14
+ NzkxZWViZWZjMzRhNmRjZDYxYjQ2ZWNhNGI2MWI1ZjNhZTlmODBjN2VmYjcy
15
+ ZjNkYjU0MjE4MTlhZmI5Nzc1ZDBkZTcwNDYxYTA4NmFhZDI5NTc=
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  tags
2
2
  TAGS
3
3
  ripper-tags-*gem
4
+ *.swp
5
+ Gemfile.lock
@@ -144,22 +144,26 @@ class Parser < Ripper
144
144
  gen
145
145
  end
146
146
  when "has_many", "has_and_belongs_to_many"
147
- a = args[1][0]
147
+ a = args[1][0].to_s
148
148
  kind = name.to_sym
149
149
  gen = []
150
- gen << [:rails_def, kind, a, line]
151
- gen << [:rails_def, kind, "#{a}=", line]
152
- if (sing = a.chomp('s')) != a
153
- # poor man's singularize
154
- gen << [:rails_def, kind, "#{sing}_ids", line]
155
- gen << [:rails_def, kind, "#{sing}_ids=", line]
150
+ unless a.is_a?(Enumerable)
151
+ gen << [:rails_def, kind, a, line]
152
+ gen << [:rails_def, kind, "#{a}=", line]
153
+ if a.respond_to?(:chomp) && (sing = a.chomp('s')) != a
154
+ # poor man's singularize
155
+ gen << [:rails_def, kind, "#{sing}_ids", line]
156
+ gen << [:rails_def, kind, "#{sing}_ids=", line]
157
+ end
156
158
  end
157
159
  gen
158
160
  when "belongs_to", "has_one"
159
161
  a = args[1][0]
160
- kind = name.to_sym
161
- %W[ #{a} #{a}= build_#{a} create_#{a} create_#{a}! ].inject([]) do |gen, ident|
162
- gen << [:rails_def, kind, ident, line]
162
+ unless a.is_a?(Enumerable)
163
+ kind = name.to_sym
164
+ %W[ #{a} #{a}= build_#{a} create_#{a} create_#{a}! ].inject([]) do |gen, ident|
165
+ gen << [:rails_def, kind, ident, line]
166
+ end
163
167
  end
164
168
  end
165
169
  else
@@ -244,7 +248,8 @@ end
244
248
  sexp.each{ |child| process(child) }
245
249
  when Symbol
246
250
  name, *args = sexp
247
- __send__("on_#{name}", *args)
251
+ handler = "on_#{name}"
252
+ __send__(handler, *args) if respond_to?(handler)
248
253
  when String, nil
249
254
  # nothing
250
255
  end
@@ -283,7 +288,7 @@ end
283
288
  on_module_or_class(:module, name, nil, body)
284
289
  end
285
290
 
286
- def on_class(name, superclass, body)
291
+ def on_class(name, superclass, body = nil)
287
292
  on_module_or_class(:class, name, superclass, body)
288
293
  end
289
294
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ripper-tags'
3
- s.version = '0.1.2'
3
+ s.version = '0.1.3'
4
4
 
5
5
  s.summary = 'ctags generator for ruby code'
6
6
  s.description = 'fast, accurate ctags generator for ruby source code using Ripper'
@@ -41,7 +41,7 @@ class DataReaderTest < Test::Unit::TestCase
41
41
  very/deep/script.rb
42
42
  very/inter.rb
43
43
  ]
44
- assert_equal expected, files
44
+ assert_equal Set.new(expected), Set.new(files)
45
45
  end
46
46
 
47
47
  def test_file_finder_no_exclude
@@ -61,7 +61,7 @@ class DataReaderTest < Test::Unit::TestCase
61
61
  encoding.rb
62
62
  very/inter.rb
63
63
  ]
64
- assert_equal expected, files
64
+ assert_equal Set.new(expected), Set.new(files)
65
65
  end
66
66
 
67
67
  def with_default_encoding(name)
@@ -295,4 +295,48 @@ class TagRipperTest < Test::Unit::TestCase
295
295
  assert_equal '2: scope C.red', inspect(tags[1])
296
296
  assert_equal '3: scope C.red', inspect(tags[2])
297
297
  end
298
+
299
+ def test_extract_from_erb
300
+ tags = extract(<<-EOC)
301
+ class NavigationTest < ActionDispatch::IntegrationTest
302
+ <% unless options[:skip_active_record] -%>
303
+ fixtures :all
304
+ <% end -%>
305
+
306
+ # test "the truth" do
307
+ # assert true
308
+ # end
309
+ end
310
+ EOC
311
+
312
+ assert_equal 1, tags.size
313
+ assert_equal 'NavigationTest', tags[0][:name]
314
+ end
315
+
316
+ def test_extract_with_keyword_variables
317
+ tags = extract(<<-EOC)
318
+ class Foo
319
+ @public
320
+ @protected
321
+ @private
322
+ end
323
+ EOC
324
+
325
+ assert_equal 1, tags.size
326
+ assert_equal 'Foo', tags[0][:name]
327
+ end
328
+
329
+ def test_extract_associations_with_class_name
330
+ tags = extract(<<-EOC)
331
+ class Foo
332
+ belongs_to Bar
333
+ has_one Bar
334
+ has_and_belongs_to_many Bar
335
+ has_many Bar
336
+ end
337
+ EOC
338
+
339
+ assert_equal 1, tags.size
340
+ assert_equal 'Foo', tags[0][:name]
341
+ end
298
342
  end
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.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aman Gupta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-28 00:00:00.000000000 Z
11
+ date: 2013-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby