parser 3.0.0.0 → 3.0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -305,6 +305,11 @@ module Parser
305
305
  super
306
306
  end
307
307
 
308
+ # :nodoc:
309
+ def inspect
310
+ "#<#{self.class} #{name}>"
311
+ end
312
+
308
313
  private
309
314
 
310
315
  # @returns [0, line_begin_of_line_1, ..., source.size + 1]
@@ -330,6 +330,11 @@ module Parser
330
330
  @in_transaction
331
331
  end
332
332
 
333
+ # :nodoc:
334
+ def inspect
335
+ "#<#{self.class} #{source_buffer.name}: #{action_summary}>"
336
+ end
337
+
333
338
  ##
334
339
  # @api private
335
340
  # @deprecated Use insert_after or wrap
@@ -361,6 +366,28 @@ module Parser
361
366
 
362
367
  private
363
368
 
369
+ def action_summary
370
+ replacements = as_replacements
371
+ case replacements.size
372
+ when 0 then return 'empty'
373
+ when 1..3 then #ok
374
+ else
375
+ replacements = replacements.first(3)
376
+ suffix = '…'
377
+ end
378
+ parts = replacements.map do |(range, str)|
379
+ if str.empty? # is this a deletion?
380
+ "-#{range.to_range}"
381
+ elsif range.size == 0 # is this an insertion?
382
+ "+#{str.inspect}@#{range.begin_pos}"
383
+ else # it is a replacement
384
+ "^#{str.inspect}@#{range.to_range}"
385
+ end
386
+ end
387
+ parts << suffix if suffix
388
+ parts.join(', ')
389
+ end
390
+
364
391
  ACTIONS = %i[accept warn raise].freeze
365
392
  def check_policy_validity
366
393
  invalid = @policy.values - ACTIONS
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parser
4
- VERSION = '3.0.0.0'
4
+ VERSION = '3.0.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.0
4
+ version: 3.0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - whitequark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-25 00:00:00.000000000 Z
11
+ date: 2021-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast
@@ -244,9 +244,9 @@ licenses:
244
244
  - MIT
245
245
  metadata:
246
246
  bug_tracker_uri: https://github.com/whitequark/parser/issues
247
- changelog_uri: https://github.com/whitequark/parser/blob/v3.0.0.0/CHANGELOG.md
248
- documentation_uri: https://www.rubydoc.info/gems/parser/3.0.0.0
249
- source_code_uri: https://github.com/whitequark/parser/tree/v3.0.0.0
247
+ changelog_uri: https://github.com/whitequark/parser/blob/v3.0.1.0/CHANGELOG.md
248
+ documentation_uri: https://www.rubydoc.info/gems/parser/3.0.1.0
249
+ source_code_uri: https://github.com/whitequark/parser/tree/v3.0.1.0
250
250
  post_install_message:
251
251
  rdoc_options: []
252
252
  require_paths: