mvz-live_ast 2.1.1 → 2.2.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 +4 -4
- data/CHANGES.rdoc +11 -0
- data/README.rdoc +2 -2
- data/lib/live_ast/ast_eval.rb +2 -2
- data/lib/live_ast/base.rb +2 -2
- data/lib/live_ast/common.rb +17 -15
- data/lib/live_ast/evaler.rb +5 -12
- data/lib/live_ast/linker.rb +7 -6
- data/lib/live_ast/reader.rb +2 -2
- data/lib/live_ast/replace_caller.rb +3 -2
- data/lib/live_ast/replace_eval.rb +10 -7
- data/lib/live_ast/replace_raise.rb +2 -2
- data/lib/live_ast/version.rb +1 -1
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55a4905b0508e1fb40901c7459dba58c4955dd176c37c3d420e105754588707e
|
4
|
+
data.tar.gz: 8d1e9426cbb0eb669047fe8e73717012f4c5493b63a8971152c5dfb261bc5959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4465fa6540167ff69f472dcba3a881e4ef039795eaaeb2d79e7cb95142de456047fd9b42589779889875bb2ed30508160361a89dc43d91a81c470a76b288345b
|
7
|
+
data.tar.gz: 1cc74db8fed7f2a011a142fa44ce86e1e56a082a571b7a66104a5ed2b63f340f3f7ea2a7fe7b8d944a55b92f151818a558d688b497737aa7858cb9076daeb27d
|
data/CHANGES.rdoc
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
= live_ast Changes
|
2
2
|
|
3
|
+
== Version 2.2.0
|
4
|
+
|
5
|
+
* Improve error message compatibility for instance_eval filename argument
|
6
|
+
* Drop support for Ruby 2.7
|
7
|
+
* Fix source location for eval with binding and no location
|
8
|
+
* Add support for Ruby 3.2 and 3.3
|
9
|
+
|
10
|
+
== Version 2.1.2
|
11
|
+
|
12
|
+
* Raise informative acception for methods defined in the prelude
|
13
|
+
|
3
14
|
== Version 2.1.1
|
4
15
|
|
5
16
|
* Loosen dependency on ruby2ruby
|
data/README.rdoc
CHANGED
@@ -80,7 +80,7 @@ sexps used by tools such as <code>ruby2ruby</code>.
|
|
80
80
|
|
81
81
|
LiveAST is thread-safe.
|
82
82
|
|
83
|
-
Ruby 2.
|
83
|
+
Ruby 2.7.0 or higher is required.
|
84
84
|
|
85
85
|
== Links
|
86
86
|
|
@@ -384,7 +384,7 @@ assumed that the file is unmodified between the moment it is
|
|
384
384
|
== License
|
385
385
|
|
386
386
|
Copyright (c) 2011 James M. Lawrence. All rights reserved.
|
387
|
-
Copyright (c) 2014 Matijs van Zuijlen. All rights reserved.
|
387
|
+
Copyright (c) 2014-2022 Matijs van Zuijlen. All rights reserved.
|
388
388
|
|
389
389
|
Permission is hereby granted, free of charge, to any person
|
390
390
|
obtaining a copy of this software and associated documentation files
|
data/lib/live_ast/ast_eval.rb
CHANGED
@@ -7,7 +7,7 @@ module Kernel
|
|
7
7
|
|
8
8
|
# The same as +eval+ except that the binding argument is required
|
9
9
|
# and AST-accessible objects are created.
|
10
|
-
def ast_eval(
|
11
|
-
LiveAST::Evaler.eval(
|
10
|
+
def ast_eval(string, bind, filename = nil, lineno = nil)
|
11
|
+
LiveAST::Evaler.eval(string, string, bind, filename, lineno)
|
12
12
|
end
|
13
13
|
end
|
data/lib/live_ast/base.rb
CHANGED
@@ -51,8 +51,8 @@ module LiveAST
|
|
51
51
|
#
|
52
52
|
# Equivalent to <code>Kernel#ast_eval</code>.
|
53
53
|
#
|
54
|
-
def eval(
|
55
|
-
Evaler.eval(
|
54
|
+
def eval(string, bind, filename = nil, lineno = nil) # :nodoc:
|
55
|
+
Evaler.eval(string, string, bind, filename, lineno)
|
56
56
|
end
|
57
57
|
|
58
58
|
#
|
data/lib/live_ast/common.rb
CHANGED
@@ -7,18 +7,25 @@ module LiveAST
|
|
7
7
|
def arg_to_str(arg)
|
8
8
|
arg.to_str
|
9
9
|
rescue NameError
|
10
|
-
thing = arg
|
10
|
+
thing = arg&.class
|
11
11
|
|
12
12
|
message = "no implicit conversion of #{thing.inspect} into String"
|
13
13
|
raise TypeError, message
|
14
14
|
end
|
15
15
|
|
16
16
|
def arg_to_str2(arg)
|
17
|
+
return "" if arg.nil? && RUBY_VERSION >= "3.3.0"
|
18
|
+
|
17
19
|
arg.to_str
|
18
20
|
rescue NameError
|
19
|
-
thing = arg
|
21
|
+
thing = arg&.class
|
22
|
+
|
23
|
+
message = if arg.nil?
|
24
|
+
"wrong argument type #{thing.inspect} (expected String)"
|
25
|
+
else
|
26
|
+
"no implicit conversion of #{thing.inspect} into String"
|
27
|
+
end
|
20
28
|
|
21
|
-
message = "wrong argument type #{thing.inspect} (expected String)"
|
22
29
|
raise TypeError, message
|
23
30
|
end
|
24
31
|
|
@@ -38,18 +45,13 @@ module LiveAST
|
|
38
45
|
raise TypeError, message
|
39
46
|
end
|
40
47
|
|
41
|
-
def location_for_eval(
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
when 1
|
49
|
-
[location.first, 1]
|
50
|
-
else
|
51
|
-
location
|
52
|
-
end
|
48
|
+
def location_for_eval(bind, filename = nil, lineno = nil)
|
49
|
+
if filename
|
50
|
+
lineno ||= 1
|
51
|
+
[filename, lineno]
|
52
|
+
elsif RUBY_VERSION >= "3.3.0"
|
53
|
+
file, line = bind.source_location
|
54
|
+
["(eval at #{file}:#{line})", 1]
|
53
55
|
else
|
54
56
|
["(eval)", 1]
|
55
57
|
end
|
data/lib/live_ast/evaler.rb
CHANGED
@@ -5,10 +5,12 @@ module LiveAST
|
|
5
5
|
class << self
|
6
6
|
include Common
|
7
7
|
|
8
|
-
def eval(parser_source,
|
9
|
-
evaler_source
|
8
|
+
def eval(parser_source, evaler_source, bind, filename = nil, lineno = nil)
|
9
|
+
evaler_source = arg_to_str evaler_source
|
10
|
+
check_is_binding bind
|
11
|
+
filename = arg_to_str filename if filename
|
10
12
|
|
11
|
-
file, line = location_for_eval(bind,
|
13
|
+
file, line = location_for_eval(bind, filename, lineno)
|
12
14
|
file = LiveAST.strip_token(file)
|
13
15
|
|
14
16
|
key, = Linker.new_cache_synced(parser_source, file, line, false)
|
@@ -20,15 +22,6 @@ module LiveAST
|
|
20
22
|
raise e
|
21
23
|
end
|
22
24
|
end
|
23
|
-
|
24
|
-
def handle_args(*args)
|
25
|
-
args.tap do
|
26
|
-
check_arity(args, 2..4)
|
27
|
-
args[0] = arg_to_str(args[0])
|
28
|
-
check_is_binding(args[1])
|
29
|
-
args[2] = arg_to_str(args[2]) if args[2]
|
30
|
-
end
|
31
|
-
end
|
32
25
|
end
|
33
26
|
end
|
34
27
|
end
|
data/lib/live_ast/linker.rb
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
module LiveAST
|
4
4
|
class Cache
|
5
|
-
def initialize(
|
6
|
-
@source
|
5
|
+
def initialize(file, lineno)
|
6
|
+
@source = file
|
7
|
+
@user_line = lineno
|
7
8
|
@asts = nil
|
8
9
|
end
|
9
10
|
|
@@ -73,6 +74,8 @@ module LiveAST
|
|
73
74
|
def find_ast(*location)
|
74
75
|
raise ASTNotFoundError unless location.size == 2
|
75
76
|
raise RawEvalError if location.first == "(eval)"
|
77
|
+
raise RawEvalError if location.first.match?(/^\(eval at .*\)$/) # Ruby 3.3
|
78
|
+
raise ASTNotFoundError if location.first == "<internal:prelude>"
|
76
79
|
|
77
80
|
ast = fetch_from_cache(*location)
|
78
81
|
raise MultipleDefinitionsOnSameLineError if ast == :multiple
|
@@ -108,10 +111,8 @@ module LiveAST
|
|
108
111
|
return key, cache
|
109
112
|
end
|
110
113
|
|
111
|
-
def new_cache_synced(
|
112
|
-
@mutex.synchronize
|
113
|
-
new_cache(*args)
|
114
|
-
end
|
114
|
+
def new_cache_synced(...)
|
115
|
+
@mutex.synchronize { new_cache(...) }
|
115
116
|
end
|
116
117
|
|
117
118
|
def flush_cache
|
data/lib/live_ast/reader.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
|
4
4
|
module LiveAST
|
5
5
|
module Reader
|
6
|
-
UTF8_BOM = /\A\xef\xbb\xbf
|
7
|
-
MAGIC_COMMENT = /\A(?:#!.*?\n)?\s*\#.*(?:en)?coding\s*[:=]\s*([^\s;]+)
|
6
|
+
UTF8_BOM = /\A\xef\xbb\xbf/
|
7
|
+
MAGIC_COMMENT = /\A(?:#!.*?\n)?\s*\#.*(?:en)?coding\s*[:=]\s*([^\s;]+)/
|
8
8
|
|
9
9
|
def self.read(file)
|
10
10
|
contents = File.read(file, encoding: "BINARY")
|
@@ -53,12 +53,11 @@ module Kernel
|
|
53
53
|
|
54
54
|
alias live_ast_original_eval eval
|
55
55
|
|
56
|
-
def eval(
|
57
|
-
LiveAST::Common.check_arity(args, 1..4)
|
56
|
+
def eval(string, binding = nil, filename = nil, lineno = nil)
|
58
57
|
LiveAST.eval(
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
string,
|
59
|
+
binding || Binding.of_caller(1),
|
60
|
+
filename, lineno)
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
@@ -66,8 +65,8 @@ end
|
|
66
65
|
class Binding
|
67
66
|
alias live_ast_original_binding_eval eval
|
68
67
|
|
69
|
-
def eval(
|
70
|
-
LiveAST.eval(
|
68
|
+
def eval(string, filename = nil, lineno = nil)
|
69
|
+
LiveAST.eval(string, self, filename, lineno)
|
71
70
|
end
|
72
71
|
end
|
73
72
|
|
@@ -75,6 +74,8 @@ end
|
|
75
74
|
class BasicObject
|
76
75
|
alias live_ast_original_instance_eval instance_eval
|
77
76
|
|
77
|
+
# Arity must be handled in code because the first argument is only required
|
78
|
+
# if no block is passed.
|
78
79
|
def instance_eval(*args, &block)
|
79
80
|
if block
|
80
81
|
live_ast_original_instance_eval(*args, &block)
|
@@ -92,6 +93,8 @@ end
|
|
92
93
|
class Module
|
93
94
|
alias live_ast_original_module_eval module_eval
|
94
95
|
|
96
|
+
# Arity must be handled in code because the first argument is only required
|
97
|
+
# if no block is passed.
|
95
98
|
def module_eval(*args, &block)
|
96
99
|
if block
|
97
100
|
live_ast_original_module_eval(*args, &block)
|
data/lib/live_ast/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mvz-live_ast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James M. Lawrence
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-01-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby2ruby
|
@@ -74,103 +74,103 @@ dependencies:
|
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '5.0'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
77
|
+
name: minitest-focus
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1.4'
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '1.4'
|
90
90
|
- !ruby/object:Gem::Dependency
|
91
|
-
name: rake
|
91
|
+
name: rake
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '13.0'
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '13.0'
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
105
|
+
name: rake-manifest
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.2.0
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 0.2.0
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
119
|
name: rubocop
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '1.
|
124
|
+
version: '1.51'
|
125
125
|
type: :development
|
126
126
|
prerelease: false
|
127
127
|
version_requirements: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '1.
|
131
|
+
version: '1.51'
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
133
|
name: rubocop-minitest
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
138
|
+
version: 0.34.2
|
139
139
|
type: :development
|
140
140
|
prerelease: false
|
141
141
|
version_requirements: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
145
|
+
version: 0.34.2
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: rubocop-packaging
|
148
148
|
requirement: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.5.
|
152
|
+
version: 0.5.2
|
153
153
|
type: :development
|
154
154
|
prerelease: false
|
155
155
|
version_requirements: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.5.
|
159
|
+
version: 0.5.2
|
160
160
|
- !ruby/object:Gem::Dependency
|
161
161
|
name: rubocop-performance
|
162
162
|
requirement: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '1.
|
166
|
+
version: '1.20'
|
167
167
|
type: :development
|
168
168
|
prerelease: false
|
169
169
|
version_requirements: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '1.
|
173
|
+
version: '1.20'
|
174
174
|
- !ruby/object:Gem::Dependency
|
175
175
|
name: rubocop-rake
|
176
176
|
requirement: !ruby/object:Gem::Requirement
|
@@ -242,14 +242,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
242
242
|
requirements:
|
243
243
|
- - ">="
|
244
244
|
- !ruby/object:Gem::Version
|
245
|
-
version:
|
245
|
+
version: 3.0.0
|
246
246
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
247
247
|
requirements:
|
248
248
|
- - ">="
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '0'
|
251
251
|
requirements: []
|
252
|
-
rubygems_version: 3.3
|
252
|
+
rubygems_version: 3.5.3
|
253
253
|
signing_key:
|
254
254
|
specification_version: 4
|
255
255
|
summary: Live abstract syntax trees of methods and procs.
|