flay 2.11.0 → 2.12.0

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ba894eeca0c7966356ccb85f9252f47cf27e2ee34252288502cc70c50aa4d64
4
- data.tar.gz: eb4552d71f43350ec698c3ef36a17d0b18b93c65e54666240af786952ed8e512
3
+ metadata.gz: 3477e1943a1382b0b51cbce9a5e4f5b60c34adc2f38e1e4b713b05f6b7476160
4
+ data.tar.gz: 042ef82c48aec49077113d53cbe425e6157fd61b36e7118af18dc7369561e77e
5
5
  SHA512:
6
- metadata.gz: 921301e4deb3c56b8eaf8fa1078ddb20f5bb9a3bf298ecea377df3440b8fc6e17f2475fbc31a1009b66042876289082bf61139bc982293c5530a51975966f793
7
- data.tar.gz: 25e52c615125a7d06f59b41d1191dfca7c56a861d1c4a968f188dedd231b9d64fe84ab6c223526af10785e70b488600be4a4840754291b5408056cd9e11f7a82
6
+ metadata.gz: c05914fd7779c957f60e6e8f32d04a4069d427cf6ecb57b7be97fd53cd9d07969c0076bad6978077f09e47d73a5d7c76c5795233f846a20bc22aef2abbb41dad
7
+ data.tar.gz: bdcc376f6c7651d1fe4d7ace6349a945a221fc89152bba731719ec4083996b98d98358e6b2506fa58ca6d919dd07d99433f3c6942e0639062909f4e1d55e44e6
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,9 @@
1
+ === 2.12.0 / 2018-04-29
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Switched node filtering to happen before processing to avoid subtrees getting processed. Thanks to codeclimate.com for funding this effort!
6
+
1
7
  === 2.11.0 / 2018-04-05
2
8
 
3
9
  * 2 minor enhancements:
@@ -17,7 +17,7 @@ class File
17
17
  end
18
18
 
19
19
  class Flay
20
- VERSION = "2.11.0" # :nodoc:
20
+ VERSION = "2.12.0" # :nodoc:
21
21
 
22
22
  class Item < Struct.new(:structural_hash, :name, :bonus, :mass, :locations)
23
23
  alias identical? bonus
@@ -280,14 +280,26 @@ class Flay
280
280
  end
281
281
  end
282
282
 
283
+ ##
284
+ # Before processing, filter any sexp's that match against filters
285
+ # specified in +option[:filters]+. This changes the sexp itself.
286
+
287
+ def filter_sexp exp
288
+ exp.delete_if { |sexp|
289
+ if Sexp === sexp then
290
+ del = option[:filters].any? { |pattern| pattern.satisfy? sexp }
291
+ del or (filter_sexp(sexp); false)
292
+ end
293
+ }
294
+ end
295
+
283
296
  ##
284
297
  # Process a sexp +pt+.
285
298
 
286
299
  def process_sexp pt
287
- pt.deep_each do |node|
300
+ filter_sexp(pt).deep_each do |node|
288
301
  next :skip if node.none? { |sub| Sexp === sub }
289
302
  next :skip if node.mass < self.mass_threshold
290
- next :skip if option[:filters].any? { |pattern| pattern.satisfy? node }
291
303
 
292
304
  self.hashes[node.structural_hash] << node
293
305
 
@@ -330,22 +342,6 @@ class Flay
330
342
  end
331
343
  end
332
344
 
333
- ##
334
- # Given an array of sexp patterns (see sexp_processor), delete any
335
- # buckets whose members match any of the patterns.
336
-
337
- def filter *patterns
338
- return if patterns.empty?
339
-
340
- self.hashes.delete_if { |_, sexps|
341
- sexps.any? { |sexp|
342
- patterns.any? { |pattern|
343
- pattern =~ sexp
344
- }
345
- }
346
- }
347
- end
348
-
349
345
  ##
350
346
  # Prunes nodes that aren't relevant to analysis or are already
351
347
  # covered by another node. Also deletes nodes based on the
@@ -361,8 +357,6 @@ class Flay
361
357
  else
362
358
  prune_conservatively
363
359
  end
364
-
365
- self.filter(*option[:filters])
366
360
  end
367
361
 
368
362
  ##
@@ -450,13 +450,12 @@ class TestSexp < Minitest::Test
450
450
  exp_foo = s(:begin,
451
451
  s(:begin,
452
452
  s(:filter_me,
453
- s(:a, s(:b)))))
453
+ s(:a, s(:b, s(:c, s(:d)))))))
454
454
 
455
455
  exp_bar = s(:begin,
456
456
  s(:begin,
457
457
  s(:filter_me,
458
- s(:a, s(:b)),
459
- s(:c))))
458
+ s(:a, s(:b, s(:c, s(:d)))))))
460
459
 
461
460
  filter = Sexp::Matcher.parse("(filter_me ___)")
462
461
  options = Flay.default_options.merge(mass: 0, filters: [filter])
@@ -467,8 +466,6 @@ class TestSexp < Minitest::Test
467
466
 
468
467
  refute_nodes :filter_me
469
468
 
470
- flay.prune
471
-
472
469
  assert_empty flay.hashes
473
470
  end
474
471
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flay
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.0
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -29,7 +29,7 @@ cert_chain:
29
29
  AhXhF6Wi2GTMezlj5jlI5XV7WsJUSwTp/YiVvcmT74ZaCRvexm6EnNhkrvJJ1Xeu
30
30
  V+HB+LYYhXWitInO/eXxDrFB
31
31
  -----END CERTIFICATE-----
32
- date: 2018-04-05 00:00:00.000000000 Z
32
+ date: 2018-04-30 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: sexp_processor
metadata.gz.sig CHANGED
@@ -1,3 +1,3 @@
1
- 9l����J5u���6��tO�
2
- 7���ٞ�g��� ��}6��Lf�{���h탸��C�/�o'V��IwHC6
3
- �m@���VxfwQ���M��]2�Ј ���4�>?v㤺���fE���$]!��1}-F���`��ܨ���y4q\�5�\��MG�����G2ޭŔ�����%K���_�z�_�^�8|��U�<p�%�+��:�Wg%h�fΥ7���zB�1���F��![B尗L-%��w���
1
+
2
+ ���x�����v����#�\����]�}gh�%l�]��/���Z+����R�{'gm�&j�x����n���� G${�~�9�����a4�&�R��Rpf]b�p�mSC�IQ��k(-~~<\�Z� _�^(��� �ט`�!e����"�M�jRW�ry��{e�����wRg%�&cn$�b����
3
+ ��V��l����e��_�ӽ��B=C�ܸ��HH�� |d�넷���߉_��d