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
data/lib/alf/renderer/rash.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
class Renderer
|
3
|
-
#
|
4
|
-
# Implements the Renderer contract through inspect
|
5
|
-
#
|
6
|
-
class Rash < Renderer
|
7
|
-
|
8
|
-
# (see Renderer#render)
|
9
|
-
def render(input, output)
|
10
|
-
if options[:pretty]
|
11
|
-
input.each do |tuple|
|
12
|
-
output << "{\n" << tuple.collect{|k,v|
|
13
|
-
" #{lit(k)} => #{lit(v)}"
|
14
|
-
}.join(",\n") << "\n}\n"
|
15
|
-
end
|
16
|
-
else
|
17
|
-
input.each do |tuple|
|
18
|
-
output << lit(tuple) << "\n"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
output
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def lit(x)
|
27
|
-
Tools.to_ruby_literal(x)
|
28
|
-
end
|
29
|
-
|
30
|
-
Renderer.register(:rash, "as ruby hashes", self)
|
31
|
-
end # class Rash
|
32
|
-
end # class Renderer
|
33
|
-
end # module Alf
|
data/lib/alf/renderer/text.rb
DELETED
@@ -1,198 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Text
|
3
|
-
|
4
|
-
#
|
5
|
-
# Implements Alf::Renderer for outputting beautiful text tables.
|
6
|
-
#
|
7
|
-
class Renderer < ::Alf::Renderer
|
8
|
-
|
9
|
-
module Utils
|
10
|
-
|
11
|
-
def looks_a_relation?(value)
|
12
|
-
value.is_a?(Alf::Iterator) or
|
13
|
-
(value.is_a?(Array) && !value.empty? && value.all?{|v| v.is_a?(Hash)})
|
14
|
-
end
|
15
|
-
|
16
|
-
def max(x, y)
|
17
|
-
return y if x.nil?
|
18
|
-
return x if y.nil?
|
19
|
-
x > y ? x : y
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
include Utils
|
24
|
-
|
25
|
-
class Cell
|
26
|
-
include Utils
|
27
|
-
|
28
|
-
def initialize(value, options = {})
|
29
|
-
@value = value
|
30
|
-
@options = options
|
31
|
-
end
|
32
|
-
|
33
|
-
def min_width
|
34
|
-
@min_width ||= rendering_lines.inject(0) do |maxl,line|
|
35
|
-
max(maxl,line.size)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def rendering_lines(size = nil)
|
40
|
-
if size.nil?
|
41
|
-
text_rendering.split(/\n/)
|
42
|
-
elsif @value.is_a?(Numeric)
|
43
|
-
rendering_lines(nil).collect{|l| "%#{size}s" % l}
|
44
|
-
else
|
45
|
-
rendering_lines(nil).collect{|l| "%-#{size}s" % l}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def text_rendering
|
50
|
-
@text_rendering ||= case (value = @value)
|
51
|
-
when NilClass
|
52
|
-
"[nil]"
|
53
|
-
when Symbol
|
54
|
-
value.inspect
|
55
|
-
when Float
|
56
|
-
(@options[:float_format] || "%.3f") % value
|
57
|
-
when Hash
|
58
|
-
value.inspect
|
59
|
-
when Alf::Iterator
|
60
|
-
Text::Renderer.render(value, "", @options)
|
61
|
-
when Array
|
62
|
-
array_rendering(value)
|
63
|
-
else
|
64
|
-
value.to_s
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def array_rendering(value)
|
69
|
-
if looks_a_relation?(value)
|
70
|
-
Text.render(value, "")
|
71
|
-
elsif value.empty?
|
72
|
-
"[]"
|
73
|
-
else
|
74
|
-
values = value.collect{|x| Cell.new(x).text_rendering}
|
75
|
-
if values.inject(0){|memo,s| memo + s.size} < 20
|
76
|
-
"[" + values.join(", ") + "]"
|
77
|
-
else
|
78
|
-
"[" + values.join(",\n ") + "]"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
end # class Cell
|
84
|
-
|
85
|
-
class Row
|
86
|
-
include Utils
|
87
|
-
|
88
|
-
def initialize(values, options = {})
|
89
|
-
@cells = values.collect{|v| Cell.new(v, options)}
|
90
|
-
@options = options
|
91
|
-
end
|
92
|
-
|
93
|
-
def min_widths
|
94
|
-
@cells.collect{|cell| cell.min_width}
|
95
|
-
end
|
96
|
-
|
97
|
-
def rendering_lines(sizes = min_widths)
|
98
|
-
nb_lines = 0
|
99
|
-
by_cell = @cells.zip(sizes).collect do |cell,size|
|
100
|
-
lines = cell.rendering_lines(size)
|
101
|
-
nb_lines = max(nb_lines, lines.size)
|
102
|
-
lines
|
103
|
-
end
|
104
|
-
grid = (0...nb_lines).collect do |line_i|
|
105
|
-
"| " + by_cell.zip(sizes).collect{|cell_lines, size|
|
106
|
-
cell_lines[line_i] || " "*size
|
107
|
-
}.join(" | ") + " |"
|
108
|
-
end
|
109
|
-
grid.empty? ? ["| |"] : grid
|
110
|
-
end
|
111
|
-
|
112
|
-
end # class Row
|
113
|
-
|
114
|
-
class Table
|
115
|
-
include Utils
|
116
|
-
|
117
|
-
def initialize(records, attributes, options = {})
|
118
|
-
@header = Row.new(attributes)
|
119
|
-
@rows = records.collect{|r| Row.new(r, options)}
|
120
|
-
@options = options
|
121
|
-
end
|
122
|
-
|
123
|
-
def render(buffer = "")
|
124
|
-
sizes = @rows.inject(@header.min_widths) do |memo,row|
|
125
|
-
memo.zip(row.min_widths).collect{|x,y| max(x,y)}
|
126
|
-
end
|
127
|
-
sep = '+-' << sizes.collect{|s| '-' * s}.join('-+-') << '-+'
|
128
|
-
buffer << sep << "\n"
|
129
|
-
buffer << @header.rendering_lines(sizes).first << "\n"
|
130
|
-
buffer << sep << "\n"
|
131
|
-
@rows.each do |row|
|
132
|
-
row.rendering_lines(sizes).each do |line|
|
133
|
-
buffer << line << "\n"
|
134
|
-
end
|
135
|
-
end
|
136
|
-
buffer << sep << "\n"
|
137
|
-
buffer
|
138
|
-
end
|
139
|
-
|
140
|
-
end # class Table
|
141
|
-
|
142
|
-
class PrettyBuffer
|
143
|
-
|
144
|
-
def initialize(out, options)
|
145
|
-
@out = out
|
146
|
-
@trim_at = options[:trim_at]
|
147
|
-
@page_at = options[:page_at]
|
148
|
-
@page_line = 0
|
149
|
-
end
|
150
|
-
|
151
|
-
def <<(str)
|
152
|
-
print_a_line trim(str)
|
153
|
-
self
|
154
|
-
end
|
155
|
-
|
156
|
-
def trim(str)
|
157
|
-
return str unless (@trim_at && (str.length > @trim_at))
|
158
|
-
trimmed = (str[0..(@trim_at-4)] + "...")
|
159
|
-
trimmed << "\n" if str =~ /\n$/
|
160
|
-
trimmed
|
161
|
-
end
|
162
|
-
|
163
|
-
def print_a_line(line)
|
164
|
-
@out << line
|
165
|
-
@page_line += 1
|
166
|
-
do_wait if @page_at && (@page_line > @page_at)
|
167
|
-
end
|
168
|
-
|
169
|
-
def do_wait
|
170
|
-
@out << "--- Press ENTER (or quit) ---\n"
|
171
|
-
throw :stop if $stdin.getc =~ /^[qQ](uit)?/
|
172
|
-
@page_line = 0
|
173
|
-
end
|
174
|
-
|
175
|
-
end # class PrettyBuffer
|
176
|
-
|
177
|
-
protected
|
178
|
-
|
179
|
-
def render(input, output)
|
180
|
-
relation = input.to_a
|
181
|
-
attrs = relation.inject([]){|memo,t| (memo | t.keys)}
|
182
|
-
records = relation.collect{|t| attrs.collect{|a| t[a]}}
|
183
|
-
table = Table.new(records, attrs, options)
|
184
|
-
buffer = options[:pretty] ?
|
185
|
-
PrettyBuffer.new(output, options) : output
|
186
|
-
catch(:stop){ table.render(buffer) }
|
187
|
-
output
|
188
|
-
end
|
189
|
-
|
190
|
-
def self.render(input, output, options= {})
|
191
|
-
new(input, options).execute(output)
|
192
|
-
end
|
193
|
-
|
194
|
-
::Alf::Renderer.register(:text, "as a text table", self)
|
195
|
-
end # class Renderer
|
196
|
-
|
197
|
-
end # module Text
|
198
|
-
end # module Alf
|
data/lib/alf/tools.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
#
|
3
|
-
# Provides tooling methods that are used here and there in Alf.
|
4
|
-
#
|
5
|
-
module Tools
|
6
|
-
require 'alf/tools/coerce'
|
7
|
-
require 'alf/tools/to_ruby_literal'
|
8
|
-
require 'alf/tools/to_lispy'
|
9
|
-
require 'alf/tools/to_relation'
|
10
|
-
require 'alf/tools/tuple_handle'
|
11
|
-
require 'alf/tools/miscellaneous'
|
12
|
-
|
13
|
-
extend Tools
|
14
|
-
end # module Tools
|
15
|
-
end # module Alf
|
data/lib/alf/tools/coerce.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Tools
|
3
|
-
|
4
|
-
# Defines all coercion rules, through Myrrha inheritance
|
5
|
-
Coercions = Myrrha::Coerce.dup.append do
|
6
|
-
end
|
7
|
-
|
8
|
-
# Coerces a value to a particular domain.
|
9
|
-
#
|
10
|
-
# Example:
|
11
|
-
#
|
12
|
-
# Tools.coerce("123", Integer) # => 123
|
13
|
-
#
|
14
|
-
# @param [Object] val any value
|
15
|
-
# @param [Class] domain a domain, represented by a ruby class
|
16
|
-
# @return [Object] an instance of `domain` resulting from the coercion
|
17
|
-
# @raise [Myrrha::CoercionError] if something goes wrong
|
18
|
-
def coerce(val, domain)
|
19
|
-
Coercions.apply(val, domain)
|
20
|
-
rescue Myrrha::Error => ex
|
21
|
-
raise CoercionError, ex.message, caller
|
22
|
-
end
|
23
|
-
|
24
|
-
end # module Tools
|
25
|
-
end # module Alf
|
@@ -1,111 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Tools
|
3
|
-
|
4
|
-
# Helper to define methods with multiple signatures.
|
5
|
-
#
|
6
|
-
# Example:
|
7
|
-
#
|
8
|
-
# varargs([1, "hello"], [Integer, String]) # => [1, "hello"]
|
9
|
-
# varargs(["hello"], [Integer, String]) # => [nil, "hello"]
|
10
|
-
#
|
11
|
-
# @param [Array] args some arguments passed to a method
|
12
|
-
# @param [Array<===>] some expected types
|
13
|
-
# @return [Array] an array with one value for each type
|
14
|
-
def varargs(args, types)
|
15
|
-
types.map{|t| t===args.first ? args.shift : nil}
|
16
|
-
end
|
17
|
-
|
18
|
-
# Attempts to require `who` the most friendly way as possible.
|
19
|
-
#
|
20
|
-
# This method allows loading weak dependencies in a friendly way. It takes
|
21
|
-
# care of ensuring the dependency requirement `req` through rubygems. The
|
22
|
-
# latter is loaded if required.
|
23
|
-
#
|
24
|
-
# Example:
|
25
|
-
#
|
26
|
-
# Tools.friendly_require('sequel', '~> 3.0')
|
27
|
-
#
|
28
|
-
# @param [String] who the name of a gem
|
29
|
-
# @param [String] req optional requirements on the gem version
|
30
|
-
# @param [Boolean] retried (private parameter)
|
31
|
-
def friendly_require(who, req = nil, retried = false)
|
32
|
-
gem(who, req) if req && defined?(Gem)
|
33
|
-
require who
|
34
|
-
rescue LoadError => ex
|
35
|
-
if retried
|
36
|
-
raise "Unable to require #{who}, which is now needed\n"\
|
37
|
-
"Try 'gem install #{who}'"
|
38
|
-
else
|
39
|
-
require 'rubygems' unless defined?(Gem)
|
40
|
-
friendly_require(who, req, true)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Returns the unqualified name of a ruby class or module.
|
45
|
-
#
|
46
|
-
# Example
|
47
|
-
#
|
48
|
-
# class_name(Alf::Tools) -> :Tools
|
49
|
-
#
|
50
|
-
# @param [Class] clazz a ruby class
|
51
|
-
# @return [Symbol] the unqualified name of the class as a Symbol
|
52
|
-
def class_name(clazz)
|
53
|
-
/([A-Za-z0-9_]+)$/.match(clazz.name.to_s)[1].to_sym
|
54
|
-
end
|
55
|
-
|
56
|
-
# Converts an unqualified class or module name to a ruby case method name.
|
57
|
-
#
|
58
|
-
# Example
|
59
|
-
#
|
60
|
-
# ruby_case(:Alf) -> "alf"
|
61
|
-
# ruby_case(:HelloWorld) -> "hello_world"
|
62
|
-
#
|
63
|
-
# @param [String or Symbol] a class or module name
|
64
|
-
# @return [String] the class or module name in ruby_case
|
65
|
-
def ruby_case(s)
|
66
|
-
s.to_s.gsub(/[A-Z]/){|x| "_#{x.downcase}"}[1..-1]
|
67
|
-
end
|
68
|
-
|
69
|
-
# Returns the first non nil values from arguments.
|
70
|
-
#
|
71
|
-
# When no non-nil value can be found, the block is yield if present.
|
72
|
-
# Otherwise, nil is returned.
|
73
|
-
#
|
74
|
-
# Example:
|
75
|
-
#
|
76
|
-
# coalesce(nil, 1, "abc") # -> 1
|
77
|
-
# coalesce(nil, nil){ "hello" } # -> "hello"
|
78
|
-
# coalesce(nil, nil) # -> nil
|
79
|
-
#
|
80
|
-
# @param [Array] args a list of values
|
81
|
-
# @return [Object] the first non-nil value in `args`; the result of the
|
82
|
-
# block or nil if no non-nil value can be found.
|
83
|
-
def coalesce(*args)
|
84
|
-
if found = args.find{|x| !x.nil?}
|
85
|
-
found
|
86
|
-
elsif block_given?
|
87
|
-
yield
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# Builds a tuple through enumeration.
|
92
|
-
#
|
93
|
-
# Iterates over enum and yields the block on each element. Collect block
|
94
|
-
# results as key/value pairs returns them as a Hash.
|
95
|
-
#
|
96
|
-
# @param [Enumerable] enum any enumerable
|
97
|
-
# @return [Tuple] a tuple built from yield results
|
98
|
-
def tuple_collect(enum)
|
99
|
-
Hash[enum.map{|elm| yield(elm)}]
|
100
|
-
end
|
101
|
-
|
102
|
-
# Infers the heading from a tuple
|
103
|
-
#
|
104
|
-
# @param [Tuple] tuple a tuple, represented by a Hash
|
105
|
-
# @param [Heading] the heading of the tuple
|
106
|
-
def tuple_heading(tuple)
|
107
|
-
Heading[Hash[tuple.map{|k,v| [k, v.class]}]]
|
108
|
-
end
|
109
|
-
|
110
|
-
end # module Tools
|
111
|
-
end # module Alf
|
data/lib/alf/tools/to_lispy.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
module Alf
|
2
|
-
module Tools
|
3
|
-
|
4
|
-
# Converts `value` to a lispy expression.
|
5
|
-
#
|
6
|
-
# Example:
|
7
|
-
#
|
8
|
-
# expr = Alf.lispy.compile{
|
9
|
-
# (project :suppliers, [:name])
|
10
|
-
# }
|
11
|
-
# Tools.to_lispy(expr)
|
12
|
-
# # => (project :suppliers, [:name])
|
13
|
-
#
|
14
|
-
# @param [Object] expr any ruby object denoting a lispy expression
|
15
|
-
# @return [String] a lispy expression for `value`
|
16
|
-
def to_lispy(expr)
|
17
|
-
ToLispy.apply(expr)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Myrrha rules for converting to ruby literals
|
21
|
-
ToLispy = Myrrha::coercions do |r|
|
22
|
-
|
23
|
-
# Delegate to #to_lispy if it exists
|
24
|
-
lispy_able = lambda{|v,rd| v.respond_to?(:to_lispy)}
|
25
|
-
r.upon(lispy_able) do |v,rd|
|
26
|
-
v.to_lispy
|
27
|
-
end
|
28
|
-
|
29
|
-
# AttrList -> [:sid, :sname, ...]
|
30
|
-
r.upon(Types::AttrList) do |v, rd|
|
31
|
-
Tools.to_ruby_literal(v.attributes)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Heading -> {:sid => String, ...}
|
35
|
-
r.upon(Types::Heading) do |v, rd|
|
36
|
-
Tools.to_ruby_literal(v.to_h)
|
37
|
-
end
|
38
|
-
|
39
|
-
# Ordering -> [[:sid, :asc], ...]
|
40
|
-
r.upon(Types::Ordering) do |v, rd|
|
41
|
-
Tools.to_ruby_literal(v.ordering)
|
42
|
-
end
|
43
|
-
|
44
|
-
# Renaming -> {:old => :new, ...}
|
45
|
-
r.upon(Types::Renaming) do |v, rd|
|
46
|
-
Tools.to_ruby_literal(v.renaming)
|
47
|
-
end
|
48
|
-
|
49
|
-
# Iterator::Proxy -> :suppliers
|
50
|
-
r.upon(lambda{|v,rd| Iterator::Proxy === v}) do |v, rd|
|
51
|
-
Tools.to_ruby_literal(v.name)
|
52
|
-
end
|
53
|
-
|
54
|
-
# TupleExpression -> ->{ ... }
|
55
|
-
r.upon(Types::TupleExpression) do |v, rd|
|
56
|
-
"->{ #{v.has_source_code!} }"
|
57
|
-
end
|
58
|
-
|
59
|
-
# TupleComputation -> { :big => ->{ ... }, ... }
|
60
|
-
r.upon(Types::TupleComputation) do |v, rd|
|
61
|
-
"{" + v.computation.map{|name,compu|
|
62
|
-
[name.inspect, r.coerce(compu)].join(" => ")
|
63
|
-
}.join(', ') + "}"
|
64
|
-
end
|
65
|
-
|
66
|
-
# Aggregator -> agg.source
|
67
|
-
r.upon(lambda{|v,_| Aggregator === v}) do |v, rd|
|
68
|
-
v.has_source_code!
|
69
|
-
end
|
70
|
-
|
71
|
-
# Summarization -> { :total => ->{ ... } }
|
72
|
-
r.upon(Types::Summarization) do |v, rd|
|
73
|
-
"{" + v.aggregations.map{|name,compu|
|
74
|
-
[name.inspect, r.coerce(compu)].join(" => ")
|
75
|
-
}.join(', ') + "}"
|
76
|
-
end
|
77
|
-
|
78
|
-
# Command and Operator -> (operator operands, args, options)
|
79
|
-
cmd = lambda{|v,_| (Command === v) || (Operator === v)}
|
80
|
-
r.upon(cmd) do |v,rd|
|
81
|
-
cmdname = v.class.rubycase_name
|
82
|
-
oper, args, opts = v.class.signature.collect_on(v)
|
83
|
-
args = opts.empty? ? (oper + args) : (oper + args + [ opts ])
|
84
|
-
args = args.map{|arg| r.coerce(arg)}
|
85
|
-
"(#{cmdname} #{args.join(', ')})"
|
86
|
-
end
|
87
|
-
|
88
|
-
# Let's assume to to_ruby_literal will make the job
|
89
|
-
r.fallback(Object) do |v, _|
|
90
|
-
Tools.to_ruby_literal(v)
|
91
|
-
end
|
92
|
-
|
93
|
-
end # ToLispy
|
94
|
-
|
95
|
-
end # module Tools
|
96
|
-
end # module Alf
|