fstrings 0.0.1 → 0.0.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 +10 -0
- data/lib/fstrings/parser.rb +24 -6
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86b8160ade1317b3f2b29a2672e5b13485e234dee620debe84ed90a925d7ac96
|
4
|
+
data.tar.gz: ce625de3062453ea2c7d2365f6838aeddf11de35389dcb72423472d4771bcada
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35f5672766c28a97b24e0bc555d8d966fa64ef3db85bbc6f298ba210a79cbd24a7801dad8c3bbefed56f3352a350bb8450a035a86e350971ae5e8fe1be1b2b37
|
7
|
+
data.tar.gz: dba0378ee23417e17b06a21a8ed4ace15fb7aa44a1dab06f4037e8d5b2caed140bf70fe664f5209ae8e4aaddf88ea569f5acb0b832a883327d7d46c99d4aec94
|
data/CHANGELOG.md
ADDED
data/lib/fstrings/parser.rb
CHANGED
@@ -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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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.
|
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-
|
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.
|
179
|
+
version: 2.6.0
|
179
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
181
|
requirements:
|
181
182
|
- - ">="
|