ripper-plus 1.0.0 → 1.0.1

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.
data/README.md CHANGED
@@ -49,7 +49,7 @@ Need to be properly resolved. Did you know that, unlike the `label = label` exam
49
49
 
50
50
  Anyway, ripper-plus turns all method-call `:var_ref` nodes into `zcall` nodes; the node structure is otherwise unchanged.
51
51
 
52
- The truth is, everybody who is using Ripper right now *should* be doing *all* of this. Anything short, and you have bugs. [Laser](https://github.com/michaeledgar/laser/) has bugs as a result. It's a pain in the ass to get it all right. So hopefully, in Ruby 1.9.x, this will be the default. For now, you *should* use ripper-plus.
52
+ The truth is, everybody who is using Ripper right now *should* be doing *all* of this. Anything short, and you have bugs. [Laser](https://github.com/michaeledgar/laser/) has bugs as a result. It's a pain in the ass to get it all right. `ripper-plus` probably has bugs - I'm not gonna lie. So hopefully, in Ruby 1.9.x, this will be the default. For now, you *should* use ripper-plus.
53
53
 
54
54
  ## Contributing to ripper-plus
55
55
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -98,6 +98,13 @@ module RipperPlus
98
98
  transform_params(param_node, scope_stack)
99
99
  transform_tree(body, scope_stack)
100
100
  end
101
+ when :rescue
102
+ list, name, body = tree[1..3]
103
+ transform_tree(list, scope_stack)
104
+ if name
105
+ add_variables_from_lhs(name, scope_stack)
106
+ end
107
+ transform_tree(body, scope_stack)
101
108
  when :method_add_block
102
109
  call, block = tree[1..2]
103
110
  # first transform the call
@@ -0,0 +1,75 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ripper-plus}
8
+ s.version = "1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Michael Edgar"]
12
+ s.date = %q{2011-04-27}
13
+ s.description = %q{Ripper is the Ruby parser library packaged
14
+ with Ruby 1.9. While quite complete, it has some quirks that can
15
+ make use frustrating. This gem intends to correct them.}
16
+ s.email = %q{michael.j.edgar@dartmouth.edu}
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/ripper-plus.rb",
30
+ "lib/ripper-plus/ripper-plus.rb",
31
+ "lib/ripper-plus/scope_stack.rb",
32
+ "lib/ripper-plus/transformer.rb",
33
+ "ripper-plus.gemspec",
34
+ "spec/ripper-plus_spec.rb",
35
+ "spec/scope_stack_spec.rb",
36
+ "spec/spec_helper.rb",
37
+ "spec/transformer_spec.rb"
38
+ ]
39
+ s.homepage = %q{http://github.com/michaeledgar/ripper-plus}
40
+ s.licenses = ["MIT"]
41
+ s.require_paths = ["lib"]
42
+ s.rubygems_version = %q{1.7.2}
43
+ s.summary = %q{Parses Ruby code into an improved Ripper AST format}
44
+ s.test_files = [
45
+ "spec/ripper-plus_spec.rb",
46
+ "spec/scope_stack_spec.rb",
47
+ "spec/spec_helper.rb",
48
+ "spec/transformer_spec.rb"
49
+ ]
50
+
51
+ if s.respond_to? :specification_version then
52
+ s.specification_version = 3
53
+
54
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
56
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
57
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
58
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
59
+ s.add_development_dependency(%q<rcov>, [">= 0"])
60
+ else
61
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
62
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
65
+ s.add_dependency(%q<rcov>, [">= 0"])
66
+ end
67
+ else
68
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
69
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
70
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
71
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
72
+ s.add_dependency(%q<rcov>, [">= 0"])
73
+ end
74
+ end
75
+
@@ -464,4 +464,102 @@ describe RipperPlus::Transformer do
464
464
  [:bodystmt, [[:void_stmt]], nil, nil, nil]]]]
465
465
  input_tree.should transform_to output_tree
466
466
  end
467
+
468
+ it 'observes the creation of local variables by rescue clauses' do
469
+ input_tree =
470
+ [:program,
471
+ [[:def,
472
+ [:@ident, "foo", [1, 4]],
473
+ [:paren, [:params, [[:@ident, "x", [1, 8]]], nil, nil, nil, nil]],
474
+ [:bodystmt,
475
+ [[:void_stmt],
476
+ [:assign,
477
+ [:var_field, [:@ident, "y", [1, 12]]],
478
+ [:binary,
479
+ [:@int, "1", [1, 16]],
480
+ :/,
481
+ [:var_ref, [:@ident, "x", [1, 20]]]]]],
482
+ [:rescue,
483
+ [[:var_ref, [:@const, "Exception", [1, 30]]]],
484
+ [:var_field, [:@ident, "err", [1, 43]]],
485
+ [[:command,
486
+ [:@ident, "p", [1, 48]],
487
+ [:args_add_block, [[:var_ref, [:@ident, "err", [1, 50]]]], false]]],
488
+ nil],
489
+ [:else,
490
+ [[:void_stmt],
491
+ [:command,
492
+ [:@ident, "p", [1, 61]],
493
+ [:args_add_block, [[:var_ref, [:@ident, "err", [1, 63]]]], false]]]],
494
+ [:ensure,
495
+ [[:void_stmt],
496
+ [:command,
497
+ [:@ident, "p", [1, 76]],
498
+ [:args_add_block, [[:var_ref, [:@ident, "err", [1, 78]]]], false]]]]]]]]
499
+ input_tree.should transform_to input_tree
500
+ end
501
+
502
+ it 'handles rescue clauses normally otherwise' do
503
+ input_tree =
504
+ [:program,
505
+ [[:def,
506
+ [:@ident, "foo", [1, 4]],
507
+ [:paren, [:params, [[:@ident, "x", [1, 8]]], nil, nil, nil, nil]],
508
+ [:bodystmt,
509
+ [[:void_stmt],
510
+ [:assign,
511
+ [:var_field, [:@ident, "y", [1, 12]]],
512
+ [:binary,
513
+ [:@int, "1", [1, 16]],
514
+ :/,
515
+ [:var_ref, [:@ident, "x", [1, 20]]]]]],
516
+ [:rescue,
517
+ [[:var_ref, [:@const, "Exception", [1, 30]]]],
518
+ nil,
519
+ [[:command,
520
+ [:@ident, "p", [1, 48]],
521
+ [:args_add_block, [[:var_ref, [:@ident, "err", [1, 50]]]], false]]],
522
+ nil],
523
+ [:else,
524
+ [[:void_stmt],
525
+ [:command,
526
+ [:@ident, "p", [1, 61]],
527
+ [:args_add_block, [[:var_ref, [:@ident, "err", [1, 63]]]], false]]]],
528
+ [:ensure,
529
+ [[:void_stmt],
530
+ [:command,
531
+ [:@ident, "p", [1, 76]],
532
+ [:args_add_block, [[:var_ref, [:@ident, "err", [1, 78]]]], false]]]]]]]]
533
+ output_tree =
534
+ [:program,
535
+ [[:def,
536
+ [:@ident, "foo", [1, 4]],
537
+ [:paren, [:params, [[:@ident, "x", [1, 8]]], nil, nil, nil, nil]],
538
+ [:bodystmt,
539
+ [[:void_stmt],
540
+ [:assign,
541
+ [:var_field, [:@ident, "y", [1, 12]]],
542
+ [:binary,
543
+ [:@int, "1", [1, 16]],
544
+ :/,
545
+ [:var_ref, [:@ident, "x", [1, 20]]]]]],
546
+ [:rescue,
547
+ [[:var_ref, [:@const, "Exception", [1, 30]]]],
548
+ nil,
549
+ [[:command,
550
+ [:@ident, "p", [1, 48]],
551
+ [:args_add_block, [[:zcall, [:@ident, "err", [1, 50]]]], false]]],
552
+ nil],
553
+ [:else,
554
+ [[:void_stmt],
555
+ [:command,
556
+ [:@ident, "p", [1, 61]],
557
+ [:args_add_block, [[:zcall, [:@ident, "err", [1, 63]]]], false]]]],
558
+ [:ensure,
559
+ [[:void_stmt],
560
+ [:command,
561
+ [:@ident, "p", [1, 76]],
562
+ [:args_add_block, [[:zcall, [:@ident, "err", [1, 78]]]], false]]]]]]]]
563
+ input_tree.should transform_to output_tree
564
+ end
467
565
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ripper-plus
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Edgar
@@ -91,6 +91,7 @@ files:
91
91
  - lib/ripper-plus/ripper-plus.rb
92
92
  - lib/ripper-plus/scope_stack.rb
93
93
  - lib/ripper-plus/transformer.rb
94
+ - ripper-plus.gemspec
94
95
  - spec/ripper-plus_spec.rb
95
96
  - spec/scope_stack_spec.rb
96
97
  - spec/spec_helper.rb
@@ -108,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
109
  requirements:
109
110
  - - ">="
110
111
  - !ruby/object:Gem::Version
111
- hash: 505813799173151565
112
+ hash: -2160406408905027692
112
113
  segments:
113
114
  - 0
114
115
  version: "0"