ruby-next-core 0.8.0 → 0.9.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb8a0798576c2859d40a9bcc7ce9b4c5a9bcdd2560a603bdf14b897a1248edc2
4
- data.tar.gz: 38f599eb8a725bb52ad7a7ae66342c3450da6906366a8d6e53304484ca60a1b5
3
+ metadata.gz: 44b797d87fbbc3b9eb0c31ad04466abadb286728a80a5222808072994939dc81
4
+ data.tar.gz: 3e3f018b5adbfb2f2213722509d5d50fafec01efd85e92580e26234f7fd2f99e
5
5
  SHA512:
6
- metadata.gz: abdb54f137bce953dfe24eaa29dcb35c057534821ac2dbd5a4b3092608aa88b6a2e8ac81032f86766d2eda29c70bbc0b2acd79f72dcd2490d230cd92a34af00b
7
- data.tar.gz: ff4087bb6b6ecf1cc159166b0a4a8bcc650d2ef1ee315f3eeee5e8b8b1f3005ce560c4fcd7ffd5673cef206fbaf7f3fca2e0f0a594fda042b5f5178d43ea2a5b
6
+ metadata.gz: 9ee37b8457ecba6d8c0ae4ff82a1d9e4a5fbc72a7d9e8bd0997d13ce461d0d3894cae439ddde2836a1e48c1af481d978c66eec83cb6f9865b96c417b69a0d0ba
7
+ data.tar.gz: 4d74819e5235e53cdad9c8f5ae25d761309937002a4d03858c0b979fc504535fc04ab76a45dd74ceb9165acb06d73fb643dbc02349925dc438d21155dcc342fc
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ - Add Ruby 2.4 support. ([@palkan][])
6
+
7
+ APIs for <2.5 must be backported via [backports][] gem. Refinements are not supported.
8
+
5
9
  ## 0.8.0 (2020-05-01) 🚩
6
10
 
7
11
  - Add right-hand assignment support. ([@palkan][])
@@ -178,3 +182,4 @@ p a #=> 1
178
182
  - Add `Kernel#then`. ([@palkan][])
179
183
 
180
184
  [@palkan]: https://github.com/palkan
185
+ [backports]: https://github.com/marcandre/backports
data/README.md CHANGED
@@ -17,13 +17,29 @@ Who might be interested in Ruby Next?
17
17
  Ruby Next also aims to help the community to assess new, _experimental_, MRI features by making it easier to play with them.
18
18
  That's why Ruby Next implements the `master` features as fast as possible.
19
19
 
20
+ 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).
21
+
20
22
  <a href="https://evilmartians.com/?utm_source=ruby-next">
21
23
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
22
24
 
23
- ## Links
25
+ ## Posts
26
+
27
+ - [Ruby Next: Make all Rubies quack alike](https://evilmartians.com/chronicles/ruby-next-make-all-rubies-quack-alike)
28
+
29
+ ## Talks
24
30
 
25
31
  - [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
32
 
33
+ ## Examples
34
+
35
+ - Ruby gems
36
+ - [anyway_config](https://github.com/palkan/anyway_config)
37
+ - [graphql-fragment_cache](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache)
38
+ - mruby
39
+ - [ACLI](https://github.com/palkan/acli)
40
+
41
+ _Please, submit a PR to add your project to the list!_
42
+
27
43
  ## Table of contents
28
44
 
29
45
  - [Overview](#overview)
@@ -38,6 +54,7 @@ That's why Ruby Next implements the `master` features as fast as possible.
38
54
  - [`ruby -ruby-next`](#uby-next)
39
55
  - [Logging & Debugging](#logging-and-debugging)
40
56
  - [RuboCop](#rubocop)
57
+ - [Using with EOL Rubies](#using-with-eol-rubies)
41
58
  - [Proposed & edge features](#proposed-and-edge-features)
42
59
 
43
60
  ## Overview
@@ -49,8 +66,9 @@ Core provides **polyfills** for Ruby core classes APIs via Refinements (default
49
66
  Language is responsible for **transpiling** edge Ruby syntax into older versions. It could be done
50
67
  programmatically or via CLI. It also could be done in runtime.
51
68
 
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.
69
+ Currently, Ruby Next supports Ruby versions 2.4+ (including JRuby 9.2.8+). Support for EOL versions (<2.5) slightly differs though ([see below](#using-with-eol-rubies)).
70
+
71
+ 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
72
 
55
73
  ## Quick start
56
74
 
@@ -297,17 +315,17 @@ If you're using [runtime mode](#runtime-usage) a long with `setup_gem_load_path`
297
315
 
298
316
  \* 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).
299
317
 
300
- ### Transpiled files vs. VSC vs. installing from source
318
+ ### Transpiled files vs. VCS vs. installing from source
301
319
 
302
320
  It's a best practice to not keep generated files in repositories. In case of Ruby Next, it's a `lib/.rbnext` folder.
303
321
 
304
- 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.
322
+ 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.
305
323
 
306
- 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.
324
+ 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.
307
325
 
308
326
  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:
309
327
 
310
- - We in the Bundler context (since that's the most common way of installing gems from source).
328
+ - We are in the Bundler context (since that's the most common way of installing gems from source).
311
329
  - Our Gemfile contains `ruby-next` gem.
312
330
  - We use [`.rbnextrc`](#CLI-configuration-file) for transpiling options.
313
331
 
@@ -406,6 +424,40 @@ AllCops:
406
424
 
407
425
  **NOTE:** you need `ruby-next` gem available in the environment where you run RuboCop (having `ruby-next-core` is not enough).
408
426
 
427
+ ## Using with EOL Rubies
428
+
429
+ **NOTE:** Use Ruby Next `0.9.0.pre` to use this feature.
430
+
431
+ We currently provide experimental support for Ruby 2.4. Work on older Rubies (down to 2.2) is in progress.
432
+
433
+ Ruby Next itself relies on 2.5 features and contains polyfills only for version 2.5+ (and that won't change).
434
+ Thus, to make it work with <2.5 we need to backport some APIs ourselves.
435
+
436
+ The recommended way of doing this is to use [backports][] gem. You need to load backports **before Ruby Next**.
437
+
438
+ When using runtime features, you should do the following:
439
+
440
+ ```ruby
441
+ # first, require backports upto 2.5
442
+ require "backports/2.5"
443
+ # then, load Ruby Next
444
+ require "ruby-next"
445
+ # if you need 2.6+ APIs, add Ruby Next core_ext
446
+ require "ruby-next/core_ext"
447
+ # then, load runtime transpiling
448
+ require "ruby-next/language/runtime"
449
+ # or
450
+ require "ruby-next/language/bootsnap"
451
+ ```
452
+
453
+ To load backports while using `ruby-next nextify` command, you must configure the environment variable:
454
+
455
+ ```sh
456
+ RUBY_NEXT_CORE_STRATEGY=backports ruby-next nextify lib/
457
+ ```
458
+
459
+ **NOTE:** Make sure you have `backports` gem installed globally or added to your bundle (if you're using `bundle exec ruby-next ...`).
460
+
409
461
  ## Proposed and edge features
410
462
 
411
463
  Ruby Next aims to bring edge and proposed features to Ruby community before they (hopefully) reach an official Ruby release.
@@ -470,3 +522,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
470
522
  [next_parser]: https://github.com/ruby-next/parser
471
523
  [Bootsnap]: https://github.com/Shopify/bootsnap
472
524
  [rubocop]: https://github.com/rubocop-hq/rubocop
525
+ [backports]: https://github.com/marcandre/backports
@@ -34,5 +34,6 @@ module RubyNext
34
34
  end
35
35
 
36
36
  require_relative "ruby-next/core"
37
+ require_relative "ruby-next/core_ext" if RubyNext::Core.core_ext?
37
38
  require_relative "ruby-next/logging"
38
39
  end
@@ -95,7 +95,7 @@ module RubyNext
95
95
  end
96
96
 
97
97
  class << self
98
- STRATEGIES = %i[refine core_ext].freeze
98
+ STRATEGIES = %i[refine core_ext backports].freeze
99
99
 
100
100
  attr_reader :strategy
101
101
 
@@ -109,7 +109,11 @@ module RubyNext
109
109
  end
110
110
 
111
111
  def core_ext?
112
- strategy == :core_ext
112
+ strategy == :core_ext || strategy == :backports
113
+ end
114
+
115
+ def backports?
116
+ strategy == :backports
113
117
  end
114
118
 
115
119
  def patch(*args, **kwargs, &block)
@@ -136,6 +140,8 @@ module RubyNext
136
140
  end
137
141
  end
138
142
 
143
+ require "backports/2.5" if RubyNext::Core.backports?
144
+
139
145
  require_relative "core/kernel/then"
140
146
 
141
147
  require_relative "core/proc/compose"
@@ -15,4 +15,4 @@ RubyNext::Core.patches.extensions.each do |mod, patches|
15
15
  end
16
16
  end
17
17
 
18
- RubyNext::Core.strategy = :core_ext
18
+ RubyNext::Core.strategy = :core_ext unless RubyNext::Core.core_ext?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyNext
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.0.pre"
5
5
  end
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.8.0
4
+ version: 0.9.0.pre
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-05-01 00:00:00.000000000 Z
11
+ date: 2020-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-next-parser
@@ -121,12 +121,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 2.5.0
124
+ version: 2.4.0
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
127
+ - - ">"
128
128
  - !ruby/object:Gem::Version
129
- version: '0'
129
+ version: 1.3.1
130
130
  requirements: []
131
131
  rubygems_version: 3.0.6
132
132
  signing_key: