dead_code_terminator 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -6
- data/lib/dead_code_terminator/ast.rb +2 -0
- data/lib/dead_code_terminator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 120030c3b768640a90d8b8d3f762280835dc107e03214c47a53611d39e30a7a7
|
4
|
+
data.tar.gz: 29cc7f27dc056671f4c7104ff653020e64842b010a386e9095ce9cf75020a80c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bef01523a2c5803bae4d3aecb43878195b7e6138656e0bb5d686d6d28ce7a351aec3bcfe06b760dc3fd2d53441d34e1a293a14461157b04a2da9c6450a93364
|
7
|
+
data.tar.gz: fa2641062b631410568e8319781a83dd05341364acfbf961dec5fae09ecfa5d92b7adb87ca5c088af5cb3500dd6445ab2a774fa52c49e2927a51657cac97f8c7
|
data/README.md
CHANGED
@@ -7,24 +7,37 @@
|
|
7
7
|
This acts like [webpack's DefinePlugin](https://webpack.js.org/plugins/define-plugin/) with minification pass. It allows to eliminate dead code statically, which can be required by regulations.
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
if ENV['
|
11
|
-
|
10
|
+
value = if ENV['FLAG']
|
11
|
+
:then_branch
|
12
12
|
else
|
13
|
-
|
13
|
+
value2 = unless ENV['PRODUCTION']
|
14
|
+
:then_branch
|
15
|
+
else
|
16
|
+
ENV['RUNTIME'] ? :else1 : :else2
|
17
|
+
end
|
14
18
|
end
|
15
19
|
```
|
16
20
|
|
17
21
|
```ruby
|
18
|
-
|
19
|
-
|
22
|
+
# returns a valid ruby code string back with statically evaluated conditions
|
23
|
+
DeadCodeTerminator.strip(string, env: { "PRODUCTION" => true, "FLAG" => false })
|
24
|
+
```
|
20
25
|
|
21
|
-
|
26
|
+
```ruby
|
27
|
+
value =
|
22
28
|
|
29
|
+
|
30
|
+
value2 =
|
31
|
+
|
32
|
+
|
33
|
+
ENV['RUNTIME'] ? :else1 : :else2
|
23
34
|
```
|
24
35
|
|
25
36
|
Note: it keeps *precise* code locations (including whitespaces and line-breaks).
|
26
37
|
So if you have hotfix patches from upstream - they'll be applied without conflicts.
|
27
38
|
|
39
|
+
Other example can be found in [specs](https://github.com/razum2um/dead_code_terminator/blob/master/spec/dead_code_terminator_spec.rb)
|
40
|
+
|
28
41
|
## TODO
|
29
42
|
|
30
43
|
- builtin file tree processing
|