ruby-next-core 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +11 -0
- data/lib/ruby-next.rb +1 -0
- data/lib/ruby-next/language/bootsnap.rb +1 -1
- data/lib/ruby-next/language/eval.rb +4 -4
- data/lib/ruby-next/language/rewriters/base.rb +1 -1
- data/lib/ruby-next/language/runtime.rb +4 -4
- data/lib/ruby-next/logging.rb +43 -0
- data/lib/ruby-next/utils.rb +3 -1
- data/lib/ruby-next/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3395d5a5cd7bbc3f2697682cd8d212c398ef0a76d19b60308f68d027c545300
|
4
|
+
data.tar.gz: aa20461bff07df85835508f8e498b88604c5d31988db06fe4793d2becda92055
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d431025ce839f76a8d39436899b6d38e66ed8818f62a14bfad0e8367cdf29ed11439ed75a91bb9051f68488c70ffdc7622210ac0fe76e3385e7b945a4545113b
|
7
|
+
data.tar.gz: e3ff453d83653ebd4bfefe1bdb30e12e6ac39d25a80311accbfabe7fd0af1395b216c07e6e91a33cb05aa50e45dc6e246e9c118b59d09bf95bb75eb4f6f1a69a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.5.2 (2020-03-25)
|
6
|
+
|
7
|
+
- Enhance logging. ([@palkan][])
|
8
|
+
|
9
|
+
Use `RUBY_NEXT_WARN=false` to disable warnings.
|
10
|
+
Use `RUBY_NEXT_DEBUG=path.rb` to display the transpiler output only for matching files
|
11
|
+
in the runtime mode.
|
12
|
+
|
5
13
|
## 0.5.1 (2020-03-20)
|
6
14
|
|
7
15
|
- Add RuboCop integration. ([@palkan][])
|
data/README.md
CHANGED
@@ -35,6 +35,7 @@ That's why Ruby Next implements the `master` features as fast as possible.
|
|
35
35
|
- [Runtime usage](#runtime-usage)
|
36
36
|
- [Bootsnap integration](#using-with-bootsnap)
|
37
37
|
- [`ruby -ruby-next`](#uby-next)
|
38
|
+
- [Logging & Debugging](#logging-and-debugging)
|
38
39
|
- [RuboCop](#rubocop)
|
39
40
|
- [Proposed & edge features](#proposed-and-edge-features)
|
40
41
|
|
@@ -307,6 +308,16 @@ RUBYOPT="-ruby-next" ruby my_ruby_script.rb
|
|
307
308
|
ruby -ruby-next -e "puts [2, 4, 5].tally"
|
308
309
|
```
|
309
310
|
|
311
|
+
## Logging and debugging
|
312
|
+
|
313
|
+
Ruby Next prints some debugging information when fails to load a file in the runtime mode (and fallbacks to the built-in loading mechanism).
|
314
|
+
|
315
|
+
You can disable these warnings either by providing the `RUBY_NEXT_WARN=false` env variable or by setting `RubyNext.silence_warnings = true` in your code.
|
316
|
+
|
317
|
+
You can also enable transpiled source code debugging by setting the `RUBY_NEXT_DEBUG=true` env variable. When it's set, Ruby Next prints the transpiled code before loading it.
|
318
|
+
|
319
|
+
You can use a file pattern as the value for the env var to limit the output: for example, `RUBY_NEXT_DEBUG=my_script.rb`.
|
320
|
+
|
310
321
|
## RuboCop
|
311
322
|
|
312
323
|
Since Ruby Next provides support for features not available in RuboCop yet, you need to add a patch for compatibility.
|
data/lib/ruby-next.rb
CHANGED
@@ -17,7 +17,7 @@ if load_iseq.source_location[0].include?("/bootsnap/")
|
|
17
17
|
return super unless RubyNext::Language.transformable?(path)
|
18
18
|
source = RubyNext::Language.transform(source, rewriters: RubyNext::Language.current_rewriters)
|
19
19
|
|
20
|
-
|
20
|
+
RubyNext.debug_source(source, path)
|
21
21
|
|
22
22
|
RubyVM::InstructionSequence.compile(source, path, path).to_binary
|
23
23
|
rescue SyntaxError
|
@@ -9,7 +9,7 @@ module RubyNext
|
|
9
9
|
source,
|
10
10
|
using: bind&.receiver == TOPLEVEL_BINDING.receiver || bind&.receiver&.is_a?(Module)
|
11
11
|
)
|
12
|
-
|
12
|
+
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
13
13
|
super new_source, bind, *args
|
14
14
|
end
|
15
15
|
end
|
@@ -22,7 +22,7 @@ module RubyNext
|
|
22
22
|
|
23
23
|
source = args.shift
|
24
24
|
new_source = ::RubyNext::Language::Runtime.transform(source, using: false)
|
25
|
-
|
25
|
+
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
26
26
|
super new_source, *args
|
27
27
|
end
|
28
28
|
end
|
@@ -35,7 +35,7 @@ module RubyNext
|
|
35
35
|
|
36
36
|
source = args.shift
|
37
37
|
new_source = ::RubyNext::Language::Runtime.transform(source, using: false)
|
38
|
-
|
38
|
+
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
39
39
|
super new_source, *args
|
40
40
|
end
|
41
41
|
|
@@ -44,7 +44,7 @@ module RubyNext
|
|
44
44
|
|
45
45
|
source = args.shift
|
46
46
|
new_source = ::RubyNext::Language::Runtime.transform(source, using: false)
|
47
|
-
|
47
|
+
RubyNext.debug_source(new_source, "(#{caller_locations(1, 1).first})")
|
48
48
|
super new_source, *args
|
49
49
|
end
|
50
50
|
end
|
@@ -24,7 +24,7 @@ module RubyNext
|
|
24
24
|
contents = File.read(path)
|
25
25
|
new_contents = transform contents
|
26
26
|
|
27
|
-
|
27
|
+
RubyNext.debug_source new_contents, path
|
28
28
|
|
29
29
|
evaluate(new_contents, path)
|
30
30
|
true
|
@@ -83,7 +83,7 @@ module Kernel
|
|
83
83
|
true
|
84
84
|
rescue => e
|
85
85
|
$LOADED_FEATURES.delete realpath
|
86
|
-
warn "RubyNext failed to require '#{path}': #{e.message}"
|
86
|
+
RubyNext.warn "RubyNext failed to require '#{path}': #{e.message}"
|
87
87
|
require_without_ruby_next(path)
|
88
88
|
end
|
89
89
|
|
@@ -98,7 +98,7 @@ module Kernel
|
|
98
98
|
)
|
99
99
|
require(realpath)
|
100
100
|
rescue => e
|
101
|
-
warn "RubyNext failed to require relative '#{path}' from #{from}: #{e.message}"
|
101
|
+
RubyNext.warn "RubyNext failed to require relative '#{path}' from #{from}: #{e.message}"
|
102
102
|
require_relative_without_ruby_next(path)
|
103
103
|
end
|
104
104
|
|
@@ -110,7 +110,7 @@ module Kernel
|
|
110
110
|
|
111
111
|
RubyNext::Language::Runtime.load(realpath, wrap: wrap)
|
112
112
|
rescue => e
|
113
|
-
warn "RubyNext failed to load '#{path}': #{e.message}"
|
113
|
+
RubyNext.warn "RubyNext failed to load '#{path}': #{e.message}"
|
114
114
|
load_without_ruby_next(path)
|
115
115
|
end
|
116
116
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "utils"
|
4
|
+
|
5
|
+
module RubyNext
|
6
|
+
class << self
|
7
|
+
attr_accessor :silence_warnings
|
8
|
+
attr_reader :debug_enabled
|
9
|
+
|
10
|
+
def warn(msg)
|
11
|
+
return if silence_warnings
|
12
|
+
|
13
|
+
Kernel.warn msg
|
14
|
+
end
|
15
|
+
|
16
|
+
def debug_source(source, filepath = nil)
|
17
|
+
return unless debug_enabled
|
18
|
+
|
19
|
+
return if debug_filter && !filepath.include?(debug_filter)
|
20
|
+
|
21
|
+
$stdout.puts Utils.source_with_lines(source, filepath)
|
22
|
+
end
|
23
|
+
|
24
|
+
def debug_enabled=(val)
|
25
|
+
return if val.nil?
|
26
|
+
|
27
|
+
@debug_enabled = !(val == "false" || val == "0")
|
28
|
+
|
29
|
+
return unless debug_enabled
|
30
|
+
|
31
|
+
return if val == "true" || val == "1"
|
32
|
+
|
33
|
+
@debug_filter = val
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
attr_reader :debug_filter
|
39
|
+
end
|
40
|
+
|
41
|
+
self.silence_warnings = ENV["RUBY_NEXT_WARN"] != "false"
|
42
|
+
self.debug_enabled = ENV["RUBY_NEXT_DEBUG"]
|
43
|
+
end
|
data/lib/ruby-next/utils.rb
CHANGED
@@ -6,7 +6,9 @@ module RubyNext
|
|
6
6
|
|
7
7
|
if $LOAD_PATH.respond_to?(:resolve_feature_path)
|
8
8
|
def resolve_feature_path(feature)
|
9
|
-
|
9
|
+
catch(LoadError) do
|
10
|
+
$LOAD_PATH.resolve_feature_path(feature)&.last
|
11
|
+
end
|
10
12
|
end
|
11
13
|
else
|
12
14
|
def resolve_feature_path(path)
|
data/lib/ruby-next/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-next-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/ruby-next/language/runtime.rb
|
96
96
|
- lib/ruby-next/language/setup.rb
|
97
97
|
- lib/ruby-next/language/unparser.rb
|
98
|
+
- lib/ruby-next/logging.rb
|
98
99
|
- lib/ruby-next/rubocop.rb
|
99
100
|
- lib/ruby-next/utils.rb
|
100
101
|
- lib/ruby-next/version.rb
|