alf 0.12.2 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +186 -80
- data/Gemfile +16 -32
- data/Gemfile.lock +35 -34
- data/LICENCE.md +1 -1
- data/Manifest.txt +7 -9
- data/README.md +139 -809
- data/alf.gemspec +6 -15
- data/alf.noespec +16 -34
- data/lib/alf.rb +3 -73
- data/lib/alf/loader.rb +3 -3
- data/lib/alf/version.rb +2 -2
- data/spec/spec_helper.rb +3 -18
- data/spec/test_alf.rb +8 -0
- data/tasks/test.rake +6 -0
- data/test/migrations/test_folder_migration.rb +18 -0
- data/test/migrations/test_sequel_migration.rb +34 -0
- data/test/seeding/test_seeding.rb +49 -0
- data/test/test_alf.rb +8 -0
- data/test/test_helpers.rb +24 -0
- metadata +54 -952
- data/TODO.md +0 -21
- data/bin/alf +0 -27
- 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 -19
- 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/relational/extend.md +0 -18
- data/doc/operators/relational/group.md +0 -27
- data/doc/operators/relational/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/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/examples/csv/suppliers.csv +0 -6
- data/examples/logs/access.log +0 -1000
- data/examples/logs/combined.alf +0 -2
- data/examples/logs/hits.alf +0 -14
- data/examples/logs/not_found.alf +0 -7
- data/examples/logs/robots-cheating.alf +0 -11
- data/examples/logs/robots.alf +0 -8
- data/examples/operators/autonum.alf +0 -6
- data/examples/operators/cities.rash +0 -4
- data/examples/operators/clip.alf +0 -3
- data/examples/operators/compact.alf +0 -2
- data/examples/operators/database.alf +0 -5
- data/examples/operators/defaults.alf +0 -3
- data/examples/operators/extend.alf +0 -3
- data/examples/operators/group.alf +0 -3
- data/examples/operators/intersect.alf +0 -4
- data/examples/operators/join.alf +0 -2
- data/examples/operators/matching.alf +0 -2
- data/examples/operators/minus.alf +0 -8
- data/examples/operators/not_matching.alf +0 -2
- data/examples/operators/nulls.rash +0 -3
- data/examples/operators/parts.rash +0 -6
- data/examples/operators/project.alf +0 -3
- data/examples/operators/pseudo-with.alf +0 -7
- data/examples/operators/quota.alf +0 -4
- data/examples/operators/rank.alf +0 -4
- data/examples/operators/rename.alf +0 -3
- data/examples/operators/restrict.alf +0 -2
- data/examples/operators/schema.yaml +0 -28
- data/examples/operators/sort.alf +0 -4
- data/examples/operators/summarize.alf +0 -16
- data/examples/operators/suppliers.rash +0 -5
- data/examples/operators/supplies.rash +0 -12
- data/examples/operators/ungroup.alf +0 -4
- data/examples/operators/union.alf +0 -3
- data/examples/operators/unwrap.alf +0 -4
- data/examples/operators/wrap.alf +0 -2
- data/lib/alf-csv/alf/csv.rb +0 -3
- data/lib/alf-csv/alf/csv/commons.rb +0 -36
- data/lib/alf-csv/alf/csv/reader.rb +0 -33
- data/lib/alf-csv/alf/csv/renderer.rb +0 -38
- data/lib/alf-engine/alf/engine.rb +0 -25
- data/lib/alf-engine/alf/engine/aggregate.rb +0 -44
- data/lib/alf-engine/alf/engine/autonum.rb +0 -45
- data/lib/alf-engine/alf/engine/cesure.rb +0 -45
- data/lib/alf-engine/alf/engine/clip.rb +0 -53
- data/lib/alf-engine/alf/engine/coerce.rb +0 -46
- data/lib/alf-engine/alf/engine/cog.rb +0 -7
- data/lib/alf-engine/alf/engine/compact.rb +0 -26
- data/lib/alf-engine/alf/engine/compact/set.rb +0 -23
- data/lib/alf-engine/alf/engine/compact/uniq.rb +0 -23
- data/lib/alf-engine/alf/engine/concat.rb +0 -25
- data/lib/alf-engine/alf/engine/defaults.rb +0 -43
- data/lib/alf-engine/alf/engine/filter.rb +0 -41
- data/lib/alf-engine/alf/engine/generator.rb +0 -50
- data/lib/alf-engine/alf/engine/group.rb +0 -7
- data/lib/alf-engine/alf/engine/group/hash.rb +0 -40
- data/lib/alf-engine/alf/engine/join.rb +0 -7
- data/lib/alf-engine/alf/engine/join/hash.rb +0 -35
- data/lib/alf-engine/alf/engine/materialize.rb +0 -8
- data/lib/alf-engine/alf/engine/materialize/array.rb +0 -78
- data/lib/alf-engine/alf/engine/materialize/hash.rb +0 -122
- data/lib/alf-engine/alf/engine/quota.rb +0 -7
- data/lib/alf-engine/alf/engine/quota/cesure.rb +0 -46
- data/lib/alf-engine/alf/engine/rank.rb +0 -7
- data/lib/alf-engine/alf/engine/rank/cesure.rb +0 -48
- data/lib/alf-engine/alf/engine/rename.rb +0 -39
- data/lib/alf-engine/alf/engine/semi.rb +0 -7
- data/lib/alf-engine/alf/engine/semi/hash.rb +0 -39
- data/lib/alf-engine/alf/engine/set_attr.rb +0 -46
- data/lib/alf-engine/alf/engine/sort.rb +0 -28
- data/lib/alf-engine/alf/engine/sort/in_memory.rb +0 -39
- data/lib/alf-engine/alf/engine/summarize.rb +0 -8
- data/lib/alf-engine/alf/engine/summarize/cesure.rb +0 -51
- data/lib/alf-engine/alf/engine/summarize/hash.rb +0 -35
- data/lib/alf-engine/alf/engine/ungroup.rb +0 -29
- data/lib/alf-engine/alf/engine/unwrap.rb +0 -31
- data/lib/alf-engine/alf/engine/wrap.rb +0 -39
- data/lib/alf-logs/alf/logs.rb +0 -1
- data/lib/alf-logs/alf/logs/reader.rb +0 -98
- data/lib/alf-sequel/alf/sequel.rb +0 -2
- data/lib/alf-sequel/alf/sequel/environment.rb +0 -61
- data/lib/alf-sequel/alf/sequel/iterator.rb +0 -21
- data/lib/alf-shell/alf/shell.rb +0 -40
- data/lib/alf-shell/alf/shell/command.rb +0 -26
- data/lib/alf-shell/alf/shell/command/exec.rb +0 -11
- data/lib/alf-shell/alf/shell/command/help.rb +0 -30
- data/lib/alf-shell/alf/shell/command/main.rb +0 -136
- data/lib/alf-shell/alf/shell/command/main/class_methods.rb +0 -46
- data/lib/alf-shell/alf/shell/command/show.rb +0 -63
- data/lib/alf-shell/alf/shell/doc_manager.rb +0 -72
- data/lib/alf-shell/alf/shell/operator.rb +0 -86
- data/lib/alf-yaml/alf/yaml.rb +0 -1
- data/lib/alf-yaml/alf/yaml/renderer.rb +0 -22
- data/lib/alf/aggregator.rb +0 -51
- data/lib/alf/aggregator/avg.rb +0 -39
- data/lib/alf/aggregator/class_methods.rb +0 -77
- data/lib/alf/aggregator/collect.rb +0 -32
- data/lib/alf/aggregator/concat.rb +0 -47
- data/lib/alf/aggregator/count.rb +0 -32
- data/lib/alf/aggregator/instance_methods.rb +0 -119
- data/lib/alf/aggregator/max.rb +0 -32
- data/lib/alf/aggregator/min.rb +0 -32
- data/lib/alf/aggregator/stddev.rb +0 -25
- data/lib/alf/aggregator/sum.rb +0 -32
- data/lib/alf/aggregator/variance.rb +0 -45
- data/lib/alf/environment.rb +0 -34
- data/lib/alf/environment/class_methods.rb +0 -95
- data/lib/alf/environment/folder.rb +0 -60
- data/lib/alf/environment/instance_methods.rb +0 -26
- data/lib/alf/errors.rb +0 -5
- data/lib/alf/ext.rb +0 -4
- data/lib/alf/ext/relation.rb +0 -4
- data/lib/alf/iterator.rb +0 -28
- data/lib/alf/iterator/class_methods.rb +0 -20
- data/lib/alf/iterator/proxy.rb +0 -27
- data/lib/alf/lispy.rb +0 -24
- data/lib/alf/lispy/instance_methods.rb +0 -157
- data/lib/alf/operator.rb +0 -68
- data/lib/alf/operator/binary.rb +0 -21
- data/lib/alf/operator/class_methods.rb +0 -82
- data/lib/alf/operator/experimental.rb +0 -9
- data/lib/alf/operator/instance_methods.rb +0 -29
- data/lib/alf/operator/non_relational/autonum.rb +0 -19
- data/lib/alf/operator/non_relational/clip.rb +0 -20
- data/lib/alf/operator/non_relational/coerce.rb +0 -19
- data/lib/alf/operator/non_relational/compact.rb +0 -18
- data/lib/alf/operator/non_relational/defaults.rb +0 -22
- data/lib/alf/operator/non_relational/generator.rb +0 -20
- data/lib/alf/operator/non_relational/sort.rb +0 -19
- data/lib/alf/operator/nullary.rb +0 -11
- data/lib/alf/operator/relational/extend.rb +0 -19
- data/lib/alf/operator/relational/group.rb +0 -21
- data/lib/alf/operator/relational/heading.rb +0 -20
- data/lib/alf/operator/relational/intersect.rb +0 -18
- data/lib/alf/operator/relational/join.rb +0 -18
- data/lib/alf/operator/relational/matching.rb +0 -18
- data/lib/alf/operator/relational/minus.rb +0 -18
- data/lib/alf/operator/relational/not_matching.rb +0 -18
- data/lib/alf/operator/relational/project.rb +0 -22
- data/lib/alf/operator/relational/quota.rb +0 -23
- data/lib/alf/operator/relational/rank.rb +0 -22
- data/lib/alf/operator/relational/rename.rb +0 -18
- data/lib/alf/operator/relational/restrict.rb +0 -18
- data/lib/alf/operator/relational/summarize.rb +0 -27
- data/lib/alf/operator/relational/ungroup.rb +0 -19
- data/lib/alf/operator/relational/union.rb +0 -20
- data/lib/alf/operator/relational/unwrap.rb +0 -19
- data/lib/alf/operator/relational/wrap.rb +0 -20
- data/lib/alf/operator/signature.rb +0 -233
- data/lib/alf/operator/unary.rb +0 -16
- data/lib/alf/reader.rb +0 -37
- data/lib/alf/reader/alf_file.rb +0 -24
- data/lib/alf/reader/class_methods.rb +0 -91
- data/lib/alf/reader/instance_methods.rb +0 -97
- data/lib/alf/reader/rash.rb +0 -28
- data/lib/alf/relation.rb +0 -28
- data/lib/alf/relation/class_methods.rb +0 -28
- data/lib/alf/relation/instance_methods.rb +0 -119
- data/lib/alf/renderer.rb +0 -32
- data/lib/alf/renderer/class_methods.rb +0 -58
- data/lib/alf/renderer/instance_methods.rb +0 -55
- data/lib/alf/renderer/rash.rb +0 -33
- data/lib/alf/renderer/text.rb +0 -198
- data/lib/alf/tools.rb +0 -15
- data/lib/alf/tools/coerce.rb +0 -25
- data/lib/alf/tools/miscellaneous.rb +0 -111
- data/lib/alf/tools/to_lispy.rb +0 -96
- data/lib/alf/tools/to_relation.rb +0 -54
- data/lib/alf/tools/to_ruby_literal.rb +0 -31
- data/lib/alf/tools/tuple_handle.rb +0 -60
- data/lib/alf/types.rb +0 -49
- data/lib/alf/types/attr_list.rb +0 -160
- data/lib/alf/types/attr_name.rb +0 -66
- data/lib/alf/types/boolean.rb +0 -25
- data/lib/alf/types/heading.rb +0 -135
- data/lib/alf/types/ordering.rb +0 -146
- data/lib/alf/types/renaming.rb +0 -97
- data/lib/alf/types/size.rb +0 -57
- data/lib/alf/types/summarization.rb +0 -138
- data/lib/alf/types/tuple_computation.rb +0 -136
- data/lib/alf/types/tuple_expression.rb +0 -152
- data/lib/alf/types/tuple_predicate.rb +0 -73
- data/spec/integration/__database__/group.alf +0 -3
- data/spec/integration/__database__/parts.rash +0 -6
- data/spec/integration/__database__/suppliers.rash +0 -5
- data/spec/integration/__database__/suppliers_csv.csv +0 -6
- data/spec/integration/__database__/supplies.rash +0 -12
- data/spec/integration/alf/example.rash +0 -1
- data/spec/integration/alf/test_Relation.rb +0 -32
- data/spec/integration/ext/test_relation.rb +0 -16
- data/spec/integration/lispy/test_relation.rb +0 -37
- data/spec/integration/lispy/test_run.rb +0 -40
- data/spec/integration/lispy/test_tuple.rb +0 -36
- data/spec/integration/semantics/test_join.alf +0 -9
- data/spec/integration/semantics/test_minus.alf +0 -5
- data/spec/integration/semantics/test_project.alf +0 -8
- data/spec/integration/semantics/test_rank.alf +0 -34
- data/spec/integration/shell/alf/alf.db +0 -0
- data/spec/integration/shell/alf/alf_e.cmd +0 -1
- data/spec/integration/shell/alf/alf_e.stdout +0 -4
- data/spec/integration/shell/alf/alf_env.cmd +0 -1
- data/spec/integration/shell/alf/alf_env.stdout +0 -5
- data/spec/integration/shell/alf/alf_env_sqlite.cmd +0 -1
- data/spec/integration/shell/alf/alf_env_sqlite.stdout +0 -9
- data/spec/integration/shell/alf/alf_help.cmd +0 -1
- data/spec/integration/shell/alf/alf_help.stdout +0 -69
- data/spec/integration/shell/alf/alf_implicit.alf +0 -1
- data/spec/integration/shell/alf/alf_implicit_exec.cmd +0 -1
- data/spec/integration/shell/alf/alf_implicit_exec.stdout +0 -4
- data/spec/integration/shell/alf/alf_r.cmd +0 -1
- data/spec/integration/shell/alf/alf_r.stdout +0 -5
- data/spec/integration/shell/alf/alf_version.cmd +0 -1
- data/spec/integration/shell/alf/alf_version.stdout +0 -2
- data/spec/integration/shell/alf/alf_yaml.cmd +0 -1
- data/spec/integration/shell/alf/alf_yaml.stdout +0 -22
- data/spec/integration/shell/alf/rel.rash +0 -1
- data/spec/integration/shell/autonum/autonum_0.cmd +0 -1
- data/spec/integration/shell/autonum/autonum_0.stdout +0 -9
- data/spec/integration/shell/autonum/autonum_1.cmd +0 -1
- data/spec/integration/shell/autonum/autonum_1.stdout +0 -9
- data/spec/integration/shell/clip/clip_0.cmd +0 -1
- data/spec/integration/shell/clip/clip_0.stdout +0 -9
- data/spec/integration/shell/clip/clip_1.cmd +0 -1
- data/spec/integration/shell/clip/clip_1.stdout +0 -9
- data/spec/integration/shell/coerce/coerce_1.cmd +0 -1
- data/spec/integration/shell/coerce/coerce_1.stdout +0 -5
- data/spec/integration/shell/compact/compact_0.cmd +0 -1
- data/spec/integration/shell/compact/compact_0.stdout +0 -9
- data/spec/integration/shell/defaults/defaults_0.cmd +0 -1
- data/spec/integration/shell/defaults/defaults_0.stdout +0 -9
- data/spec/integration/shell/defaults/defaults_1.cmd +0 -1
- data/spec/integration/shell/defaults/defaults_1.stdout +0 -9
- data/spec/integration/shell/defaults/defaults_2.cmd +0 -1
- data/spec/integration/shell/defaults/defaults_2.stdout +0 -9
- data/spec/integration/shell/extend/extend_0.cmd +0 -1
- data/spec/integration/shell/extend/extend_0.stdout +0 -16
- data/spec/integration/shell/generator/generator_1.cmd +0 -1
- data/spec/integration/shell/generator/generator_1.stdout +0 -10
- data/spec/integration/shell/generator/generator_2.cmd +0 -1
- data/spec/integration/shell/generator/generator_2.stdout +0 -5
- data/spec/integration/shell/generator/generator_3.cmd +0 -1
- data/spec/integration/shell/generator/generator_3.stdout +0 -5
- data/spec/integration/shell/group/group_0.cmd +0 -1
- data/spec/integration/shell/group/group_0.stdout +0 -32
- data/spec/integration/shell/group/group_1.cmd +0 -1
- data/spec/integration/shell/group/group_1.stdout +0 -32
- data/spec/integration/shell/help/help_1.cmd +0 -1
- data/spec/integration/shell/help/help_1.stdout +0 -24
- data/spec/integration/shell/intersect/intersect_0.cmd +0 -1
- data/spec/integration/shell/intersect/intersect_0.stdout +0 -9
- data/spec/integration/shell/join/join_0.cmd +0 -1
- data/spec/integration/shell/join/join_0.stdout +0 -16
- data/spec/integration/shell/matching/matching_0.cmd +0 -1
- data/spec/integration/shell/matching/matching_0.stdout +0 -8
- data/spec/integration/shell/minus/minus_0.cmd +0 -1
- data/spec/integration/shell/minus/minus_0.stdout +0 -4
- data/spec/integration/shell/not-matching/not-matching_0.cmd +0 -1
- data/spec/integration/shell/not-matching/not-matching_0.stdout +0 -5
- data/spec/integration/shell/project/project_0.cmd +0 -1
- data/spec/integration/shell/project/project_0.stdout +0 -9
- data/spec/integration/shell/project/project_1.cmd +0 -1
- data/spec/integration/shell/project/project_1.stdout +0 -9
- data/spec/integration/shell/quota/quota_0.cmd +0 -1
- data/spec/integration/shell/quota/quota_0.stdout +0 -16
- data/spec/integration/shell/rank/rank_1.cmd +0 -1
- data/spec/integration/shell/rank/rank_1.stdout +0 -10
- data/spec/integration/shell/rank/rank_2.cmd +0 -1
- data/spec/integration/shell/rank/rank_2.stdout +0 -10
- data/spec/integration/shell/rank/rank_3.cmd +0 -1
- data/spec/integration/shell/rank/rank_3.stdout +0 -10
- data/spec/integration/shell/rank/rank_4.cmd +0 -1
- data/spec/integration/shell/rank/rank_4.stdout +0 -6
- data/spec/integration/shell/rank/rank_5.cmd +0 -1
- data/spec/integration/shell/rank/rank_5.stdout +0 -6
- data/spec/integration/shell/rename/rename_0.cmd +0 -1
- data/spec/integration/shell/rename/rename_0.stdout +0 -9
- data/spec/integration/shell/restrict/restrict_0.cmd +0 -1
- data/spec/integration/shell/restrict/restrict_0.stdout +0 -6
- data/spec/integration/shell/restrict/restrict_1.cmd +0 -1
- data/spec/integration/shell/restrict/restrict_1.stdout +0 -6
- data/spec/integration/shell/show/show_base.cmd +0 -1
- data/spec/integration/shell/show/show_base.stdout +0 -9
- data/spec/integration/shell/show/show_base_sort_1.cmd +0 -1
- data/spec/integration/shell/show/show_base_sort_1.stdout +0 -9
- data/spec/integration/shell/show/show_base_sort_2.cmd +0 -1
- data/spec/integration/shell/show/show_base_sort_2.stdout +0 -9
- data/spec/integration/shell/show/show_conflictual.cmd +0 -1
- data/spec/integration/shell/show/show_conflictual.stdout +0 -5
- data/spec/integration/shell/show/show_csv.cmd +0 -1
- data/spec/integration/shell/show/show_csv.stdout +0 -6
- data/spec/integration/shell/show/show_ff.cmd +0 -1
- data/spec/integration/shell/show/show_ff.stdout +0 -10
- data/spec/integration/shell/show/show_rash.cmd +0 -1
- data/spec/integration/shell/show/show_rash.stdout +0 -5
- data/spec/integration/shell/show/show_rash_pretty.cmd +0 -1
- data/spec/integration/shell/show/show_rash_pretty.stdout +0 -30
- data/spec/integration/shell/show/show_yaml.cmd +0 -1
- data/spec/integration/shell/show/show_yaml.stdout +0 -22
- data/spec/integration/shell/sort/sort_0.cmd +0 -1
- data/spec/integration/shell/sort/sort_0.stdout +0 -9
- data/spec/integration/shell/sort/sort_1.cmd +0 -1
- data/spec/integration/shell/sort/sort_1.stdout +0 -9
- data/spec/integration/shell/sort/sort_2.cmd +0 -1
- data/spec/integration/shell/sort/sort_2.stdout +0 -9
- data/spec/integration/shell/sort/sort_3.cmd +0 -1
- data/spec/integration/shell/sort/sort_3.stdout +0 -9
- data/spec/integration/shell/summarize/summarize_0.cmd +0 -1
- data/spec/integration/shell/summarize/summarize_0.stdout +0 -8
- data/spec/integration/shell/ungroup/ungroup_0.cmd +0 -1
- data/spec/integration/shell/ungroup/ungroup_0.stdout +0 -16
- data/spec/integration/shell/union/union_0.cmd +0 -1
- data/spec/integration/shell/union/union_0.stdout +0 -9
- data/spec/integration/shell/unwrap/unwrap_0.cmd +0 -1
- data/spec/integration/shell/unwrap/unwrap_0.stdout +0 -9
- data/spec/integration/shell/wrap/wrap_0.cmd +0 -1
- data/spec/integration/shell/wrap/wrap_0.stdout +0 -9
- data/spec/integration/test_alf.rb +0 -34
- data/spec/integration/test_examples.rb +0 -15
- data/spec/integration/test_lispy.rb +0 -31
- data/spec/integration/test_semantics.rb +0 -40
- data/spec/integration/test_shell.rb +0 -47
- data/spec/regression/alf_file/__FILE__.alf +0 -2
- data/spec/regression/alf_file/suppliers.rash +0 -5
- data/spec/regression/alf_file/test___FILE__.rb +0 -17
- data/spec/regression/heading/test_heading_with_date.rb +0 -12
- data/spec/regression/lispy/test_compile.rb +0 -14
- data/spec/regression/logs/apache_combined.log +0 -5
- data/spec/regression/logs/test_path_attribute.rb +0 -25
- data/spec/regression/relation/test_relation_allbut_all.rb +0 -14
- data/spec/regression/relation/test_relation_with_date.rb +0 -12
- data/spec/regression/restrict/test_restrict_with_keywords.rb +0 -17
- data/spec/shared/a_valid_type_implementation.rb +0 -47
- data/spec/shared/a_value.rb +0 -12
- data/spec/shared/an_operator_class.rb +0 -36
- data/spec/unit/alf-core/aggregator/test_avg.rb +0 -22
- data/spec/unit/alf-core/aggregator/test_collect.rb +0 -25
- data/spec/unit/alf-core/aggregator/test_concat.rb +0 -31
- data/spec/unit/alf-core/aggregator/test_count.rb +0 -17
- data/spec/unit/alf-core/aggregator/test_max.rb +0 -23
- data/spec/unit/alf-core/aggregator/test_min.rb +0 -23
- data/spec/unit/alf-core/aggregator/test_stddev.rb +0 -27
- data/spec/unit/alf-core/aggregator/test_sum.rb +0 -23
- data/spec/unit/alf-core/aggregator/test_variance.rb +0 -29
- data/spec/unit/alf-core/assumptions/test_file.rb +0 -17
- data/spec/unit/alf-core/assumptions/test_instance_eval.rb +0 -15
- data/spec/unit/alf-core/assumptions/test_scoping.rb +0 -29
- data/spec/unit/alf-core/assumptions/test_set.rb +0 -64
- data/spec/unit/alf-core/environment/examples/suppliers.rash +0 -5
- data/spec/unit/alf-core/environment/test_folder.rb +0 -53
- data/spec/unit/alf-core/operator/non_relational/test_autonum.rb +0 -48
- data/spec/unit/alf-core/operator/non_relational/test_clip.rb +0 -35
- data/spec/unit/alf-core/operator/non_relational/test_coerce.rb +0 -29
- data/spec/unit/alf-core/operator/non_relational/test_compact.rb +0 -32
- data/spec/unit/alf-core/operator/non_relational/test_defaults.rb +0 -53
- data/spec/unit/alf-core/operator/non_relational/test_generator.rb +0 -60
- data/spec/unit/alf-core/operator/non_relational/test_sort.rb +0 -60
- data/spec/unit/alf-core/operator/relational/test_extend.rb +0 -28
- data/spec/unit/alf-core/operator/relational/test_group.rb +0 -39
- data/spec/unit/alf-core/operator/relational/test_heading.rb +0 -27
- data/spec/unit/alf-core/operator/relational/test_intersect.rb +0 -58
- data/spec/unit/alf-core/operator/relational/test_join.rb +0 -36
- data/spec/unit/alf-core/operator/relational/test_minus.rb +0 -56
- data/spec/unit/alf-core/operator/relational/test_project.rb +0 -62
- data/spec/unit/alf-core/operator/relational/test_quota.rb +0 -36
- data/spec/unit/alf-core/operator/relational/test_rank.rb +0 -48
- data/spec/unit/alf-core/operator/relational/test_rename.rb +0 -26
- data/spec/unit/alf-core/operator/relational/test_restrict.rb +0 -45
- data/spec/unit/alf-core/operator/relational/test_summarize.rb +0 -44
- data/spec/unit/alf-core/operator/relational/test_ungroup.rb +0 -29
- data/spec/unit/alf-core/operator/relational/test_union.rb +0 -35
- data/spec/unit/alf-core/operator/relational/test_unwrap.rb +0 -26
- data/spec/unit/alf-core/operator/relational/test_wrap.rb +0 -26
- data/spec/unit/alf-core/operator/signature/test_argv2args.rb +0 -82
- data/spec/unit/alf-core/operator/signature/test_collect_on.rb +0 -38
- data/spec/unit/alf-core/operator/signature/test_initialize.rb +0 -17
- data/spec/unit/alf-core/operator/signature/test_install.rb +0 -56
- data/spec/unit/alf-core/operator/signature/test_option_parser.rb +0 -36
- data/spec/unit/alf-core/operator/signature/test_parse_args.rb +0 -90
- data/spec/unit/alf-core/operator/signature/test_to_lispy.rb +0 -102
- data/spec/unit/alf-core/operator/signature/test_to_shell.rb +0 -103
- data/spec/unit/alf-core/operator/test_non_relational.rb +0 -20
- data/spec/unit/alf-core/operator/test_relational.rb +0 -31
- data/spec/unit/alf-core/reader/input.rb +0 -2
- data/spec/unit/alf-core/reader/test_alf_file.rb +0 -30
- data/spec/unit/alf-core/reader/test_initialize.rb +0 -60
- data/spec/unit/alf-core/reader/test_looks_a_path.rb +0 -20
- data/spec/unit/alf-core/reader/test_rash.rb +0 -31
- data/spec/unit/alf-core/relation/test_coerce.rb +0 -53
- data/spec/unit/alf-core/relation/test_inspect.rb +0 -20
- data/spec/unit/alf-core/relation/test_relops.rb +0 -55
- data/spec/unit/alf-core/relation/test_to_a.rb +0 -41
- data/spec/unit/alf-core/renderer/test_initialize.rb +0 -60
- data/spec/unit/alf-core/test_aggregator.rb +0 -58
- data/spec/unit/alf-core/test_environment.rb +0 -30
- data/spec/unit/alf-core/test_operator.rb +0 -16
- data/spec/unit/alf-core/test_reader.rb +0 -40
- data/spec/unit/alf-core/test_relation.rb +0 -75
- data/spec/unit/alf-core/test_renderer.rb +0 -53
- data/spec/unit/alf-core/text/test_cell.rb +0 -35
- data/spec/unit/alf-core/text/test_row.rb +0 -30
- data/spec/unit/alf-core/text/test_table.rb +0 -39
- data/spec/unit/alf-core/tools/test_class_name.rb +0 -16
- data/spec/unit/alf-core/tools/test_coalesce.rb +0 -19
- data/spec/unit/alf-core/tools/test_coerce.rb +0 -16
- data/spec/unit/alf-core/tools/test_ruby_case.rb +0 -16
- data/spec/unit/alf-core/tools/test_to_lispy.rb +0 -145
- data/spec/unit/alf-core/tools/test_to_relation.rb +0 -39
- data/spec/unit/alf-core/tools/test_to_ruby_literal.rb +0 -10
- data/spec/unit/alf-core/tools/test_tuple_handle.rb +0 -52
- data/spec/unit/alf-core/tools/test_tuple_heading.rb +0 -15
- data/spec/unit/alf-core/tools/test_varargs.rb +0 -19
- data/spec/unit/alf-core/types/test_attr_list.rb +0 -188
- data/spec/unit/alf-core/types/test_attr_name.rb +0 -78
- data/spec/unit/alf-core/types/test_boolean.rb +0 -42
- data/spec/unit/alf-core/types/test_class_methods.rb +0 -24
- data/spec/unit/alf-core/types/test_heading.rb +0 -146
- data/spec/unit/alf-core/types/test_ordering.rb +0 -185
- data/spec/unit/alf-core/types/test_renaming.rb +0 -72
- data/spec/unit/alf-core/types/test_size.rb +0 -74
- data/spec/unit/alf-core/types/test_summarization.rb +0 -95
- data/spec/unit/alf-core/types/test_tuple_computation.rb +0 -96
- data/spec/unit/alf-core/types/test_tuple_expression.rb +0 -122
- data/spec/unit/alf-core/types/test_tuple_predicate.rb +0 -108
- data/spec/unit/alf-csv/input.csv +0 -3
- data/spec/unit/alf-csv/test_reader.rb +0 -66
- data/spec/unit/alf-csv/test_renderer.rb +0 -73
- data/spec/unit/alf-engine/compact/test_set.rb +0 -33
- data/spec/unit/alf-engine/compact/test_uniq.rb +0 -33
- data/spec/unit/alf-engine/group/test_hash.rb +0 -34
- data/spec/unit/alf-engine/join/test_hash.rb +0 -55
- data/spec/unit/alf-engine/materialize/test_array.rb +0 -28
- data/spec/unit/alf-engine/materialize/test_hash.rb +0 -76
- data/spec/unit/alf-engine/quota/test_cesure.rb +0 -34
- data/spec/unit/alf-engine/rank/test_cesure.rb +0 -47
- data/spec/unit/alf-engine/semi/test_hash.rb +0 -58
- data/spec/unit/alf-engine/sort/test_in_memory.rb +0 -32
- data/spec/unit/alf-engine/summarize/test_cesure.rb +0 -36
- data/spec/unit/alf-engine/summarize/test_hash.rb +0 -36
- data/spec/unit/alf-engine/test_aggregate.rb +0 -26
- data/spec/unit/alf-engine/test_autonum.rb +0 -24
- data/spec/unit/alf-engine/test_clip.rb +0 -34
- data/spec/unit/alf-engine/test_coerce.rb +0 -35
- data/spec/unit/alf-engine/test_compact.rb +0 -33
- data/spec/unit/alf-engine/test_concat.rb +0 -38
- data/spec/unit/alf-engine/test_defaults.rb +0 -37
- data/spec/unit/alf-engine/test_filter.rb +0 -23
- data/spec/unit/alf-engine/test_generator.rb +0 -25
- data/spec/unit/alf-engine/test_rename.rb +0 -24
- data/spec/unit/alf-engine/test_set_attr.rb +0 -38
- data/spec/unit/alf-engine/test_sort.rb +0 -32
- data/spec/unit/alf-engine/test_ungroup.rb +0 -28
- data/spec/unit/alf-engine/test_unwrap.rb +0 -20
- data/spec/unit/alf-engine/test_wrap.rb +0 -26
- data/spec/unit/alf-logs/apache_combined.log +0 -5
- data/spec/unit/alf-logs/postgresql.log +0 -29
- data/spec/unit/alf-logs/test_reader.rb +0 -57
- data/spec/unit/alf-sequel/alf.db +0 -0
- data/spec/unit/alf-sequel/test_environment.rb +0 -74
- data/spec/unit/alf-shell/doc_manager/dynamic.md +0 -1
- data/spec/unit/alf-shell/doc_manager/example.md +0 -1
- data/spec/unit/alf-shell/doc_manager/example_1.txt +0 -11
- data/spec/unit/alf-shell/doc_manager/static.md +0 -1
- data/spec/unit/alf-shell/doc_manager/test_call.rb +0 -48
- data/spec/unit/alf-shell/main/test_class_methods.rb +0 -44
- data/spec/unit/alf-shell/operator/test_autonum.rb +0 -28
- data/spec/unit/alf-shell/operator/test_clip.rb +0 -29
- data/spec/unit/alf-shell/operator/test_coerce.rb +0 -21
- data/spec/unit/alf-shell/operator/test_compact.rb +0 -16
- data/spec/unit/alf-shell/operator/test_defaults.rb +0 -29
- data/spec/unit/alf-shell/operator/test_extend.rb +0 -21
- data/spec/unit/alf-shell/operator/test_generator.rb +0 -37
- data/spec/unit/alf-shell/operator/test_group.rb +0 -32
- data/spec/unit/alf-shell/operator/test_heading.rb +0 -16
- data/spec/unit/alf-shell/operator/test_intersect.rb +0 -18
- data/spec/unit/alf-shell/operator/test_join.rb +0 -18
- data/spec/unit/alf-shell/operator/test_matching.rb +0 -18
- data/spec/unit/alf-shell/operator/test_minus.rb +0 -18
- data/spec/unit/alf-shell/operator/test_not_matching.rb +0 -18
- data/spec/unit/alf-shell/operator/test_project.rb +0 -38
- data/spec/unit/alf-shell/operator/test_quota.rb +0 -23
- data/spec/unit/alf-shell/operator/test_rank.rb +0 -30
- data/spec/unit/alf-shell/operator/test_rename.rb +0 -21
- data/spec/unit/alf-shell/operator/test_restrict.rb +0 -35
- data/spec/unit/alf-shell/operator/test_sort.rb +0 -49
- data/spec/unit/alf-shell/operator/test_summarize.rb +0 -30
- data/spec/unit/alf-shell/operator/test_ungroup.rb +0 -28
- data/spec/unit/alf-shell/operator/test_union.rb +0 -18
- data/spec/unit/alf-shell/operator/test_unwrap.rb +0 -28
- data/spec/unit/alf-shell/operator/test_wrap.rb +0 -30
- data/tasks/clean.rake +0 -3
- data/tasks/debug_mail.rake +0 -75
- data/tasks/debug_mail.txt +0 -18
- data/tasks/gh-pages.rake +0 -68
- data/tasks/integration_test.rake +0 -43
- data/tasks/regression_test.rake +0 -44
- data/tasks/unit_test.rake +0 -44
- data/tasks/yard.rake +0 -51
@@ -1,18 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Operator
|
3
|
-
module Relational
|
4
|
-
class Restrict
|
5
|
-
include Relational, Unary
|
6
|
-
|
7
|
-
signature do |s|
|
8
|
-
s.argument :predicate, TuplePredicate, "true"
|
9
|
-
end
|
10
|
-
|
11
|
-
def compile
|
12
|
-
Engine::Filter.new(operand, predicate)
|
13
|
-
end
|
14
|
-
|
15
|
-
end # class Restrict
|
16
|
-
end # module Relational
|
17
|
-
end # module Operator
|
18
|
-
end # module Alf
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Operator
|
3
|
-
module Relational
|
4
|
-
class Summarize
|
5
|
-
include Relational, Unary
|
6
|
-
|
7
|
-
signature do |s|
|
8
|
-
s.argument :by, AttrList, []
|
9
|
-
s.argument :summarization, Summarization, {}
|
10
|
-
s.option :allbut, Boolean, false, "Summarize on all but specified attributes?"
|
11
|
-
end
|
12
|
-
|
13
|
-
# (see Operator#compile)
|
14
|
-
def compile
|
15
|
-
if @allbut
|
16
|
-
Engine::Summarize::Hash.new(operand, by, summarization, allbut)
|
17
|
-
else
|
18
|
-
op = Engine::Sort.new(operand, by.to_ordering)
|
19
|
-
op = Engine::Summarize::Cesure.new(op, by, summarization, allbut)
|
20
|
-
op
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end # class Summarize
|
25
|
-
end # module Relational
|
26
|
-
end # module Operator
|
27
|
-
end # module Alf
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Operator
|
3
|
-
module Relational
|
4
|
-
class Ungroup
|
5
|
-
include Relational, Unary
|
6
|
-
|
7
|
-
signature do |s|
|
8
|
-
s.argument :attribute, AttrName, :grouped
|
9
|
-
end
|
10
|
-
|
11
|
-
# (see Operator#compile)
|
12
|
-
def compile
|
13
|
-
Engine::Ungroup.new(operand, attribute)
|
14
|
-
end
|
15
|
-
|
16
|
-
end # class Ungroup
|
17
|
-
end # module Relational
|
18
|
-
end # module Operator
|
19
|
-
end # module Alf
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Operator
|
3
|
-
module Relational
|
4
|
-
class Union
|
5
|
-
include Relational, Binary
|
6
|
-
|
7
|
-
signature do |s|
|
8
|
-
end
|
9
|
-
|
10
|
-
# (see Operator#compile)
|
11
|
-
def compile
|
12
|
-
op = Engine::Concat.new([left, right])
|
13
|
-
op = Engine::Compact.new(op)
|
14
|
-
op
|
15
|
-
end
|
16
|
-
|
17
|
-
end # class Union
|
18
|
-
end # module Relational
|
19
|
-
end # module Operator
|
20
|
-
end # module Alf
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Operator
|
3
|
-
module Relational
|
4
|
-
class Unwrap
|
5
|
-
include Relational, Unary
|
6
|
-
|
7
|
-
signature do |s|
|
8
|
-
s.argument :attribute, AttrName, :wrapped
|
9
|
-
end
|
10
|
-
|
11
|
-
# (see Operator#compile)
|
12
|
-
def compile
|
13
|
-
Engine::Unwrap.new(operand, attribute)
|
14
|
-
end
|
15
|
-
|
16
|
-
end # class Unwrap
|
17
|
-
end # module Relational
|
18
|
-
end # module Operator
|
19
|
-
end # module Alf
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Operator
|
3
|
-
module Relational
|
4
|
-
class Wrap
|
5
|
-
include Relational, Unary
|
6
|
-
|
7
|
-
signature do |s|
|
8
|
-
s.argument :attributes, AttrList, []
|
9
|
-
s.argument :as, AttrName, :wrapped
|
10
|
-
end
|
11
|
-
|
12
|
-
# (see Operator#compile)
|
13
|
-
def compile
|
14
|
-
Engine::Wrap.new(operand, attributes, as, false)
|
15
|
-
end
|
16
|
-
|
17
|
-
end # class Wrap
|
18
|
-
end # module Relational
|
19
|
-
end # module Operator
|
20
|
-
end # module Alf
|
@@ -1,233 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Operator
|
3
|
-
# Provides an operator signature
|
4
|
-
class Signature
|
5
|
-
|
6
|
-
# @return [Class] the operator class to which this signature belongs
|
7
|
-
attr_reader :operator
|
8
|
-
|
9
|
-
# @return [Array] signature arguments
|
10
|
-
attr_reader :arguments
|
11
|
-
|
12
|
-
# @return [Array] signature options
|
13
|
-
attr_reader :options
|
14
|
-
|
15
|
-
# Creates an empty signature instance
|
16
|
-
#
|
17
|
-
# @param [Class] the operator class to which this signature belongs
|
18
|
-
def initialize(operator)
|
19
|
-
@operator = operator
|
20
|
-
@arguments = []
|
21
|
-
@options = []
|
22
|
-
yield(self) if block_given?
|
23
|
-
end
|
24
|
-
|
25
|
-
# Adds an argument to the signature
|
26
|
-
#
|
27
|
-
# @param [Symbol] name argument name
|
28
|
-
# @param [Class] domain argument domain
|
29
|
-
# @param [Object] default (optional) default value
|
30
|
-
def argument(name, domain, default = nil, descr = nil)
|
31
|
-
arguments << [name, domain, default, descr]
|
32
|
-
end
|
33
|
-
|
34
|
-
# Adds an option to the signature
|
35
|
-
#
|
36
|
-
# @param [Symbol] name argument name
|
37
|
-
# @param [Class] domain argument domain
|
38
|
-
# @param [Object] default (optional) default value
|
39
|
-
def option(name, domain, default = nil, descr = nil)
|
40
|
-
options << [name, domain, default, descr]
|
41
|
-
end
|
42
|
-
|
43
|
-
# Builds an option parser instance `opt` prepared for installing options on
|
44
|
-
# `receiver`.
|
45
|
-
#
|
46
|
-
# @param [Hash|Operator] a receiver for option values
|
47
|
-
# @param [OptionParser] opt the parser to fill with options
|
48
|
-
# @return [OptionParser] `opt`
|
49
|
-
def option_parser(receiver, opt = OptionParser.new)
|
50
|
-
options.each do |option|
|
51
|
-
name, dom, defa, descr = option
|
52
|
-
opt.on(option_name(option), descr || "") do |val|
|
53
|
-
if receiver.is_a?(Hash)
|
54
|
-
receiver[name] = val
|
55
|
-
else
|
56
|
-
receiver.send(:"#{name}=", val)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
opt
|
61
|
-
end
|
62
|
-
|
63
|
-
# Installs the signature on the operator class
|
64
|
-
#
|
65
|
-
# This method installs an attr reader and an attr writer for each
|
66
|
-
# signature argument and each signature option.
|
67
|
-
#
|
68
|
-
# @return [Hash] the default options to use
|
69
|
-
def install
|
70
|
-
clazz = operator
|
71
|
-
code = (arguments + options).each{|siginfo|
|
72
|
-
name, domain, = siginfo
|
73
|
-
clazz.send(:attr_reader, name)
|
74
|
-
clazz.send(:define_method, :"#{name}=") do |val|
|
75
|
-
instance_variable_set(:"@#{name}", Tools.coerce(val, domain))
|
76
|
-
end
|
77
|
-
clazz.send(:private, :"#{name}=")
|
78
|
-
}
|
79
|
-
default_options
|
80
|
-
end
|
81
|
-
|
82
|
-
# Parses arguments `args` passed to the operator `initialize` and
|
83
|
-
# sets attributes accordingly on `receiver`.
|
84
|
-
#
|
85
|
-
# @param [Array] args an array of initialize arguments
|
86
|
-
# @param [Operator] receiver an operator instance
|
87
|
-
# @return [Operator] installed `receiver`
|
88
|
-
def parse_args(args, receiver)
|
89
|
-
|
90
|
-
# 1) Check and set operands, passed as an array as first argument
|
91
|
-
invalid_args!(args) unless args.first.is_a?(Array)
|
92
|
-
receiver.operands = args.shift
|
93
|
-
|
94
|
-
# 2) Extract options if provided
|
95
|
-
optargs = default_options
|
96
|
-
if args.size == (1+arguments.size)
|
97
|
-
# options are passed as last argument
|
98
|
-
invalid_args!(args) unless args.last.is_a?(Hash)
|
99
|
-
optargs = optargs.merge(args.pop)
|
100
|
-
elsif args.size > arguments.size
|
101
|
-
# too many arguments here
|
102
|
-
invalid_args!(args)
|
103
|
-
end
|
104
|
-
|
105
|
-
# 3) Set options now, including default ones
|
106
|
-
optargs.each_pair do |name,val|
|
107
|
-
receiver.send(:"#{name}=", val)
|
108
|
-
end
|
109
|
-
|
110
|
-
# 4) Parse other arguments now
|
111
|
-
with_each_arg(args) do |name,dom,value|
|
112
|
-
invalid_args!(args) if value.nil?
|
113
|
-
receiver.send(:"#{name}=", value)
|
114
|
-
end
|
115
|
-
|
116
|
-
receiver
|
117
|
-
end
|
118
|
-
|
119
|
-
# Converts commandline arguments to operator constructor arguments
|
120
|
-
def argv2args(argv)
|
121
|
-
# First split over --
|
122
|
-
argv = Quickl.split_commandline_args(argv)
|
123
|
-
|
124
|
-
# Parse the options and replace argv[0] by remaining arguments
|
125
|
-
opts = {}
|
126
|
-
argv[0] = option_parser(opts).parse!(argv[0])
|
127
|
-
opts = default_options.merge(opts)
|
128
|
-
|
129
|
-
# Operands are argv[0], and can be removed
|
130
|
-
oper = argv.shift
|
131
|
-
|
132
|
-
# Coerce each remaining argument according to the signature
|
133
|
-
args = []
|
134
|
-
with_each_arg(argv) do |name,dom,value|
|
135
|
-
invalid_args!(args) if value.nil?
|
136
|
-
args << dom.from_argv(Array(value))
|
137
|
-
end
|
138
|
-
|
139
|
-
[oper, args, opts]
|
140
|
-
end
|
141
|
-
|
142
|
-
# Collects signature values on a given operator.
|
143
|
-
#
|
144
|
-
# This methods returns a triple `[datasets, arguments, options]` with
|
145
|
-
# the respective values collected on `op`.
|
146
|
-
#
|
147
|
-
# @param [Operator] op an operator, which should be an instance of
|
148
|
-
# `self.operator`
|
149
|
-
# @return [Array] a triple [datasets, arguments, options] with operands,
|
150
|
-
# then signature values
|
151
|
-
def collect_on(op)
|
152
|
-
oper = op.operands
|
153
|
-
args = arguments.map{|name,_| op.send(name) }
|
154
|
-
opts = Hash[options.map{|name,dom,defa,_|
|
155
|
-
val = op.send(name)
|
156
|
-
(val == defa) ? nil : [name, val]
|
157
|
-
}.compact]
|
158
|
-
[oper, args, opts]
|
159
|
-
end
|
160
|
-
|
161
|
-
# Returns a lispy synopsis for this signature
|
162
|
-
#
|
163
|
-
# Example:
|
164
|
-
#
|
165
|
-
# Alf::Operator::Relational::Project.signature.to_shell
|
166
|
-
# # => "(project operand, attributes:AttrList, {allbut: Boolean})"
|
167
|
-
def to_lispy
|
168
|
-
cmd = operator.rubycase_name
|
169
|
-
oper = operator.nullary? ? "" :
|
170
|
-
(operator.unary? ? "operand" : "left, right")
|
171
|
-
|
172
|
-
args = arguments.collect{|name,dom,_|
|
173
|
-
dom.to_s =~ /::([A-Za-z]+)$/
|
174
|
-
"#{name}:#{$1}"
|
175
|
-
}.join(", ")
|
176
|
-
args = (args.empty? ? "#{oper}" : "#{oper}, #{args}").strip
|
177
|
-
|
178
|
-
opts = options.collect{|name,dom,_|
|
179
|
-
dom.to_s =~ /::([A-Za-z]+)$/
|
180
|
-
"#{name}: #{$1}"
|
181
|
-
}.join(', ')
|
182
|
-
opts = opts.empty? ? "" : "{#{opts}}"
|
183
|
-
|
184
|
-
argopt = [args, opts].select{|s| !s.empty?}.join(', ')
|
185
|
-
"(#{cmd} #{argopt}".strip + ")"
|
186
|
-
end
|
187
|
-
|
188
|
-
# Returns a shell synopsis for this signature.
|
189
|
-
#
|
190
|
-
# Example:
|
191
|
-
#
|
192
|
-
# Alf::Operator::Relational::Project.signature.to_shell
|
193
|
-
# # => "alf project [--allbut] [OPERAND] -- ATTRIBUTES"
|
194
|
-
def to_shell
|
195
|
-
oper = operator.nullary? ? "" :
|
196
|
-
(operator.unary? ? "[OPERAND]" : "[LEFT] RIGHT")
|
197
|
-
opts = options.collect{|opt| "[#{option_name(opt)}]" }.join(" ")
|
198
|
-
args = arguments.collect{|arg,_| "#{arg.to_s.upcase}" }.join(" -- ")
|
199
|
-
optargs = "#{opts} #{oper} " + (args.empty? ? "" : "-- #{args}")
|
200
|
-
"alf #{operator.rubycase_name} #{optargs.strip}".strip
|
201
|
-
end
|
202
|
-
|
203
|
-
private
|
204
|
-
|
205
|
-
# @return the default options as a Hash
|
206
|
-
def default_options
|
207
|
-
@default_options ||=
|
208
|
-
Hash[options.select{|opt| !opt[2].nil? }.
|
209
|
-
map{|opt| [opt[0], opt[2]]}]
|
210
|
-
end
|
211
|
-
|
212
|
-
# @return the name to use in shell for `option`
|
213
|
-
def option_name(option)
|
214
|
-
name, domain, defa, = option
|
215
|
-
domain == Boolean ? "--#{name}" : "--#{name}=#{name.to_s.upcase}"
|
216
|
-
end
|
217
|
-
|
218
|
-
# Yields `(name,dom,value)` triples for each argument value
|
219
|
-
def with_each_arg(args)
|
220
|
-
arguments.zip(args).collect do |sigpart,subargs|
|
221
|
-
name, dom, default = sigpart
|
222
|
-
val = Array(subargs).empty? ? default : subargs
|
223
|
-
yield(name, dom, val)
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
def invalid_args!(args, msg = "Invalid `#{args.inspect}` for #{self}")
|
228
|
-
raise ArgumentError, msg, caller
|
229
|
-
end
|
230
|
-
|
231
|
-
end # class Signature
|
232
|
-
end # module Operator
|
233
|
-
end # module Alf
|
data/lib/alf/operator/unary.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Operator
|
3
|
-
#
|
4
|
-
# Specialization of Operator for operators that work on a unary input
|
5
|
-
#
|
6
|
-
module Unary
|
7
|
-
include Operator
|
8
|
-
|
9
|
-
# Simply returns the first operand
|
10
|
-
def operand
|
11
|
-
operands.first
|
12
|
-
end
|
13
|
-
|
14
|
-
end # module Unary
|
15
|
-
end # module Operator
|
16
|
-
end # module Alf
|
data/lib/alf/reader.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
#
|
3
|
-
# Implements an Iterator at the interface with the outside world.
|
4
|
-
#
|
5
|
-
# The contrat of a Reader is simply to be an Iterator. Unlike operators,
|
6
|
-
# however, readers are not expected to take other iterators as input, but IO
|
7
|
-
# objects, database tables, or something similar instead. This base class
|
8
|
-
# provides a default behavior for readers that works with IO objects. It can
|
9
|
-
# be safely extended, overriden, or even mimiced (provided that you include
|
10
|
-
# and implement the Iterator contract).
|
11
|
-
#
|
12
|
-
# This class also provides a registration mechanism to help getting Reader
|
13
|
-
# instances for specific file extensions. A typical scenario for using this
|
14
|
-
# registration mechanism is as follows:
|
15
|
-
#
|
16
|
-
# # Registers a reader kind named :foo, associated with ".foo" file
|
17
|
-
# # extensions and the FooFileDecoder class (typically a subclass of
|
18
|
-
# # Reader)
|
19
|
-
# Reader.register(:foo, [".foo"], FooFileDecoder)
|
20
|
-
#
|
21
|
-
# # Later on, you can request a reader instance for a .foo file, as
|
22
|
-
# # illustrated below.
|
23
|
-
# r = Reader.reader('/a/path/to/a/file.foo')
|
24
|
-
#
|
25
|
-
# # Also, a factory method is automatically installed on the Reader class
|
26
|
-
# # itself. This factory method can be used with a String, or an IO object.
|
27
|
-
# r = Reader.foo([a path or a IO object])
|
28
|
-
#
|
29
|
-
class Reader
|
30
|
-
include Iterator
|
31
|
-
|
32
|
-
require 'alf/reader/class_methods'
|
33
|
-
require 'alf/reader/instance_methods'
|
34
|
-
require 'alf/reader/rash'
|
35
|
-
require 'alf/reader/alf_file'
|
36
|
-
end # class Reader
|
37
|
-
end # module Alf
|
data/lib/alf/reader/alf_file.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
class Reader
|
3
|
-
#
|
4
|
-
# Specialization of the Reader contract for .alf files.
|
5
|
-
#
|
6
|
-
# A .alf file simply contains a query expression in the Lispy DSL. This
|
7
|
-
# reader decodes and compiles the expression and delegates the enumeration
|
8
|
-
# to the obtained operator.
|
9
|
-
#
|
10
|
-
# Note that an Environment must be wired at creation time. A
|
11
|
-
# NoSuchDatasetError will certainly occur otherwise.
|
12
|
-
#
|
13
|
-
class AlfFile < Reader
|
14
|
-
|
15
|
-
# (see Reader#each)
|
16
|
-
def each
|
17
|
-
op = Alf.lispy(environment).compile(input_text, input_path)
|
18
|
-
op.each(&Proc.new)
|
19
|
-
end
|
20
|
-
|
21
|
-
Reader.register(:alf, [".alf"], self)
|
22
|
-
end # module AlfFile
|
23
|
-
end # class Reader
|
24
|
-
end # module Alf
|
@@ -1,91 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
class Reader
|
3
|
-
module ClassMethods
|
4
|
-
|
5
|
-
# @return [Array<Reader>] registered readers
|
6
|
-
def readers
|
7
|
-
@readers ||= []
|
8
|
-
end
|
9
|
-
|
10
|
-
# Registers a reader class associated with specific file extensions.
|
11
|
-
#
|
12
|
-
# Registered class must provide a constructor with the following signature
|
13
|
-
# `new(path_or_io, environment = nil, options = {})`. The registration
|
14
|
-
# name must be a symbol which can safely be used as a ruby method name.
|
15
|
-
# A factory method of that name and signature is automatically installed
|
16
|
-
# on the Reader class.
|
17
|
-
#
|
18
|
-
# @param [Symbol] name a name for the kind of data decoded
|
19
|
-
# @param [Array] extensions file extensions mapped to the registered reader
|
20
|
-
# class (should include the '.', e.g. '.foo')
|
21
|
-
# @param [Class] class Reader subclass used to decode this kind of files
|
22
|
-
def register(name, extensions, clazz)
|
23
|
-
readers << [name, extensions, clazz]
|
24
|
-
(class << self; self; end).
|
25
|
-
send(:define_method, name) do |*args|
|
26
|
-
clazz.new(*args)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# When filepath looks like a String or a path, returns a reader instance
|
31
|
-
# for the source it denotes. Otherwise, delegates the call to
|
32
|
-
# `coerce(filepath)`.
|
33
|
-
#
|
34
|
-
# @param [:to_str|:to_path] filepath path to a file for which extension
|
35
|
-
# is recognized
|
36
|
-
# @param [Array] args optional additional arguments that must be passed at
|
37
|
-
# reader's class new method.
|
38
|
-
# @return [Reader] a reader instance built from arguments
|
39
|
-
# @raise [ArgumentError] if `filepath` is not recognized or no reader can
|
40
|
-
# be found for this extension.
|
41
|
-
def reader(filepath, *args)
|
42
|
-
if looks_a_path?(filepath)
|
43
|
-
ext = File.extname(filepath.to_s)
|
44
|
-
has_reader_for_ext!(ext).new(filepath.to_s, *args)
|
45
|
-
elsif args.empty?
|
46
|
-
coerce(filepath)
|
47
|
-
else
|
48
|
-
raise ArgumentError, "Unable to return a reader for #{filepath} and #{args}"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Coerces `arg` to a Reader instance, using an optional environment to
|
53
|
-
# convert named datasets.
|
54
|
-
#
|
55
|
-
# This method automatically provides readers for Strings and Symbols
|
56
|
-
# through `environment` (**not** through the reader factory) and for IO
|
57
|
-
# objects through a Rash reader.
|
58
|
-
#
|
59
|
-
# @param [Object] arg any value to coerce to a Reader instance
|
60
|
-
# @param [Environment] environment to resolved named datasets (optional)
|
61
|
-
def coerce(arg, environment = nil)
|
62
|
-
case arg
|
63
|
-
when Reader
|
64
|
-
arg
|
65
|
-
when IO, StringIO
|
66
|
-
rash(arg, environment)
|
67
|
-
else
|
68
|
-
raise ArgumentError, "Unable to coerce #{arg.inspect} to a reader"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
# Checks if `path` looks like a usable path
|
75
|
-
def looks_a_path?(path)
|
76
|
-
return false if path.is_a?(StringIO)
|
77
|
-
path.respond_to?(:to_str) or path.respond_to?(:to_path)
|
78
|
-
end
|
79
|
-
|
80
|
-
# @return [Class] the reader class to use for `ext` file extension.
|
81
|
-
# @raise [ArgumentError] if no such reader class can be found
|
82
|
-
def has_reader_for_ext!(ext)
|
83
|
-
entry = readers.find{|r| r[1].include?(ext)}
|
84
|
-
return entry[2] if entry
|
85
|
-
raise ArgumentError, "No registered reader for #{ext}"
|
86
|
-
end
|
87
|
-
|
88
|
-
end # module ClassMethods
|
89
|
-
extend(ClassMethods)
|
90
|
-
end # class Reader
|
91
|
-
end # module Alf
|