alf-shell 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -2
- data/Gemfile.lock +29 -10
- data/bin/alf +2 -0
- data/doc/man/alf-explain.man +22 -0
- data/doc/man/alf-metadata.man +13 -0
- data/doc/man/alf-show.man +16 -0
- data/doc/man/alf.man +77 -0
- data/doc/man/allbut.man +39 -0
- data/doc/man/among.man +25 -0
- data/doc/man/avg.man +37 -0
- data/doc/man/between.man +24 -0
- data/doc/man/concat.man +55 -0
- data/doc/man/contradiction.man +26 -0
- data/doc/man/count.man +20 -0
- data/doc/man/eq.man +29 -0
- data/doc/man/extend.man +33 -0
- data/doc/man/frame.man +60 -0
- data/doc/man/group.man +51 -0
- data/doc/man/gt.man +30 -0
- data/doc/man/gte.man +30 -0
- data/doc/man/intersect.man +54 -0
- data/doc/man/join.man +84 -0
- data/doc/man/lt.man +30 -0
- data/doc/man/lte.man +30 -0
- data/doc/man/matching.man +73 -0
- data/doc/man/max.man +36 -0
- data/doc/man/min.man +36 -0
- data/doc/man/minus.man +54 -0
- data/doc/man/native.man +32 -0
- data/doc/man/neq.man +29 -0
- data/doc/man/not_matching.man +51 -0
- data/doc/man/page.man +60 -0
- data/doc/man/project.man +36 -0
- data/doc/man/rank.man +42 -0
- data/doc/man/rename.man +29 -0
- data/doc/man/restrict.man +38 -0
- data/doc/man/stddev.man +37 -0
- data/doc/man/sum.man +37 -0
- data/doc/man/summarize.man +45 -0
- data/doc/man/tautology.man +26 -0
- data/doc/man/ungroup.man +30 -0
- data/doc/man/union.man +55 -0
- data/doc/man/unwrap.man +37 -0
- data/doc/man/variance.man +37 -0
- data/doc/man/wrap.man +37 -0
- data/doc/txt/alf-explain.man +22 -0
- data/doc/txt/alf-metadata.man +16 -0
- data/doc/txt/alf-show.man +19 -0
- data/doc/txt/alf.man +80 -0
- data/doc/txt/allbut.txt +31 -0
- data/doc/txt/among.txt +20 -0
- data/doc/txt/avg.txt +22 -0
- data/doc/txt/between.txt +19 -0
- data/doc/txt/concat.txt +31 -0
- data/doc/txt/contradiction.txt +15 -0
- data/doc/txt/count.txt +14 -0
- data/doc/txt/eq.txt +19 -0
- data/doc/txt/extend.txt +29 -0
- data/doc/txt/frame.txt +48 -0
- data/doc/txt/group.txt +37 -0
- data/doc/txt/gt.txt +20 -0
- data/doc/txt/gte.txt +20 -0
- data/doc/txt/intersect.txt +42 -0
- data/doc/txt/join.txt +65 -0
- data/doc/txt/lt.txt +20 -0
- data/doc/txt/lte.txt +20 -0
- data/doc/txt/matching.txt +54 -0
- data/doc/txt/max.txt +21 -0
- data/doc/txt/min.txt +21 -0
- data/doc/txt/minus.txt +42 -0
- data/doc/txt/native.txt +27 -0
- data/doc/txt/neq.txt +19 -0
- data/doc/txt/not_matching.txt +39 -0
- data/doc/txt/page.txt +48 -0
- data/doc/txt/project.txt +28 -0
- data/doc/txt/rank.txt +34 -0
- data/doc/txt/rename.txt +25 -0
- data/doc/txt/restrict.txt +26 -0
- data/doc/txt/stddev.txt +22 -0
- data/doc/txt/sum.txt +22 -0
- data/doc/txt/summarize.txt +33 -0
- data/doc/txt/tautology.txt +15 -0
- data/doc/txt/ungroup.txt +26 -0
- data/doc/txt/union.txt +43 -0
- data/doc/txt/unwrap.txt +29 -0
- data/doc/txt/variance.txt +22 -0
- data/doc/txt/wrap.txt +29 -0
- data/lib/alf/shell.rb +2 -32
- data/lib/alf/shell/alfrc.rb +3 -0
- data/lib/alf/shell/command.rb +2 -18
- data/lib/alf/shell/command/explain.rb +37 -0
- data/lib/alf/shell/command/help.rb +3 -21
- data/lib/alf/shell/command/main.rb +20 -78
- data/lib/alf/shell/command/metadata.rb +32 -0
- data/lib/alf/shell/command/show.rb +17 -5
- data/lib/alf/shell/support.rb +21 -13
- data/lib/alf/shell/version.rb +1 -1
- data/spec/integration/explain/explain.cmd +1 -0
- data/spec/integration/explain/explain.stdout +11 -0
- data/spec/integration/show/group.alf +2 -0
- data/spec/integration/show/show_alf.cmd +1 -0
- data/spec/integration/{group/group_0.stdout → show/show_alf.stdout} +0 -0
- data/tasks/doc.rake +4 -0
- metadata +116 -178
- data/doc/commands/exec.md +0 -16
- data/doc/commands/help.md +0 -11
- data/doc/commands/main.md +0 -33
- data/doc/commands/show.md +0 -12
- data/doc/operators/non_relational/autonum.md +0 -23
- data/doc/operators/non_relational/clip.md +0 -31
- data/doc/operators/non_relational/coerce.md +0 -15
- data/doc/operators/non_relational/compact.md +0 -20
- data/doc/operators/non_relational/defaults.md +0 -32
- data/doc/operators/non_relational/generator.md +0 -20
- data/doc/operators/non_relational/sort.md +0 -24
- data/doc/operators/non_relational/type-safe.md +0 -20
- data/doc/operators/relational/extend.md +0 -18
- data/doc/operators/relational/frame.md +0 -26
- data/doc/operators/relational/group.md +0 -27
- data/doc/operators/relational/hierarchize.md +0 -14
- data/doc/operators/relational/infer-heading.md +0 -20
- data/doc/operators/relational/intersect.md +0 -13
- data/doc/operators/relational/join.md +0 -28
- data/doc/operators/relational/matching.md +0 -24
- data/doc/operators/relational/minus.md +0 -12
- data/doc/operators/relational/not-matching.md +0 -20
- data/doc/operators/relational/page.md +0 -31
- data/doc/operators/relational/project.md +0 -28
- data/doc/operators/relational/quota.md +0 -21
- data/doc/operators/relational/rank.md +0 -27
- data/doc/operators/relational/rename.md +0 -17
- data/doc/operators/relational/restrict.md +0 -25
- data/doc/operators/relational/summarize.md +0 -25
- data/doc/operators/relational/ungroup.md +0 -20
- data/doc/operators/relational/union.md +0 -14
- data/doc/operators/relational/unwrap.md +0 -20
- data/doc/operators/relational/wrap.md +0 -24
- data/lib/alf/shell/command/exec.rb +0 -16
- data/lib/alf/shell/doc_manager.rb +0 -84
- data/lib/alf/shell/ext/signature.rb +0 -45
- data/lib/alf/shell/from_argv.rb +0 -84
- data/lib/alf/shell/operator.rb +0 -63
- data/spec/integration/__database__/group.alf +0 -3
- data/spec/integration/alf/alf_e.cmd +0 -1
- data/spec/integration/alf/alf_e.stdout +0 -4
- data/spec/integration/alf/alf_help.cmd +0 -1
- data/spec/integration/alf/alf_help.stdout +0 -76
- data/spec/integration/alf/alf_r.cmd +0 -1
- data/spec/integration/alf/alf_r.stdout +0 -5
- data/spec/integration/autonum/autonum_0.cmd +0 -1
- data/spec/integration/autonum/autonum_0.stdout +0 -9
- data/spec/integration/autonum/autonum_1.cmd +0 -1
- data/spec/integration/autonum/autonum_1.stdout +0 -9
- data/spec/integration/clip/clip_0.cmd +0 -1
- data/spec/integration/clip/clip_0.stdout +0 -9
- data/spec/integration/clip/clip_1.cmd +0 -1
- data/spec/integration/clip/clip_1.stdout +0 -9
- data/spec/integration/coerce/coerce_1.cmd +0 -1
- data/spec/integration/coerce/coerce_1.stdout +0 -5
- data/spec/integration/compact/compact_0.cmd +0 -1
- data/spec/integration/compact/compact_0.stdout +0 -9
- data/spec/integration/defaults/defaults_0.cmd +0 -1
- data/spec/integration/defaults/defaults_0.stdout +0 -9
- data/spec/integration/defaults/defaults_1.cmd +0 -1
- data/spec/integration/defaults/defaults_1.stdout +0 -9
- data/spec/integration/defaults/defaults_2.cmd +0 -1
- data/spec/integration/defaults/defaults_2.stdout +0 -9
- data/spec/integration/extend/extend_0.cmd +0 -1
- data/spec/integration/extend/extend_0.stdout +0 -16
- data/spec/integration/frame/frame_0.cmd +0 -1
- data/spec/integration/frame/frame_0.stdout +0 -6
- data/spec/integration/generator/generator_1.cmd +0 -1
- data/spec/integration/generator/generator_1.stdout +0 -10
- data/spec/integration/generator/generator_2.cmd +0 -1
- data/spec/integration/generator/generator_2.stdout +0 -5
- data/spec/integration/generator/generator_3.cmd +0 -1
- data/spec/integration/generator/generator_3.stdout +0 -5
- data/spec/integration/group/group_0.cmd +0 -1
- data/spec/integration/group/group_1.cmd +0 -1
- data/spec/integration/group/group_1.stdout +0 -32
- data/spec/integration/help/help_1.cmd +0 -1
- data/spec/integration/help/help_1.stdout +0 -12
- data/spec/integration/intersect/intersect_0.cmd +0 -1
- data/spec/integration/intersect/intersect_0.stdout +0 -9
- data/spec/integration/join/join_0.cmd +0 -1
- data/spec/integration/join/join_0.stdout +0 -16
- data/spec/integration/matching/matching_0.cmd +0 -1
- data/spec/integration/matching/matching_0.stdout +0 -8
- data/spec/integration/minus/minus_0.cmd +0 -1
- data/spec/integration/minus/minus_0.stdout +0 -4
- data/spec/integration/not-matching/not-matching_0.cmd +0 -1
- data/spec/integration/not-matching/not-matching_0.stdout +0 -5
- data/spec/integration/page/page_0.cmd +0 -1
- data/spec/integration/page/page_0.stdout +0 -6
- data/spec/integration/project/project_0.cmd +0 -1
- data/spec/integration/project/project_0.stdout +0 -9
- data/spec/integration/project/project_1.cmd +0 -1
- data/spec/integration/project/project_1.stdout +0 -9
- data/spec/integration/quota/quota_0.cmd +0 -1
- data/spec/integration/quota/quota_0.stdout +0 -16
- data/spec/integration/rank/rank_1.cmd +0 -1
- data/spec/integration/rank/rank_1.stdout +0 -10
- data/spec/integration/rank/rank_2.cmd +0 -1
- data/spec/integration/rank/rank_2.stdout +0 -10
- data/spec/integration/rank/rank_3.cmd +0 -1
- data/spec/integration/rank/rank_3.stdout +0 -10
- data/spec/integration/rank/rank_4.cmd +0 -1
- data/spec/integration/rank/rank_4.stdout +0 -6
- data/spec/integration/rank/rank_5.cmd +0 -1
- data/spec/integration/rank/rank_5.stdout +0 -6
- data/spec/integration/rename/rename_0.cmd +0 -1
- data/spec/integration/rename/rename_0.stdout +0 -9
- data/spec/integration/restrict/restrict_0.cmd +0 -1
- data/spec/integration/restrict/restrict_0.stdout +0 -6
- data/spec/integration/restrict/restrict_1.cmd +0 -1
- data/spec/integration/restrict/restrict_1.stdout +0 -6
- data/spec/integration/sort/sort_0.cmd +0 -1
- data/spec/integration/sort/sort_0.stdout +0 -9
- data/spec/integration/sort/sort_1.cmd +0 -1
- data/spec/integration/sort/sort_1.stdout +0 -9
- data/spec/integration/sort/sort_2.cmd +0 -1
- data/spec/integration/sort/sort_2.stdout +0 -9
- data/spec/integration/sort/sort_3.cmd +0 -1
- data/spec/integration/sort/sort_3.stdout +0 -9
- data/spec/integration/summarize/summarize_0.cmd +0 -1
- data/spec/integration/summarize/summarize_0.stdout +0 -8
- data/spec/integration/union/union_0.cmd +0 -1
- data/spec/integration/union/union_0.stdout +0 -9
- data/spec/integration/unwrap/unwrap_0.cmd +0 -1
- data/spec/integration/unwrap/unwrap_0.stdout +0 -9
- data/spec/integration/wrap/wrap_0.cmd +0 -1
- data/spec/integration/wrap/wrap_0.stdout +0 -9
- data/spec/unit/doc_manager/dynamic.md +0 -1
- data/spec/unit/doc_manager/example.md +0 -1
- data/spec/unit/doc_manager/example_1.txt +0 -11
- data/spec/unit/doc_manager/static.md +0 -1
- data/spec/unit/doc_manager/test_call.rb +0 -41
- data/spec/unit/ext/signature/test_argv2args.rb +0 -82
- data/spec/unit/ext/signature/test_to_shell.rb +0 -103
- data/spec/unit/from_argv/test_to_attr_list.rb +0 -30
- data/spec/unit/from_argv/test_to_attr_name.rb +0 -27
- data/spec/unit/from_argv/test_to_boolean.rb +0 -32
- data/spec/unit/from_argv/test_to_heading.rb +0 -37
- data/spec/unit/from_argv/test_to_ordering.rb +0 -28
- data/spec/unit/from_argv/test_to_predicate.rb +0 -26
- data/spec/unit/from_argv/test_to_renaming.rb +0 -23
- data/spec/unit/from_argv/test_to_size.rb +0 -32
- data/spec/unit/from_argv/test_to_summarization.rb +0 -19
- data/spec/unit/from_argv/test_to_tuple_computation.rb +0 -18
- data/spec/unit/from_argv/test_to_tuple_expression.rb +0 -38
- data/spec/unit/main/test_class_methods.rb +0 -44
- data/spec/unit/operator/test_autonum.rb +0 -28
- data/spec/unit/operator/test_clip.rb +0 -29
- data/spec/unit/operator/test_coerce.rb +0 -22
- data/spec/unit/operator/test_compact.rb +0 -16
- data/spec/unit/operator/test_defaults.rb +0 -29
- data/spec/unit/operator/test_extend.rb +0 -21
- data/spec/unit/operator/test_generator.rb +0 -37
- data/spec/unit/operator/test_group.rb +0 -32
- data/spec/unit/operator/test_infer_heading.rb +0 -16
- data/spec/unit/operator/test_intersect.rb +0 -18
- data/spec/unit/operator/test_join.rb +0 -18
- data/spec/unit/operator/test_matching.rb +0 -18
- data/spec/unit/operator/test_minus.rb +0 -18
- data/spec/unit/operator/test_not_matching.rb +0 -18
- data/spec/unit/operator/test_project.rb +0 -38
- data/spec/unit/operator/test_quota.rb +0 -23
- data/spec/unit/operator/test_rank.rb +0 -30
- data/spec/unit/operator/test_rename.rb +0 -21
- data/spec/unit/operator/test_restrict.rb +0 -36
- data/spec/unit/operator/test_sort.rb +0 -49
- data/spec/unit/operator/test_summarize.rb +0 -30
- data/spec/unit/operator/test_ungroup.rb +0 -28
- data/spec/unit/operator/test_union.rb +0 -18
- data/spec/unit/operator/test_unwrap.rb +0 -28
- data/spec/unit/operator/test_wrap.rb +0 -30
@@ -1,20 +0,0 @@
|
|
1
|
-
|
2
|
-
Relational not matching (inverse of matching)
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
DESCRIPTION
|
9
|
-
|
10
|
-
This operator restricts LEFT tuples to those for which there does not
|
11
|
-
exist any tuple in RIGHT that (naturally) joins. This is a shortcut
|
12
|
-
operator for the following longer expression:
|
13
|
-
|
14
|
-
(minus xxx, (matching xxx, yyy))
|
15
|
-
|
16
|
-
EXAMPLE
|
17
|
-
|
18
|
-
# Which suppliers do not supply any part?
|
19
|
-
!(alf not-matching suppliers supplies)
|
20
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
|
2
|
-
Relational pagination (like frame, but easier)
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
DESCRIPTION
|
9
|
-
|
10
|
-
This command provides pagination over the input relation.
|
11
|
-
|
12
|
-
When page_index is positive (resp. striclty negative), this operator returns
|
13
|
-
`page_size` tuples whose ranking according to `ordering` (resp. reverse
|
14
|
-
ordering) is between `page_size * (page_index - 1)` and `page_size * page_index`
|
15
|
-
(excluded).
|
16
|
-
|
17
|
-
To be sound, this operator requires the ordering to include a candidate key
|
18
|
-
for the input relation. Alf will automatically extend the ordering you provide
|
19
|
-
to guarantee this, provided key inference is possible.
|
20
|
-
|
21
|
-
EXAMPLE
|
22
|
-
|
23
|
-
# Take the first two suppliers ordered by name (then by id)
|
24
|
-
!(alf page --page-size=2 suppliers -- name -- 1)
|
25
|
-
|
26
|
-
# Take the next two suppliers
|
27
|
-
!(alf page --page-size=2 suppliers -- name -- 2)
|
28
|
-
|
29
|
-
# Take the last two suppliers
|
30
|
-
!(alf page --page-size=2 suppliers -- name -- -1)
|
31
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
|
2
|
-
Relational projection (clip + compact)
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
OPTIONS
|
9
|
-
|
10
|
-
#(summarized_options)
|
11
|
-
|
12
|
-
DESCRIPTION
|
13
|
-
|
14
|
-
This operator projects tuples on attributes whose names are specified in
|
15
|
-
ATTRIBUTES. Unlike SQL, this operator **always** removes duplicates in the
|
16
|
-
result so that the output is a set of tuples, that is, a relation.
|
17
|
-
|
18
|
-
With the allbut option, the operator projects ATTRIBUTES away instead of
|
19
|
-
keeping them.
|
20
|
-
|
21
|
-
EXAMPLE
|
22
|
-
|
23
|
-
# What are supplier cities ?
|
24
|
-
!(alf project suppliers -- city)
|
25
|
-
|
26
|
-
# What are all but supplier's id and name
|
27
|
-
!(alf project --allbut suppliers -- sid name)
|
28
|
-
|
@@ -1,21 +0,0 @@
|
|
1
|
-
|
2
|
-
Generalized quota-queries (position, sum progression, etc.)
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
DESCRIPTION
|
9
|
-
|
10
|
-
**This operator is a work in progress and should be used with care.**
|
11
|
-
|
12
|
-
This operator is an attempt to generalize RANK in two directions:
|
13
|
-
|
14
|
-
* Use a full SUMMARIZATION instead of hard-coding a ranking attribute via count()
|
15
|
-
* Providing a BY key so that summarizations can actually be done on sub-groups
|
16
|
-
|
17
|
-
EXAMPLE
|
18
|
-
|
19
|
-
# Compute linear progression of quantities by supplier number
|
20
|
-
!(alf quota supplies -- sid -- qty -- position count sum_qty "sum{ qty }")
|
21
|
-
|
@@ -1,27 +0,0 @@
|
|
1
|
-
|
2
|
-
Relational ranking (explicit tuple positions)
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
DESCRIPTION
|
9
|
-
|
10
|
-
This operator computes the ranking of input tuples, according to ORDER.
|
11
|
-
|
12
|
-
Precisely, it extends its operand with an attribute called AS whose value
|
13
|
-
is the number of tuples which are considered strictly less according to the
|
14
|
-
order relation denoted by ORDER.
|
15
|
-
|
16
|
-
Note that, unless the ordering includes a candidate key for the input relation,
|
17
|
-
the new AS attribute is not necessarily a candidate key for the output.
|
18
|
-
|
19
|
-
EXAMPLE
|
20
|
-
|
21
|
-
# Rank parts by weight
|
22
|
-
!(alf rank parts -- weight -- position)
|
23
|
-
|
24
|
-
# Rank parts by weight in descending order. Ensure that position is a
|
25
|
-
# candidate key by including a key in ordering
|
26
|
-
!(alf rank parts -- weight desc pid asc -- position)
|
27
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
|
2
|
-
Relational renaming (rename some attributes)
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
DESCRIPTION
|
9
|
-
|
10
|
-
This command renames attributes as specified in RENAMING, taken as successive
|
11
|
-
(old name, new name) pairs
|
12
|
-
|
13
|
-
EXAMPLE
|
14
|
-
|
15
|
-
# Rename a few supplier attributes
|
16
|
-
!(alf rename suppliers -- name supplier_name city supplier_city)
|
17
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
|
2
|
-
Relational restriction (aka where, predicate filtering)
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
DESCRIPTION
|
9
|
-
|
10
|
-
This command restricts restricts relations to those tuples for which PREDICATE
|
11
|
-
evaluates to true.
|
12
|
-
|
13
|
-
PREDICATE must be a valid tuple expression that returns a truth-value. It
|
14
|
-
may be specified as a ruby code literal, or a mapping between (name, value)
|
15
|
-
pairs. In the latter case, PREDICATE is built as a conjunction of attribute
|
16
|
-
equalities.
|
17
|
-
|
18
|
-
EXAMPLE
|
19
|
-
|
20
|
-
# Who are suppliers with a status greater than 20?
|
21
|
-
!(alf restrict suppliers -- "status > 20")
|
22
|
-
|
23
|
-
# Which suppliers live in London?
|
24
|
-
!(alf restrict suppliers -- city "'London'")
|
25
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
|
2
|
-
Relational summarization (group-by + aggregate ops)
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
OPTIONS
|
9
|
-
|
10
|
-
#(summarized_options)
|
11
|
-
|
12
|
-
DESCRIPTION
|
13
|
-
|
14
|
-
This operator summarizes input tuples over a projection given by BY.
|
15
|
-
SUMMARIZATION is a mapping between attribute names and summarizing
|
16
|
-
expressions.
|
17
|
-
|
18
|
-
With the allbut option, the operator uses all attributes not specified
|
19
|
-
in BY as the projection key.
|
20
|
-
|
21
|
-
EXAMPLE
|
22
|
-
|
23
|
-
# Compute the sum of supplied quantities, by supplier id
|
24
|
-
!(alf summarize supplies -- sid -- total_qty "sum{ qty }")
|
25
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
|
2
|
-
Relational un-grouping (inverse of group)
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
DESCRIPTION
|
9
|
-
|
10
|
-
This operator flattens its operand by ungrouping the relation-valued
|
11
|
-
attribute ATTR.
|
12
|
-
|
13
|
-
EXAMPLE
|
14
|
-
|
15
|
-
# Given `pid` and `qty` groupped as `supplying`
|
16
|
-
!(alf group supplies -- pid qty -- supplying)
|
17
|
-
|
18
|
-
# Let's ungroup them
|
19
|
-
!(alf group supplies -- pid qty -- supplying | alf ungroup -- supplying)
|
20
|
-
|
@@ -1,14 +0,0 @@
|
|
1
|
-
|
2
|
-
Relational union
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
DESCRIPTION
|
9
|
-
|
10
|
-
This operator computes the union of its operands, that is the set of
|
11
|
-
tuples that appear in LEFT or in RIGHT.
|
12
|
-
|
13
|
-
The result is a valid relation in that it never contains duplicates.
|
14
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
|
2
|
-
Relational un-wrapping (inverse of wrap)
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
DESCRIPTION
|
9
|
-
|
10
|
-
This operator flattens its operand by unwrapping the tuple-valued
|
11
|
-
attribute ATTR.
|
12
|
-
|
13
|
-
EXAMPLE
|
14
|
-
|
15
|
-
# Given, `city` and `status` wrapped as `loc_and_status`
|
16
|
-
!(alf wrap suppliers -- city status -- loc_and_status)
|
17
|
-
|
18
|
-
# Let's unwrap them
|
19
|
-
!(alf wrap suppliers -- city status -- loc_and_status | alf unwrap -- loc_and_status)
|
20
|
-
|
@@ -1,24 +0,0 @@
|
|
1
|
-
|
2
|
-
Relational wrapping (tuple-valued attributes)
|
3
|
-
|
4
|
-
SYNOPSIS
|
5
|
-
|
6
|
-
#(signature)
|
7
|
-
|
8
|
-
OPTIONS
|
9
|
-
|
10
|
-
#(summarized_options)
|
11
|
-
|
12
|
-
DESCRIPTION
|
13
|
-
|
14
|
-
This operator wraps attributes in ATTRIBUTES as a new, tuple-valued attribute
|
15
|
-
named AS.
|
16
|
-
|
17
|
-
With the allbut option, it wraps all attributes not specified in ATTRIBUTES
|
18
|
-
instead.
|
19
|
-
|
20
|
-
EXAMPLE
|
21
|
-
|
22
|
-
# Wrap `city` and `status` and a tuple-value attribute named `loc_and_status`
|
23
|
-
!(alf wrap suppliers -- city status -- loc_and_status)
|
24
|
-
|
@@ -1,84 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Shell
|
3
|
-
class DocManager
|
4
|
-
|
5
|
-
# Main documentation folder
|
6
|
-
DOC_FOLDER = Path.backfind("doc")
|
7
|
-
|
8
|
-
#
|
9
|
-
# Called by Quickl when it's time to generate documentation of `cmd`.
|
10
|
-
#
|
11
|
-
def call(cmd, options = {})
|
12
|
-
if (file = find_file(cmd)).file?
|
13
|
-
text = file.read
|
14
|
-
|
15
|
-
# Replace occurences of #{signature} to #{signature.to_xxx}
|
16
|
-
# according to options
|
17
|
-
method = (options[:method] || "shell").to_s
|
18
|
-
text = text.gsub('#(signature)', '#(signature.to_' + method + ')')
|
19
|
-
|
20
|
-
# Replace occurences of #{...} on single lines
|
21
|
-
text = text.gsub(/^([ \t]*)#\(([^\)]+)\)/){|match|
|
22
|
-
spacing, invocation = $1, $2
|
23
|
-
res = cmd.instance_eval(invocation).to_s
|
24
|
-
realign(res, spacing, true)
|
25
|
-
}
|
26
|
-
|
27
|
-
# Replace occurences of #{...} in other places
|
28
|
-
text = text.gsub(/#\(([^\)]+)\)/){|match|
|
29
|
-
cmd.instance_eval($1).to_s
|
30
|
-
}
|
31
|
-
|
32
|
-
# Replace occurences of !{...} by the execution of the example
|
33
|
-
text = text.gsub(/^([ \t]*)!\(([^\)]+)\)/){|match|
|
34
|
-
spacing, invocation = $1, $2
|
35
|
-
args = Quickl.parse_commandline_args(invocation)[1..-1]
|
36
|
-
op = run_alf_command(args)
|
37
|
-
res = op.to_relation.to_s
|
38
|
-
res = realign(res, spacing, false)[0...-1]
|
39
|
-
if options[:method] == :lispy
|
40
|
-
invocation = Alf::Support.to_lispy(op)
|
41
|
-
end
|
42
|
-
realign("$ #{invocation}\n\n#{res}", spacing, false)
|
43
|
-
}
|
44
|
-
|
45
|
-
else
|
46
|
-
"Sorry, no documentation available for #{cmd.command_name}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def run_alf_command(argv, requester = nil)
|
53
|
-
argv = Quickl.parse_commandline_args(argv) if argv.is_a?(String)
|
54
|
-
argv = Quickl.split_commandline_args(argv, '|')
|
55
|
-
argv.inject(nil) do |cmd,arr|
|
56
|
-
arr.shift if arr.first == "alf"
|
57
|
-
main = Alf::Shell::Main.new(Alf::Shell::DEFAULT_CONFIG)
|
58
|
-
main.config.adapter = Alf.examples_adapter
|
59
|
-
main.stdin_operand = cmd unless cmd.nil?
|
60
|
-
main.run(arr, requester)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def realign(txt, spacing, strip)
|
65
|
-
rx = strip ? /^[ \t]*/ : /^/
|
66
|
-
txt.gsub(rx, spacing)
|
67
|
-
end
|
68
|
-
|
69
|
-
def find_file(cmd)
|
70
|
-
where = if cmd.command?
|
71
|
-
"commands"
|
72
|
-
elsif cmd.operator? && cmd.relational?
|
73
|
-
File.join("operators", "relational")
|
74
|
-
elsif cmd.operator? && cmd.non_relational?
|
75
|
-
File.join("operators", "non_relational")
|
76
|
-
else
|
77
|
-
raise "Unexpected command #{cmd}"
|
78
|
-
end
|
79
|
-
DOC_FOLDER/where/"#{cmd.command_name}.md"
|
80
|
-
end
|
81
|
-
|
82
|
-
end # class DocManager
|
83
|
-
end # module Shell
|
84
|
-
end # module Alf
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Algebra
|
3
|
-
class Signature
|
4
|
-
|
5
|
-
# Converts commandline arguments to operator constructor arguments
|
6
|
-
def argv2args(argv)
|
7
|
-
# First split over --
|
8
|
-
argv = Quickl.split_commandline_args(argv)
|
9
|
-
|
10
|
-
# Parse the options and replace argv[0] by remaining arguments
|
11
|
-
opts = {}
|
12
|
-
argv[0] = option_parser(opts).parse!(argv[0])
|
13
|
-
opts = default_options.merge(opts)
|
14
|
-
|
15
|
-
# Operands are argv[0], and can be removed
|
16
|
-
oper = argv.shift
|
17
|
-
|
18
|
-
# Coerce each remaining argument according to the signature
|
19
|
-
args = []
|
20
|
-
with_each_arg(argv) do |name,dom,value|
|
21
|
-
invalid_args!(args) if value.nil?
|
22
|
-
args << Shell.from_argv(Array(value), dom)
|
23
|
-
end
|
24
|
-
|
25
|
-
[oper, args, opts]
|
26
|
-
end
|
27
|
-
|
28
|
-
# Returns a shell synopsis for this signature.
|
29
|
-
#
|
30
|
-
# Example:
|
31
|
-
#
|
32
|
-
# Alf::Algebra::Project.signature.to_shell
|
33
|
-
# # => "alf project [--allbut] [OPERAND] -- ATTRIBUTES"
|
34
|
-
def to_shell
|
35
|
-
oper = operator.nullary? ? "" :
|
36
|
-
(operator.unary? ? "[OPERAND]" : "[LEFT] RIGHT")
|
37
|
-
opts = options.map{|opt| "[#{option_name(opt)}]" }.join(" ")
|
38
|
-
args = arguments.map{|arg,_| "#{arg.to_s.upcase}" }.join(" -- ")
|
39
|
-
optargs = "#{opts} #{oper} " + (args.empty? ? "" : "-- #{args}")
|
40
|
-
"alf #{operator.rubycase_name} #{optargs.strip}".strip
|
41
|
-
end
|
42
|
-
|
43
|
-
end # class Signature
|
44
|
-
end # module Algebra
|
45
|
-
end # module Alf
|