ruby-next 0.7.0 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -0
  3. data/README.md +90 -18
  4. metadata +9 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3215bbbd87086368ad17287a6bc9b69a3fb6d5d28f3fb5364f2f85eef5a2e2e
4
- data.tar.gz: a35527c354c57dacc97b178aaf182610dbe528e28b509e83191219c98d4647cb
3
+ metadata.gz: fe4d8a355191412c50b1f1c4c7cbf92e3d70ecb0dff07602ad0e55549e1cc764
4
+ data.tar.gz: 54a7d596d68a55cf34f1fc1371d3675aa046b54149d45be44c93f329121b1e7d
5
5
  SHA512:
6
- metadata.gz: 21acb52c5919ecf3e1950c8df15c32b1bc27d3228a6513d78fa20e5a8b6a1eb993637b447604ac6c9b38690507d2f4e3d28688df732a0a67c07cd17b0e6680cd
7
- data.tar.gz: 0b2b034e5b3219b0f8f247d1d474950abe9e73a09eed885cb771227cb6cd8b51dc409898c603215c0b13c0fedb81572e09e81ebb122ffb3cdadf6f336d3c7b10
6
+ metadata.gz: cabc61d8bd370bdb3b04353f87ec7eb353200484a6d61d592be9f1917a4eb507b404d8a0a915ea49531c2059668dcbb34518dc10ca815202c9fa67df6a6f7d15
7
+ data.tar.gz: 967f88bac4e946b0f5b4de8a121ffc2b72f2cdccb5df99f398d9cb15533fa37fa20371ff9213799555afae1cd48bd1f24e04235632cc09e5e91bfa59e1ad9ea7
@@ -2,6 +2,41 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.9.2 (2020-06-24)
6
+
7
+ - Support passing rewriters to CLI. ([@sl4vr][])
8
+
9
+ Use `nextify --list-rewriters` to view all available rewriters.
10
+ Use `nextify` with `--rewrite=REWRITERS...` option to specify which particular rewriters to use.
11
+
12
+ ## 0.9.1 (2020-06-05)
13
+
14
+ - Keep `ruby-next` version in sync with `ruby-next-core`. ([@palkan][])
15
+
16
+ Require `ruby-next-core` of the same version as `ruby-next`.
17
+
18
+ ## 0.9.0 (2020-06-04)
19
+
20
+ - Add Ruby 2.3 support. ([@palkan][])
21
+
22
+ - Remove stale transpiled files when running `ruby-next nextify`. ([@palkan][])
23
+
24
+ - Add Ruby 2.4 support. ([@palkan][])
25
+
26
+ APIs for <2.5 must be backported via [backports][] gem. Refinements are not supported.
27
+
28
+ ## 0.8.0 (2020-05-01) 🚩
29
+
30
+ - Add right-hand assignment support. ([@palkan][])
31
+
32
+ It is real: `13.divmod(5) => a, b`.
33
+
34
+ - Add endless methods support. ([@palkan][])
35
+
36
+ Now you can write `def foo() = :bar`.
37
+
38
+ ## 0.7.0 (2020-04-29)
39
+
5
40
  - Try to auto-transpile the source code on load in `.setup_gem_load_path` if transpiled files are missing. ([@palkan][])
6
41
 
7
42
  This would make it possible to install gems from source if transpiled files do not exist in the repository.
@@ -166,3 +201,5 @@ p a #=> 1
166
201
  - Add `Kernel#then`. ([@palkan][])
167
202
 
168
203
  [@palkan]: https://github.com/palkan
204
+ [backports]: https://github.com/marcandre/backports
205
+ [@sl4vr]: https://github.com/sl4vr
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
+ [![Cult Of Martians](http://cultofmartians.com/assets/badges/badge.svg)](https://cultofmartians.com/tasks/ruby-next-cli-rewriters.html#task)
1
2
  [![Gem Version](https://badge.fury.io/rb/ruby-next.svg)](https://rubygems.org/gems/ruby-next) [![Build](https://github.com/ruby-next/ruby-next/workflows/Build/badge.svg)](https://github.com/ruby-next/ruby-next/actions)
2
- [![JRuby Build](https://github.com/ruby-next/ruby-next/workflows/JRuby%20Build/badge.svg)](https://github.com/ruby-next/ruby-next/actions)
3
+ [![JRuby Build](https://github.com/ruby-next/ruby-next/workflows/JRuby%20Build/badge.svg)](https://github.com/ruby-next/ruby-next/actions?query=workflow%3A%22TruffleRuby+Build%22)
4
+ [![TruffleRuby Build](https://github.com/ruby-next/ruby-next/workflows/TruffleRuby%20Build/badge.svg)](https://github.com/ruby-next/ruby-next/actions?query=workflow%3A%22TruffleRuby+Build%22)
3
5
 
4
6
  # Ruby Next
5
7
 
@@ -17,13 +19,29 @@ Who might be interested in Ruby Next?
17
19
  Ruby Next also aims to help the community to assess new, _experimental_, MRI features by making it easier to play with them.
18
20
  That's why Ruby Next implements the `master` features as fast as possible.
19
21
 
22
+ Read more about the motivation behind the Ruby Next in this post: [Ruby Next: Make all Rubies quack alike](https://evilmartians.com/chronicles/ruby-next-make-all-rubies-quack-alike).
23
+
20
24
  <a href="https://evilmartians.com/?utm_source=ruby-next">
21
25
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
22
26
 
23
- ## Links
27
+ ## Posts
28
+
29
+ - [Ruby Next: Make all Rubies quack alike](https://evilmartians.com/chronicles/ruby-next-make-all-rubies-quack-alike)
30
+
31
+ ## Talks
24
32
 
25
33
  - [Ruby Next: Make old Rubies quack like a new one](https://noti.st/palkan/j3i2Dr/ruby-next-make-old-rubies-quack-like-a-new-one) (RubyConf 2019)
26
34
 
35
+ ## Examples
36
+
37
+ - Ruby gems
38
+ - [anyway_config](https://github.com/palkan/anyway_config)
39
+ - [graphql-fragment_cache](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache)
40
+ - mruby
41
+ - [ACLI](https://github.com/palkan/acli)
42
+
43
+ _Please, submit a PR to add your project to the list!_
44
+
27
45
  ## Table of contents
28
46
 
29
47
  - [Overview](#overview)
@@ -38,6 +56,7 @@ That's why Ruby Next implements the `master` features as fast as possible.
38
56
  - [`ruby -ruby-next`](#uby-next)
39
57
  - [Logging & Debugging](#logging-and-debugging)
40
58
  - [RuboCop](#rubocop)
59
+ - [Using with EOL Rubies](#using-with-eol-rubies)
41
60
  - [Proposed & edge features](#proposed-and-edge-features)
42
61
 
43
62
  ## Overview
@@ -49,8 +68,9 @@ Core provides **polyfills** for Ruby core classes APIs via Refinements (default
49
68
  Language is responsible for **transpiling** edge Ruby syntax into older versions. It could be done
50
69
  programmatically or via CLI. It also could be done in runtime.
51
70
 
52
- Currently, Ruby Next supports Ruby versions 2.5+ (including JRuby 9.2.8+).
53
- Please, [open an issue](https://github.com/ruby-next/ruby-next/issues/new/choose) if you would like us to support older Ruby versions.
71
+ Currently, Ruby Next supports Ruby versions 2.3+, including JRuby 9.2.8+ and TruffleRuby 20.1+ (with some limitations). Support for EOL versions (<2.5) slightly differs though ([see below](#using-with-eol-rubies)).
72
+
73
+ Please, [open an issue](https://github.com/ruby-next/ruby-next/issues/new/choose) or join the discussion in the existing ones if you would like us to support older Ruby versions.
54
74
 
55
75
  ## Quick start
56
76
 
@@ -62,12 +82,16 @@ $ gem install ruby-next
62
82
 
63
83
  # Call ruby with -ruby-next flag
64
84
  $ ruby -ruby-next -e "
65
- case {hello: 'martian'}
66
- in hello: hello if hello =~ /human/
67
- puts '🙂'
68
- in hello: 'martian'
69
- puts '👽'
70
- end
85
+ def greet(val) =
86
+ case val
87
+ in hello: hello if hello =~ /human/i
88
+ '🙂'
89
+ in hello: 'martian'
90
+ '👽'
91
+ end
92
+
93
+ greet(hello: 'martian') => greeting
94
+ puts greeting
71
95
  "
72
96
 
73
97
  => 👽
@@ -115,6 +139,8 @@ The following _rule of thumb_ is recommended when choosing between refinements a
115
139
  - Using core extensions could be considered for application development (no need to think about `using RubyNext`); this approach could potentially lead to conflicts with dependencies (if these dependencies are not using refinements 🙂)
116
140
  - Use core extensions if refinements are not supported by your platform
117
141
 
142
+ **NOTE:** TruffleRuby doesn't fully support refinements (refining modules is not supported as of v20.1.0).
143
+
118
144
  [**The list of supported APIs.**][features_core]
119
145
 
120
146
  ## Transpiling
@@ -160,6 +186,8 @@ You can change the transpiler mode:
160
186
  - Via environmental variable `RUBY_NEXT_TRANSPILE_MODE=rewrite`.
161
187
  - Via CLI option ([see below](#cli)).
162
188
 
189
+ **NOTE:** For the time being, Unparser [doesn't support](https://github.com/mbj/unparser/pull/142) new Ruby 2.7 AST nodes, so we always use rewrite mode in Ruby 2.7+.
190
+
163
191
  ## CLI
164
192
 
165
193
  Ruby Next ships with the command-line interface (`ruby-next`) which provides the following functionality:
@@ -173,12 +201,15 @@ It has the following interface:
173
201
  ```sh
174
202
  $ ruby-next nextify
175
203
  Usage: ruby-next nextify DIRECTORY_OR_FILE [options]
176
- -o, --output=OUTPUT Specify output directory or file or stdout (use -o stdout for that)
204
+ -o, --output=OUTPUT Specify output directory or file or stdout
177
205
  --min-version=VERSION Specify the minimum Ruby version to support
178
206
  --single-version Only create one version of a file (for the earliest Ruby version)
179
- --enable-method-reference Enable reverted method reference syntax (requires custom parser)
207
+ --edge Enable edge (master) Ruby features
208
+ --proposed Enable proposed/experimental Ruby features
180
209
  --transpile-mode=MODE Transpiler mode (ast or rewrite). Default: ast
181
210
  --[no-]refine Do not inject `using RubyNext`
211
+ --list-rewriters List available rewriters
212
+ --rewrite=REWRITERS... Specify particular Ruby features to rewrite
182
213
  -h, --help Print help
183
214
  -V Turn on verbose mode
184
215
  --dry-run Print verbose output without generating files
@@ -291,17 +322,17 @@ If you're using [runtime mode](#runtime-usage) a long with `setup_gem_load_path`
291
322
 
292
323
  \* Ruby Next avoids storing duplicates; instead, only the code for the earlier version is created and is assumed to be used with other versions. For example, if the transpiled code is the same for Ruby 2.5 and Ruby 2.6, only the `.rbnext/2.7/path/to/file.rb` is kept. That's why multiple entries are added to the `$LOAD_PATH` (`.rbnext/2.6` and `.rbnext/2.7` in the specified order for Ruby 2.5 and only `.rbnext/2.7` for Ruby 2.6).
293
324
 
294
- ### Transpiled files vs. VSC vs. installing from source
325
+ ### Transpiled files vs. VCS vs. installing from source
295
326
 
296
327
  It's a best practice to not keep generated files in repositories. In case of Ruby Next, it's a `lib/.rbnext` folder.
297
328
 
298
- We recommend adding this folder only to the gem package (i.e., it should be added to your `spec.files`) and ignore it in your VSC (e.g., `echo ".rbnext/" >> .gitignore`). That would make transpiled files available in releases without polluting your repository.
329
+ We recommend adding this folder only to the gem package (i.e., it should be added to your `spec.files`) and ignore it in your VCS (e.g., `echo ".rbnext/" >> .gitignore`). That would make transpiled files available in releases without polluting your repository.
299
330
 
300
- What if someone decides to install your gem from the VSC source? They would likely face some syntax errors due to the missing transpiled files.
331
+ What if someone decides to install your gem from the VCS source? They would likely face some syntax errors due to the missing transpiled files.
301
332
 
302
333
  To solve this problem, Ruby Next _tries_ to transpile the source code when you call `#setup_gem_load_path`. It does this by calling `bundle exec ruby-next nextify <lib_dir> -o <next_dir>`. We make the following assumptions:
303
334
 
304
- - We in the Bundler context (since that's the most common way of installing gems from source).
335
+ - We are in the Bundler context (since that's the most common way of installing gems from source).
305
336
  - Our Gemfile contains `ruby-next` gem.
306
337
  - We use [`.rbnextrc`](#CLI-configuration-file) for transpiling options.
307
338
 
@@ -366,6 +397,12 @@ RUBYOPT="-ruby-next" ruby my_ruby_script.rb
366
397
  ruby -ruby-next -e "puts [2, 4, 5].tally"
367
398
  ```
368
399
 
400
+ **NOTE:** running Ruby scripts directly or executing code via `-e` option is not supported in TruffleRuby. You can still use `-ruby-next` to transpile required files, e.g.:
401
+
402
+ ```sh
403
+ ruby -ruby-next -r my_ruby_script.rb -e "puts my_method"
404
+ ```
405
+
369
406
  ## Logging and debugging
370
407
 
371
408
  Ruby Next prints some debugging information when fails to load a file in the runtime mode (and fallbacks to the built-in loading mechanism).
@@ -400,6 +437,38 @@ AllCops:
400
437
 
401
438
  **NOTE:** you need `ruby-next` gem available in the environment where you run RuboCop (having `ruby-next-core` is not enough).
402
439
 
440
+ ## Using with EOL Rubies
441
+
442
+ We currently provide support for Ruby 2.3 and 2.4. Work on 2.2 is in progress.
443
+
444
+ Ruby Next itself relies on 2.5 features and contains polyfills only for version 2.5+ (and that won't change).
445
+ Thus, to make it work with <2.5 we need to backport some APIs ourselves.
446
+
447
+ The recommended way of doing this is to use [backports][] gem. You need to load backports **before Ruby Next**.
448
+
449
+ When using runtime features, you should do the following:
450
+
451
+ ```ruby
452
+ # first, require backports upto 2.5
453
+ require "backports/2.5"
454
+ # then, load Ruby Next
455
+ require "ruby-next"
456
+ # if you need 2.6+ APIs, add Ruby Next core_ext
457
+ require "ruby-next/core_ext"
458
+ # then, load runtime transpiling
459
+ require "ruby-next/language/runtime"
460
+ # or
461
+ require "ruby-next/language/bootsnap"
462
+ ```
463
+
464
+ To load backports while using `ruby-next nextify` command, you must configure the environment variable:
465
+
466
+ ```sh
467
+ RUBY_NEXT_CORE_STRATEGY=backports ruby-next nextify lib/
468
+ ```
469
+
470
+ **NOTE:** Make sure you have `backports` gem installed globally or added to your bundle (if you're using `bundle exec ruby-next ...`).
471
+
403
472
  ## Proposed and edge features
404
473
 
405
474
  Ruby Next aims to bring edge and proposed features to Ruby community before they (hopefully) reach an official Ruby release.
@@ -431,11 +500,13 @@ require "ruby-next/language/runtime"
431
500
 
432
501
  ### Supported edge features
433
502
 
434
- Not yet.
503
+ - "Endless" method definition (`def foo() = 42`) ([#16746](https://bugs.ruby-lang.org/issues/16746)).
504
+
505
+ - Right-hand assignment (`13.divmod(5) => a,b`) ([#15921](https://bugs.ruby-lang.org/issues/15921))
435
506
 
436
507
  ### Supported proposed features
437
508
 
438
- - _Method reference_ operator (`.:`) ([link](https://bugs.ruby-lang.org/issues/13581)).
509
+ - _Method reference_ operator (`.:`) ([#13581](https://bugs.ruby-lang.org/issues/13581)).
439
510
 
440
511
  ## Contributing
441
512
 
@@ -462,3 +533,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
462
533
  [next_parser]: https://github.com/ruby-next/parser
463
534
  [Bootsnap]: https://github.com/Shopify/bootsnap
464
535
  [rubocop]: https://github.com/rubocop-hq/rubocop
536
+ [backports]: https://github.com/marcandre/backports
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-next
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.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-04-29 00:00:00.000000000 Z
11
+ date: 2020-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-next-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.9.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.9.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-next-parser
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.8.0.0
33
+ version: 2.8.0.7
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.8.0.0
40
+ version: 2.8.0.7
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: unparser
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - ">="
83
83
  - !ruby/object:Gem::Version
84
- version: 2.5.0
84
+ version: 2.3.0
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="