raka 0.3.10 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +54 -6
- data/VERSION +1 -1
- data/lib/raka/compile.rb +1 -0
- data/lib/raka/token.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c18ff3ef2a33821e333fec106d2f64ade89ca0f416d02c914ce5b5eb1601ba0
|
4
|
+
data.tar.gz: ca858c3ea2807d209cceebe85ae1d4e987bd125597fd9575bb82d907785ed109
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d8089d3f500a7f57789be879cd7f4f2fbadd2fd64ba0ca2957694289813587a5b603d7c0cb5fe8b5e84c442eccd7274f3203aef4f1e94f5830039e53cc7c3da
|
7
|
+
data.tar.gz: 37625d41c5e2d09d47254d0be9497a95fcbc2b33810fb5ab942050763db35f4c2b3d1958c52a478b72eefe2c65e48ae619be52ec252e0365d58978bafaa2b0f9
|
data/README.md
CHANGED
@@ -338,7 +338,7 @@ In the host protocol and the block versions of other protocols, a raka task (the
|
|
338
338
|
| scope | scope for current task, i.e. the common directory for output, input and dependencies |
|
339
339
|
| target_scope | the inline scope defined in target |
|
340
340
|
| target_scope_captures | captured values by inline scope defined in target |
|
341
|
-
| rule_scopes | the
|
341
|
+
| rule_scopes | the scope components bounded by the rule scopes |
|
342
342
|
|
343
343
|
```ruby
|
344
344
|
require 'raka'
|
@@ -469,13 +469,61 @@ The `input_types` involves the strategy to find inputs. All possible input types
|
|
469
469
|
|
470
470
|
### Scope
|
471
471
|
|
472
|
-
Scopes
|
472
|
+
Scopes represent the context of a running task and its components, which are generally folders physically. Users can define scope constraints with rules to help users create rules more precisely. and can happen in several places.
|
473
473
|
|
474
|
-
|
474
|
+
Scope constraints:
|
475
475
|
|
476
|
-
**Rule scope** is the scope to restrict possible task scope
|
476
|
+
**Rule scope** is the scope to restrict possible task scope. Rule scopes can be layered, each layer with several options, like:
|
477
477
|
|
478
|
-
|
478
|
+
```ruby
|
479
|
+
dsl.scope :de, :fr
|
480
|
+
dsl.scope :food, :med
|
481
|
+
...rules
|
482
|
+
end
|
483
|
+
end
|
484
|
+
```
|
485
|
+
|
486
|
+
**Target scope** is the scope to restrict a single target. It can be used in the left-hand part of a rule, or as dependencies in the right-hand. For example:
|
487
|
+
|
488
|
+
```ruby
|
489
|
+
# The constraint "de" only apply to food.csv and fruit__food.csv, not classifier.csv
|
490
|
+
csv('de').food.fruit = [csv.classifier] | action
|
491
|
+
```
|
492
|
+
|
493
|
+
When resolved, scope constraints are verified and scopes are extracted and parsed, including the following concepts:
|
494
|
+
|
495
|
+
**Scope**(**Task scope**) is the common scope of the task, every target is resolved under the scope.
|
496
|
+
|
497
|
+
**Rule bounded scopes** (abbr. rule scopes) are the parts of scope bounded by the **Rule scope** constraints.
|
498
|
+
|
499
|
+
**Target bounded scope** (abbr. target scope) is the part of scope bounded by the **Target scope** constraints.
|
500
|
+
|
501
|
+
**Output scope** is the scope of output, while **Dep scope** is the scope of dependencies.
|
502
|
+
|
503
|
+
The following example illustrates the relationships of the above concepts.
|
504
|
+
|
505
|
+
Rule definition:
|
506
|
+
|
507
|
+
```ruby
|
508
|
+
dsl.scope :de, :fr,
|
509
|
+
dsl.scope :food, :med
|
510
|
+
csv('percent_(\d+)').data.cheap = [csv('base').price] | ...
|
511
|
+
end
|
512
|
+
end
|
513
|
+
```
|
514
|
+
|
515
|
+
When running `raka out/de/food/percent_50/cheap__data.csv`, the extracted scopes are as follows:
|
516
|
+
|
517
|
+
![](https://cdn.rawgit.com/yarray/raka/master/doc/scope.svg)
|
518
|
+
|
519
|
+
The auto variables are:
|
520
|
+
|
521
|
+
|var|value|var|value|
|
522
|
+
|---|-----|---|-----|
|
523
|
+
|$(scope)|out/de/food|$(output_scope)|out/de/food/percent_50|
|
524
|
+
|$(rule_scope0)|food|$(rule_scope1)|de|
|
525
|
+
|$(target_scope)|percent_50|$(target_scope0)|50|
|
526
|
+
|$(dep1_scope)|out/de/food/base|||
|
479
527
|
|
480
528
|
## Rakefile Template
|
481
529
|
|
@@ -483,4 +531,4 @@ Scopes define constraints which help users create rules more precisely. A scope
|
|
483
531
|
|
484
532
|
## Compare to other tools
|
485
533
|
|
486
|
-
Raka borrows some ideas from Drake but not much (currently mainly the name "protocol"). Briefly we have different visions and maybe different suitable
|
534
|
+
Raka borrows some ideas from Drake but not much (currently mainly the name "protocol"). Briefly, we have different visions and maybe different suitable scenarios.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.11
|
data/lib/raka/compile.rb
CHANGED
data/lib/raka/token.rb
CHANGED
@@ -58,7 +58,7 @@ class Token
|
|
58
58
|
res = Hash[info.names.zip(info.captures)]
|
59
59
|
unless info[:scope].nil?
|
60
60
|
rule_scopes = Regexp.new(_scope_pattern_).match(info[:scope]).captures
|
61
|
-
res[:rule_scopes] = rule_scopes[
|
61
|
+
res[:rule_scopes] = rule_scopes[2..-1].reverse
|
62
62
|
end
|
63
63
|
if !@inline_scope.nil? && !info[:target_scope].nil?
|
64
64
|
segs = Regexp.new(@inline_scope).match(info[:target_scope]).captures
|
@@ -130,8 +130,12 @@ class Token
|
|
130
130
|
[auto_input]
|
131
131
|
end
|
132
132
|
|
133
|
+
def _rule_scope_pattern_
|
134
|
+
(@context.scopes.map { |layer| "(#{layer.join('|')})" }).join('/') + ')'
|
135
|
+
end
|
136
|
+
|
133
137
|
def _scope_pattern_
|
134
|
-
'((?:(\S+)/)?' +
|
138
|
+
'((?:(\S+)/)?' + _rule_scope_pattern_
|
135
139
|
end
|
136
140
|
|
137
141
|
def _pattern_
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yarray
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|