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,54 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
class Relation; end
|
3
|
-
module Tools
|
4
|
-
|
5
|
-
# Converts `value` to a Relation.
|
6
|
-
#
|
7
|
-
# Example:
|
8
|
-
#
|
9
|
-
# Tools.to_relation(:name => "Alf")
|
10
|
-
# # => (Relation {:name => "Alf"})
|
11
|
-
#
|
12
|
-
# @param [Object] expr any ruby object to convert to a Relation
|
13
|
-
# @return [Relation] a relation for `expr`
|
14
|
-
def to_relation(expr)
|
15
|
-
ToRelation.apply(expr)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Myrrha rules for converting objects to relations
|
19
|
-
ToRelation = Myrrha::coercions do |r|
|
20
|
-
r.main_target_domain = Relation
|
21
|
-
|
22
|
-
# Delegate to #to_relation if it exists
|
23
|
-
rel_able = lambda{|v,rd| v.respond_to?(:to_relation)}
|
24
|
-
r.upon(rel_able) do |v,_|
|
25
|
-
v.to_relation
|
26
|
-
end
|
27
|
-
|
28
|
-
# to_relation(:name => ["...", "..."])
|
29
|
-
list_of_values = lambda{|v,_|
|
30
|
-
v.is_a?(Hash) and v.size == 1 and v.values.first.is_a?(Array)
|
31
|
-
}
|
32
|
-
r.upon(list_of_values) do |v,_|
|
33
|
-
key, values = v.to_a.first
|
34
|
-
tuples = values.map{|value| {key => value}}.to_set
|
35
|
-
Relation.new(tuples)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Tuple to singleton Relation
|
39
|
-
r.upon(Hash) do |v,_|
|
40
|
-
Relation.new(Set.new << v)
|
41
|
-
end
|
42
|
-
|
43
|
-
# From enumerable of tuples to Relation
|
44
|
-
enum_of_tuples = lambda{|v,_|
|
45
|
-
v.is_a?(Enumerable) and v.all?{|t| t.is_a?(Hash)}
|
46
|
-
}
|
47
|
-
r.upon(enum_of_tuples) do |v,_|
|
48
|
-
Relation.new(v.to_set)
|
49
|
-
end
|
50
|
-
|
51
|
-
end # ToRelation
|
52
|
-
|
53
|
-
end # module Tools
|
54
|
-
end # module Alf
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Tools
|
3
|
-
|
4
|
-
# Converts `value` to a ruby literal
|
5
|
-
#
|
6
|
-
# This method is provided for code generation mechanisms used by Alf in
|
7
|
-
# various places (such as .rash files). The to_ruby_literal contract is
|
8
|
-
# such that the following invariant holds:
|
9
|
-
#
|
10
|
-
# eval(to_ruby_literal(value)) == value
|
11
|
-
#
|
12
|
-
# This contract is ensured by Myrrha::ToRubyLiteral for various ruby values.
|
13
|
-
# Myrrha delegates the job to `value.to_ruby_literal` provided this method
|
14
|
-
# exists. In such case, the implementation must be such that the invariant
|
15
|
-
# above is met.
|
16
|
-
#
|
17
|
-
# In every case, an invocation to this method only makes sense provided that
|
18
|
-
# `value` denotes a pure value, with the obvious semantics (from TTM).
|
19
|
-
#
|
20
|
-
# @param [Object] value any ruby object that denotes a pure value.
|
21
|
-
# @return [String] a ruby literal for `value`
|
22
|
-
def to_ruby_literal(value)
|
23
|
-
ToRubyLiteral.apply(value)
|
24
|
-
end
|
25
|
-
|
26
|
-
# Myrrha rules for converting to ruby literals
|
27
|
-
ToRubyLiteral = Myrrha::ToRubyLiteral.dup.append do
|
28
|
-
end
|
29
|
-
|
30
|
-
end # module Tools
|
31
|
-
end # module Alf
|
@@ -1,60 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Tools
|
3
|
-
#
|
4
|
-
# Provides a handle for implementing a flyweight design pattern on tuples.
|
5
|
-
#
|
6
|
-
# This class works hand-in-hand with TupleExpression as it provides a scope
|
7
|
-
# for their evaluation on tuples.
|
8
|
-
#
|
9
|
-
# Example:
|
10
|
-
#
|
11
|
-
# handle = TupleHandle.new
|
12
|
-
# expr = TupleExpression["status > 10"]
|
13
|
-
# relation.each do |tuple|
|
14
|
-
# expr.evaluate(handle.set(tuple))
|
15
|
-
# end
|
16
|
-
#
|
17
|
-
class TupleHandle
|
18
|
-
|
19
|
-
# Creates a handle instance
|
20
|
-
def initialize
|
21
|
-
@tuple = nil
|
22
|
-
end
|
23
|
-
|
24
|
-
# Sets the next tuple to use.
|
25
|
-
#
|
26
|
-
# On first call, this method installs the handle as a side effect.
|
27
|
-
#
|
28
|
-
# @param [Tuple] tuple the current iterated tuple
|
29
|
-
# @return [TupleHandle] self
|
30
|
-
def set(tuple)
|
31
|
-
build(tuple) if @tuple.nil?
|
32
|
-
@tuple = tuple
|
33
|
-
self
|
34
|
-
end
|
35
|
-
|
36
|
-
# Evaluates a tuple expression on the current tuple.
|
37
|
-
#
|
38
|
-
# @param [Object] expr a tuple expression (coercions apply)
|
39
|
-
# @return [Object] the result of evaluting `expr` on self
|
40
|
-
def evaluate(expr)
|
41
|
-
TupleExpression.coerce(expr).evaluate(self)
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
# Builds this handle with a tuple.
|
47
|
-
#
|
48
|
-
# This method should be called only once and installs instance methods on
|
49
|
-
# the handle with keys of _tuple_.
|
50
|
-
def build(tuple)
|
51
|
-
tuple.keys.each do |k|
|
52
|
-
(class << self; self; end).send(:define_method, k) do
|
53
|
-
@tuple[k]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end # class TupleHandle
|
59
|
-
end # module Tools
|
60
|
-
end # module Alf
|
data/lib/alf/types.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
#
|
3
|
-
# This module defines a namespace for useful datatypes as well as a few
|
4
|
-
# typing tools. Defined types are automatically defined as constants on the
|
5
|
-
# Alf module itself.
|
6
|
-
#
|
7
|
-
module Types
|
8
|
-
require 'alf/types/boolean'
|
9
|
-
require 'alf/types/size'
|
10
|
-
require 'alf/types/attr_name'
|
11
|
-
require 'alf/types/attr_list'
|
12
|
-
require 'alf/types/heading'
|
13
|
-
require 'alf/types/ordering'
|
14
|
-
require 'alf/types/renaming'
|
15
|
-
require 'alf/types/summarization'
|
16
|
-
require 'alf/types/tuple_expression'
|
17
|
-
require 'alf/types/tuple_predicate'
|
18
|
-
require 'alf/types/tuple_computation'
|
19
|
-
|
20
|
-
# Returns the (least) common super type of c1 and c2.
|
21
|
-
#
|
22
|
-
# The least common super type is defined as the lowest ancestor shared
|
23
|
-
# between c1 and c2.
|
24
|
-
#
|
25
|
-
# Examples:
|
26
|
-
#
|
27
|
-
# Types.common_super_type(String, String) # => String
|
28
|
-
# Types.common_super_type(Integer, Float) # => Numeric
|
29
|
-
# Types.common_super_type(Integer, String) # => Object
|
30
|
-
#
|
31
|
-
# @param [Class] c1 a data type, respresented by a ruby class
|
32
|
-
# @param [Class] c2 a data type, respresented by a ruby class
|
33
|
-
# @return [Class] the least common super type of c1 and c2
|
34
|
-
def common_super_type(c1, c2)
|
35
|
-
return c1 if c1 == c2
|
36
|
-
ancestors = [c1, c2].map{|c|
|
37
|
-
c.ancestors.select{|a| a.is_a?(Class)}
|
38
|
-
}
|
39
|
-
(ancestors[0] & ancestors[1]).first
|
40
|
-
end
|
41
|
-
module_function :common_super_type
|
42
|
-
|
43
|
-
# Install all types on Alf now
|
44
|
-
constants.each do |s|
|
45
|
-
Alf.const_set(s, const_get(s))
|
46
|
-
end
|
47
|
-
|
48
|
-
end # module Types
|
49
|
-
end # module Alf
|
data/lib/alf/types/attr_list.rb
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Types
|
3
|
-
#
|
4
|
-
# An attribute list is an ordered collection of attribute names (see
|
5
|
-
# AttrName).
|
6
|
-
#
|
7
|
-
# Example:
|
8
|
-
#
|
9
|
-
# list = AttrList[:name, :city]
|
10
|
-
#
|
11
|
-
class AttrList
|
12
|
-
|
13
|
-
# @return [Array<AttrName>] the list of attribute names
|
14
|
-
attr_accessor :attributes
|
15
|
-
|
16
|
-
# Creates an AttrList instance.
|
17
|
-
#
|
18
|
-
# @param [Array<AttrName>] the list of attribute names
|
19
|
-
def initialize(attributes)
|
20
|
-
@attributes = attributes
|
21
|
-
end
|
22
|
-
|
23
|
-
class << self
|
24
|
-
|
25
|
-
# Coerces `arg` to an AttrList.
|
26
|
-
#
|
27
|
-
# Recognizes coercions are:
|
28
|
-
# - AttrList -> self
|
29
|
-
# - Ordering -> the underlying list of attributes
|
30
|
-
# - Array -> through AttrName coercion of its elements
|
31
|
-
#
|
32
|
-
# @param [Object] arg the value to coerce to an AttrList
|
33
|
-
# @return [AttrList] an attribute list if coercion succeeds
|
34
|
-
# @raise [ArgumentError] if the coercion fails
|
35
|
-
def coerce(arg)
|
36
|
-
return arg.to_attr_list if arg.respond_to?(:to_attr_list)
|
37
|
-
case arg
|
38
|
-
when Array
|
39
|
-
AttrList.new(arg.collect{|s| Tools.coerce(s, AttrName)})
|
40
|
-
else
|
41
|
-
raise ArgumentError, "Unable to coerce #{arg} to a projection key"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# Coerces a list of names to an AttrList.
|
46
|
-
#
|
47
|
-
# @param [Array] args a list of names (Symbol or String)
|
48
|
-
# @return [AttrList] an attribute list
|
49
|
-
def [](*args)
|
50
|
-
coerce(args)
|
51
|
-
end
|
52
|
-
|
53
|
-
# Builds an AttrList from commandline arguments.
|
54
|
-
#
|
55
|
-
# This method relies on `coerce` and therefore shares its spec.
|
56
|
-
#
|
57
|
-
# @param [Array] argv an array of commandline arguments
|
58
|
-
# @param [Hash] opts convertion options (unused)
|
59
|
-
# @return [AttrList] an attribute list if coercion succeeds
|
60
|
-
# @raise [ArgumentError] if the coercion fails
|
61
|
-
def from_argv(argv, opts = {})
|
62
|
-
coerce(argv)
|
63
|
-
end
|
64
|
-
|
65
|
-
end # class << self
|
66
|
-
|
67
|
-
# Converts this attribute list to an ordering.
|
68
|
-
#
|
69
|
-
# @param [Symbol] :asc or :desc for ordering direction
|
70
|
-
# @return [Ordering] an ordering instance
|
71
|
-
def to_ordering(order = :asc)
|
72
|
-
Ordering.new attributes.map{|arg| [arg, order]}
|
73
|
-
end
|
74
|
-
|
75
|
-
# Splits a tuple in two parts according `allbut`.
|
76
|
-
#
|
77
|
-
# Example:
|
78
|
-
# list = AttrList.new([:name])
|
79
|
-
# tuple = {:name => "Jones", :city => "London"}
|
80
|
-
#
|
81
|
-
# list.split_tuple(tuple)
|
82
|
-
# # => [{:name => "Jones"}, {:city => "London"}]
|
83
|
-
#
|
84
|
-
# list.split_tuple(tuple, true)
|
85
|
-
# # => [{:city => "London"}, {:name => "Jones"}]
|
86
|
-
#
|
87
|
-
# @param [Hash] tuple a tuple to split
|
88
|
-
# @param [Boolean] allbut unknown attributes as first result?
|
89
|
-
# @return [Array<Hash>] an array containing two tuples, according to known
|
90
|
-
# attributes and `allbut`
|
91
|
-
def split_tuple(tuple, allbut = false)
|
92
|
-
projection, rest = {}, tuple.dup
|
93
|
-
attributes.each do |a|
|
94
|
-
projection[a] = tuple[a]
|
95
|
-
rest.delete(a)
|
96
|
-
end
|
97
|
-
allbut ? [rest, projection] : [projection, rest]
|
98
|
-
end
|
99
|
-
|
100
|
-
# Projects `tuple` on known (or unknown) attributes.
|
101
|
-
#
|
102
|
-
# Example:
|
103
|
-
# list = AttrList.new([:name])
|
104
|
-
# tuple = {:name => "Jones", :city => "London"}
|
105
|
-
#
|
106
|
-
# list.project_tuple(tuple)
|
107
|
-
# # => {:name => "Jones"}
|
108
|
-
#
|
109
|
-
# list.project_tuple(tuple, true)
|
110
|
-
# # => {:city => "London"}
|
111
|
-
#
|
112
|
-
# @param [Hash] tuple a tuple to project
|
113
|
-
# @param [Boolean] allbut projection?
|
114
|
-
# @return Hash the projected tuple
|
115
|
-
def project_tuple(tuple, allbut = false)
|
116
|
-
split_tuple(tuple, allbut).first
|
117
|
-
end
|
118
|
-
|
119
|
-
# Checks equality with another attribute list.
|
120
|
-
#
|
121
|
-
# @param [Object] other another attribute list
|
122
|
-
# @return [Boolean] true if `other` is an attribute list and contains
|
123
|
-
# the same attributes, in the same order
|
124
|
-
def ==(other)
|
125
|
-
other.is_a?(AttrList) && (other.attributes == attributes)
|
126
|
-
end
|
127
|
-
alias :eql? :==
|
128
|
-
|
129
|
-
# Returns an hash code.
|
130
|
-
#
|
131
|
-
# @return [Integer] an hash code for this attribute list
|
132
|
-
def hash
|
133
|
-
attributes.hash
|
134
|
-
end
|
135
|
-
|
136
|
-
# Converts to an array of attribute names.
|
137
|
-
#
|
138
|
-
# @return [Array<AttrName>] and array of attribute names
|
139
|
-
def to_a
|
140
|
-
attributes.dup
|
141
|
-
end
|
142
|
-
|
143
|
-
# Converts to an attribute list.
|
144
|
-
#
|
145
|
-
# @return [AttrList] return self
|
146
|
-
def to_attr_list
|
147
|
-
self
|
148
|
-
end
|
149
|
-
|
150
|
-
# Returns a ruby literal for this attribute list.
|
151
|
-
#
|
152
|
-
# @return [String] a literal s.t. `eval(self.to_ruby_literal) == self`
|
153
|
-
def to_ruby_literal
|
154
|
-
"Alf::AttrList#{Tools.to_ruby_literal(attributes)}"
|
155
|
-
end
|
156
|
-
alias :inspect :to_ruby_literal
|
157
|
-
|
158
|
-
end # class AttrList
|
159
|
-
end # module Types
|
160
|
-
end # module Alf
|
data/lib/alf/types/attr_name.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Types
|
3
|
-
#
|
4
|
-
# Attribute name.
|
5
|
-
#
|
6
|
-
# Attribute names are ruby symbols that match the following regular
|
7
|
-
# expression:
|
8
|
-
#
|
9
|
-
# /^[a-zA-Z0-9_]+[?!]?$/
|
10
|
-
#
|
11
|
-
# Example:
|
12
|
-
#
|
13
|
-
# AttrName["city"]
|
14
|
-
# # => :city
|
15
|
-
#
|
16
|
-
class AttrName < Symbol
|
17
|
-
extend Myrrha::Domain
|
18
|
-
|
19
|
-
class << self
|
20
|
-
|
21
|
-
# The domain predicate
|
22
|
-
PREDICATE = lambda{|s| s.to_s =~ /^[a-zA-Z0-9_]+[?!]?$/}
|
23
|
-
|
24
|
-
# Returns the domain predicate.
|
25
|
-
#
|
26
|
-
# @return [Proc] the domain predicate as a Proc obbject
|
27
|
-
def predicate
|
28
|
-
PREDICATE
|
29
|
-
end
|
30
|
-
|
31
|
-
# Coerces `arg` to an AttrName.
|
32
|
-
#
|
33
|
-
# All objects that respond to :to_sym and match PREDICATE are
|
34
|
-
# valid coercion arguments.
|
35
|
-
#
|
36
|
-
# @param [Object] arg and argument to coerce to an AttrName
|
37
|
-
# @return [AttrName] an AttrName instance
|
38
|
-
# @raise [ArgumentError] is the coercion fails
|
39
|
-
def coerce(arg)
|
40
|
-
if arg.respond_to?(:to_sym)
|
41
|
-
sym = arg.to_sym
|
42
|
-
return sym if self.===(sym)
|
43
|
-
end
|
44
|
-
raise ArgumentError, "Unable to coerce `#{arg.inspect}` to AttrName"
|
45
|
-
end
|
46
|
-
alias :[] :coerce
|
47
|
-
|
48
|
-
# Converts commandline arguments to an AttrName.
|
49
|
-
#
|
50
|
-
# This method requires `argv` to be either empty or a singleton array.
|
51
|
-
# When empty, `opts[:default]` is used. The value must be coercable
|
52
|
-
# with `coerce` for this method to suceed.
|
53
|
-
#
|
54
|
-
# @param [Array] argv commandline arguments
|
55
|
-
# @params [Hash] opts options (not used)
|
56
|
-
# @raise [ArgumentError] is the coercion fails
|
57
|
-
def from_argv(argv, opts = {})
|
58
|
-
raise ArgumentError if argv.size > 1
|
59
|
-
coerce(argv.first || opts[:default])
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end # class AttrName
|
65
|
-
end # module Types
|
66
|
-
end # module Alf
|
data/lib/alf/types/boolean.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Types
|
3
|
-
|
4
|
-
# Defines the Boolean type which is missing to ruby.
|
5
|
-
Boolean = Myrrha::Boolean
|
6
|
-
|
7
|
-
# Converts commandline arguments to a Boolean.
|
8
|
-
#
|
9
|
-
# This method requires `argv` to be either empty or a singleton array.
|
10
|
-
# When empty, `opts[:default]` is used. The value must be coercable
|
11
|
-
# to a Boolean, according to Myrrha::Boolean coercions.
|
12
|
-
#
|
13
|
-
# @param [Array] argv commandline arguments
|
14
|
-
# @params [Hash] opts options (not used)
|
15
|
-
# @raise [ArgumentError] is the coercion fails
|
16
|
-
def Boolean.from_argv(argv, opts={})
|
17
|
-
raise ArgumentError if argv.size > 1
|
18
|
-
value = argv.first || opts[:default] || false
|
19
|
-
Tools.coerce(value, Boolean)
|
20
|
-
rescue CoercionError
|
21
|
-
raise ArgumentError, "Unable to coerce `#{value.inspect}` to Boolean"
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|