fstrings 0.0.1 → 0.0.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 +10 -0
  3. data/lib/fstrings/parser.rb +24 -6
  4. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7380d3cac8fb3aefc682a76ad4494ab1d073ce0d9151282cd308da13e4d816e3
4
- data.tar.gz: 2c68d89360ab486f60afac7b26282f1cd16fb4039d507ec586ce78906fa7c786
3
+ metadata.gz: 86b8160ade1317b3f2b29a2672e5b13485e234dee620debe84ed90a925d7ac96
4
+ data.tar.gz: ce625de3062453ea2c7d2365f6838aeddf11de35389dcb72423472d4771bcada
5
5
  SHA512:
6
- metadata.gz: 73ca4f916f6ce4da769ca3e4bf4abe44b7b4245e56ab9654bc2798a43e30967fc9c4f6fcec0b0c23992fab62bd6c6420e15e85a1c852e7c61d64d2071bf8374b
7
- data.tar.gz: 303bd05300946f90da31bb282cac0e08221387e81d907320b997a98205701d3bc1c6526cd8cdcf588577ae94173d87fb32bfe51d5e13da80f28bc0b7628a4d0a
6
+ metadata.gz: 35f5672766c28a97b24e0bc555d8d966fa64ef3db85bbc6f298ba210a79cbd24a7801dad8c3bbefed56f3352a350bb8450a035a86e350971ae5e8fe1be1b2b37
7
+ data.tar.gz: dba0378ee23417e17b06a21a8ed4ace15fb7aa44a1dab06f4037e8d5b2caed140bf70fe664f5209ae8e4aaddf88ea569f5acb0b832a883327d7d46c99d4aec94
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # fstrings Changelog
2
+
3
+ ## 0.0.2 -- 2020-01-17
4
+
5
+ * Proper Ruby minimal version (2.6, I love power of refinements) in gemspec
6
+ * Small internal cleanup
7
+
8
+ ## 0.0.1 -- 2020-01-07
9
+
10
+ Birthday!
@@ -9,17 +9,35 @@ module FStrings
9
9
  method(:%).to_proc
10
10
  end
11
11
  end
12
+
13
+ # TODO: Take from backports, when they'll be ready
14
+ unless Enumerator.respond_to?(:produce)
15
+ refine Enumerator.singleton_class do
16
+ NOVALUE = Object.new.freeze
17
+
18
+ def produce(initial = NOVALUE)
19
+ Enumerator.new do |y|
20
+ val = initial == NOVALUE ? yield() : initial
21
+
22
+ loop do
23
+ y << val
24
+ val = yield(val)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
12
30
  end)
13
31
 
14
32
  class << self
15
33
  def str2code(string)
16
- res = []
17
34
  scan = StringScanner.new(string)
18
- until scan.eos?
19
- res << scan_simple(scan).inspect
20
- res << statement2code(scan_statement(scan)) unless scan.eos?
21
- end
22
- res.join(' + ')
35
+ Enumerator.produce {
36
+ [
37
+ scan_simple(scan).inspect,
38
+ (statement2code(**scan_statement(scan)) unless scan.eos?)
39
+ ]
40
+ }.slice_after { scan.eos? }.first.flatten.compact.join(' + ')
23
41
  end
24
42
 
25
43
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fstrings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Shepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-07 00:00:00.000000000 Z
11
+ date: 2020-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller
@@ -158,6 +158,7 @@ executables: []
158
158
  extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
+ - CHANGELOG.md
161
162
  - LICENSE.txt
162
163
  - README.md
163
164
  - lib/fstrings.rb
@@ -175,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
176
  requirements:
176
177
  - - ">="
177
178
  - !ruby/object:Gem::Version
178
- version: 2.4.0
179
+ version: 2.6.0
179
180
  required_rubygems_version: !ruby/object:Gem::Requirement
180
181
  requirements:
181
182
  - - ">="