axiom 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +2 -1
- data/.rubocop.yml +7 -0
- data/.travis.yml +10 -7
- data/Gemfile +4 -0
- data/Gemfile.devtools +27 -13
- data/Guardfile +2 -2
- data/README.md +36 -30
- data/TODO +22 -24
- data/axiom.gemspec +9 -9
- data/benchmarks/memory.rb +1 -2
- data/benchmarks/speed.rb +7 -8
- data/config/flay.yml +1 -1
- data/config/reek.yml +19 -7
- data/config/rubocop.yml +6 -9
- data/lib/axiom.rb +28 -13
- data/lib/axiom/aggregate/mean.rb +4 -3
- data/lib/axiom/aggregate/sum.rb +1 -1
- data/lib/axiom/algebra/extension.rb +1 -1
- data/lib/axiom/algebra/join.rb +4 -27
- data/lib/axiom/algebra/product.rb +3 -3
- data/lib/axiom/algebra/projection.rb +2 -2
- data/lib/axiom/algebra/rename.rb +2 -2
- data/lib/axiom/algebra/rename/aliases.rb +3 -3
- data/lib/axiom/algebra/summarization.rb +3 -3
- data/lib/axiom/attribute.rb +5 -4
- data/lib/axiom/attribute/comparable.rb +15 -11
- data/lib/axiom/attribute/date.rb +1 -1
- data/lib/axiom/attribute/date_time.rb +1 -1
- data/lib/axiom/attribute/length_comparable.rb +39 -0
- data/lib/axiom/attribute/numeric.rb +1 -26
- data/lib/axiom/attribute/relation.rb +64 -0
- data/lib/axiom/attribute/string.rb +1 -28
- data/lib/axiom/attribute/time.rb +1 -1
- data/lib/axiom/attribute/tuple.rb +50 -0
- data/lib/axiom/attribute/value_comparable.rb +42 -0
- data/lib/axiom/function.rb +1 -1
- data/lib/axiom/function/binary.rb +4 -16
- data/lib/axiom/function/comparable.rb +1 -1
- data/lib/axiom/function/connective/conjunction.rb +1 -1
- data/lib/axiom/function/connective/disjunction.rb +1 -1
- data/lib/axiom/function/connective/negation.rb +1 -1
- data/lib/axiom/function/numeric/exponentiation.rb +1 -1
- data/lib/axiom/function/numeric/square_root.rb +1 -1
- data/lib/axiom/function/predicate/enumerable.rb +0 -14
- data/lib/axiom/function/predicate/exclusion.rb +1 -1
- data/lib/axiom/function/predicate/inclusion.rb +1 -1
- data/lib/axiom/function/proposition.rb +12 -25
- data/lib/axiom/function/unary.rb +92 -106
- data/lib/axiom/relation.rb +3 -3
- data/lib/axiom/relation/base.rb +15 -0
- data/lib/axiom/relation/header.rb +25 -22
- data/lib/axiom/relation/index.rb +91 -0
- data/lib/axiom/relation/keys.rb +3 -3
- data/lib/axiom/relation/materialized.rb +48 -4
- data/lib/axiom/relation/operation/binary.rb +5 -5
- data/lib/axiom/relation/operation/group.rb +95 -0
- data/lib/axiom/relation/operation/limit.rb +15 -15
- data/lib/axiom/relation/operation/offset.rb +12 -12
- data/lib/axiom/relation/operation/reverse.rb +9 -9
- data/lib/axiom/relation/operation/set.rb +1 -1
- data/lib/axiom/relation/operation/{order.rb → sorted.rb} +29 -28
- data/lib/axiom/relation/operation/{order → sorted}/direction.rb +4 -4
- data/lib/axiom/relation/operation/{order → sorted}/direction_set.rb +3 -3
- data/lib/axiom/relation/operation/ungroup.rb +82 -0
- data/lib/axiom/relation/operation/unwrap.rb +80 -0
- data/lib/axiom/relation/operation/wrap.rb +85 -0
- data/lib/axiom/relation/proxy.rb +5 -6
- data/lib/axiom/relation/variable.rb +1 -2
- data/lib/axiom/support/aliasable.rb +3 -5
- data/lib/axiom/support/equalizer.rb +10 -12
- data/lib/axiom/support/operation/binary.rb +3 -2
- data/lib/axiom/support/operation/unary.rb +1 -1
- data/lib/axiom/tuple.rb +76 -26
- data/lib/axiom/types/relation.rb +13 -0
- data/lib/axiom/types/tuple.rb +13 -0
- data/lib/axiom/version.rb +1 -1
- data/spec/integration/axiom/relation/efficient_enumerable_spec.rb +9 -9
- data/spec/integration/axiom/relation/writable_relations_spec.rb +12 -12
- data/spec/shared/invertible_method_behaviour.rb +1 -1
- data/spec/spec_helper.rb +8 -6
- data/spec/unit/axiom/aggregate/call_spec.rb +7 -12
- data/spec/unit/axiom/aggregate/class_methods/default_spec.rb +7 -2
- data/spec/unit/axiom/aggregate/default_spec.rb +1 -1
- data/spec/unit/axiom/aggregate/finalize_spec.rb +1 -1
- data/spec/unit/axiom/aggregate/maximum/type_spec.rb +2 -6
- data/spec/unit/axiom/aggregate/mean/class_methods/call_spec.rb +2 -2
- data/spec/unit/axiom/aggregate/mean/class_methods/finalize_spec.rb +10 -3
- data/spec/unit/axiom/aggregate/minimum/type_spec.rb +2 -6
- data/spec/unit/axiom/aggregate/sum/default_spec.rb +32 -6
- data/spec/unit/axiom/aggregate/sum/type_spec.rb +2 -6
- data/spec/unit/axiom/aggregate/variance/class_methods/call_spec.rb +6 -6
- data/spec/unit/axiom/algebra/difference/each_spec.rb +3 -3
- data/spec/unit/axiom/algebra/extension/class_methods/new_spec.rb +1 -1
- data/spec/unit/axiom/algebra/extension/each_spec.rb +2 -2
- data/spec/unit/axiom/algebra/intersection/each_spec.rb +3 -3
- data/spec/unit/axiom/algebra/join/each_spec.rb +6 -6
- data/spec/unit/axiom/algebra/product/each_spec.rb +2 -2
- data/spec/unit/axiom/algebra/projection/each_spec.rb +2 -2
- data/spec/unit/axiom/algebra/rename/directions_spec.rb +3 -3
- data/spec/unit/axiom/algebra/rename/each_spec.rb +2 -2
- data/spec/unit/axiom/algebra/restriction/delete_spec.rb +3 -3
- data/spec/unit/axiom/algebra/restriction/each_spec.rb +12 -11
- data/spec/unit/axiom/algebra/restriction/insert_spec.rb +3 -3
- data/spec/unit/axiom/algebra/restriction/methods/restrict_spec.rb +4 -4
- data/spec/unit/axiom/algebra/summarization/each_spec.rb +2 -2
- data/spec/unit/axiom/algebra/summarization/eql_spec.rb +1 -1
- data/spec/unit/axiom/algebra/summarization/summaries/summarize_by_spec.rb +4 -4
- data/spec/unit/axiom/algebra/summarization/summaries/to_hash_spec.rb +2 -2
- data/spec/unit/axiom/algebra/summarization/summary/summarize_by_spec.rb +1 -1
- data/spec/unit/axiom/algebra/union/each_spec.rb +4 -4
- data/spec/unit/axiom/aliasable/fixtures/classes.rb +3 -1
- data/spec/unit/axiom/aliasable/inheritable_alias_spec.rb +18 -27
- data/spec/unit/axiom/attribute/call_spec.rb +1 -1
- data/spec/unit/axiom/attribute/class_methods/coerce_spec.rb +57 -51
- data/spec/unit/axiom/attribute/class_methods/new_spec.rb +1 -1
- data/spec/unit/axiom/attribute/comparable/asc_spec.rb +4 -2
- data/spec/unit/axiom/attribute/comparable/desc_spec.rb +4 -2
- data/spec/unit/axiom/attribute/comparable/range_spec.rb +20 -0
- data/spec/unit/axiom/attribute/eql_spec.rb +1 -1
- data/spec/unit/axiom/attribute/equality_operator_spec.rb +1 -1
- data/spec/unit/axiom/attribute/include_predicate_spec.rb +1 -1
- data/spec/unit/axiom/attribute/name_spec.rb +1 -1
- data/spec/unit/axiom/attribute/optional_predicate_spec.rb +1 -1
- data/spec/unit/axiom/attribute/relation/class_methods/new_spec.rb +56 -0
- data/spec/unit/axiom/attribute/relation/class_methods/type_spec.rb +13 -0
- data/spec/unit/axiom/attribute/relation/header_spec.rb +13 -0
- data/spec/unit/axiom/attribute/relation/new_relation_spec.rb +15 -0
- data/spec/unit/axiom/attribute/rename_spec.rb +1 -1
- data/spec/unit/axiom/attribute/required_predicate_spec.rb +1 -1
- data/spec/unit/axiom/attribute/tuple/class_methods/new_spec.rb +56 -0
- data/spec/unit/axiom/attribute/tuple/class_methods/type_spec.rb +13 -0
- data/spec/unit/axiom/attribute/tuple/header_spec.rb +13 -0
- data/spec/unit/axiom/equalizer/class_method/new_spec.rb +24 -54
- data/spec/unit/axiom/evaluator/context/add_spec.rb +7 -7
- data/spec/unit/axiom/evaluator/context/element_reader_spec.rb +4 -4
- data/spec/unit/axiom/evaluator/context/functions_spec.rb +1 -1
- data/spec/unit/axiom/evaluator/context/method_missing_spec.rb +3 -3
- data/spec/unit/axiom/evaluator/context/respond_to_predicate_spec.rb +3 -3
- data/spec/unit/axiom/evaluator/context/send_spec.rb +8 -8
- data/spec/unit/axiom/function/binary/call_spec.rb +1 -1
- data/spec/unit/axiom/function/binary/type_spec.rb +12 -10
- data/spec/unit/axiom/function/comparable/class_methods/included_spec.rb +2 -2
- data/spec/unit/axiom/function/connective/negation/inverse_spec.rb +1 -1
- data/spec/unit/axiom/function/predicate/call_spec.rb +5 -4
- data/spec/unit/axiom/function/predicate/enumerable/call_spec.rb +12 -2
- data/spec/unit/axiom/function/predicate/eql_spec.rb +4 -3
- data/spec/unit/axiom/function/predicate/equality/methods/eq_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/exclusion/class_methods/call_spec.rb +37 -8
- data/spec/unit/axiom/function/predicate/exclusion/methods/exclude_spec.rb +6 -2
- data/spec/unit/axiom/function/predicate/greater_than/methods/gt_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/greater_than_or_equal_to/methods/gte_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/inclusion/class_methods/call_spec.rb +37 -8
- data/spec/unit/axiom/function/predicate/inclusion/methods/include_spec.rb +6 -2
- data/spec/unit/axiom/function/predicate/inequality/methods/ne_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/less_than/methods/lt_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/less_than_or_equal_to/methods/lte_spec.rb +5 -1
- data/spec/unit/axiom/function/predicate/match/methods/match_spec.rb +7 -3
- data/spec/unit/axiom/function/predicate/no_match/methods/no_match_spec.rb +6 -2
- data/spec/unit/axiom/function/proposition/call_spec.rb +6 -4
- data/spec/unit/axiom/function/proposition/class_methods/{new_spec.rb → coerce_spec.rb} +17 -17
- data/spec/unit/axiom/function/proposition/eql_spec.rb +4 -4
- data/spec/unit/axiom/function/proposition/equality_operator_spec.rb +3 -3
- data/spec/unit/axiom/function/proposition/inverse_spec.rb +4 -4
- data/spec/unit/axiom/function/proposition/rename_spec.rb +1 -1
- data/spec/unit/axiom/function/type_spec.rb +1 -1
- data/spec/unit/axiom/function/unary/call_spec.rb +1 -1
- data/spec/unit/axiom/function/unary/callable/call_spec.rb +3 -13
- data/spec/unit/axiom/function/unary/callable/included_spec.rb +2 -2
- data/spec/unit/axiom/function/unary/type_spec.rb +11 -1
- data/spec/unit/axiom/relation/base/eql_spec.rb +1 -1
- data/spec/unit/axiom/relation/base/equality_operator_spec.rb +138 -0
- data/spec/unit/axiom/relation/class_methods/new_spec.rb +7 -7
- data/spec/unit/axiom/relation/directions_spec.rb +2 -2
- data/spec/unit/axiom/relation/each_spec.rb +5 -5
- data/spec/unit/axiom/relation/element_reader_spec.rb +1 -1
- data/spec/unit/axiom/relation/empty/each_spec.rb +1 -1
- data/spec/unit/axiom/relation/empty_predicate_spec.rb +1 -1
- data/spec/unit/axiom/relation/eql_spec.rb +1 -1
- data/spec/unit/axiom/relation/equality_operator_spec.rb +1 -1
- data/spec/unit/axiom/relation/header/class_methods/coerce_spec.rb +2 -2
- data/spec/unit/axiom/relation/header/class_methods/new_spec.rb +3 -3
- data/spec/unit/axiom/relation/header/context_spec.rb +2 -2
- data/spec/unit/axiom/relation/header/each_spec.rb +2 -2
- data/spec/unit/axiom/relation/header/extend_spec.rb +1 -1
- data/spec/unit/axiom/relation/header/{call_spec.rb → fetch_spec.rb} +1 -1
- data/spec/unit/axiom/relation/header/project_spec.rb +1 -1
- data/spec/unit/axiom/relation/header/rename_spec.rb +19 -5
- data/spec/unit/axiom/relation/header/size_spec.rb +14 -0
- data/spec/unit/axiom/relation/header_spec.rb +1 -1
- data/spec/unit/axiom/relation/index/each_spec.rb +33 -0
- data/spec/unit/axiom/relation/index/element_reader_spec.rb +17 -0
- data/spec/unit/axiom/relation/index/left_shift_operator_spec.rb +23 -0
- data/spec/unit/axiom/relation/index/merge_spec.rb +19 -0
- data/spec/unit/axiom/relation/keys/class_methods/coerce_spec.rb +19 -2
- data/spec/unit/axiom/relation/keys/class_methods/new_spec.rb +1 -1
- data/spec/unit/axiom/relation/keys/each_spec.rb +2 -2
- data/spec/unit/axiom/relation/materialize_spec.rb +1 -1
- data/spec/unit/axiom/relation/materialized/class_methods/new_spec.rb +30 -4
- data/spec/unit/axiom/relation/materialized/directions_spec.rb +1 -1
- data/spec/unit/axiom/relation/materialized/materialized_predicate_spec.rb +1 -1
- data/spec/unit/axiom/relation/materialized_predicate_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/binary/class_methods/included_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/binary/class_methods/new_spec.rb +6 -6
- data/spec/unit/axiom/relation/operation/combination/class_methods/combine_tuples_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/group/each_spec.rb +33 -0
- data/spec/unit/axiom/relation/operation/group/header_spec.rb +22 -0
- data/spec/unit/axiom/relation/operation/group/methods/group_spec.rb +25 -0
- data/spec/unit/axiom/relation/operation/limit/class_methods/new_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/limit/directions_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/limit/each_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/limit/limit_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/offset/class_methods/new_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/offset/directions_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/offset/each_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/offset/offset_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/reverse/class_methods/new_spec.rb +6 -6
- data/spec/unit/axiom/relation/operation/reverse/directions_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/reverse/each_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/set/class_methods/included_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/{order → sorted}/ascending/class_methods/call_spec.rb +22 -1
- data/spec/unit/axiom/relation/operation/sorted/ascending/class_methods/reverse_spec.rb +11 -0
- data/spec/unit/axiom/relation/operation/{order/descending → sorted/ascending}/reverse_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/{order → sorted}/class_methods/new_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/{order → sorted}/delete_spec.rb +12 -6
- data/spec/unit/axiom/relation/operation/{order → sorted}/descending/class_methods/call_spec.rb +22 -1
- data/spec/unit/axiom/relation/operation/sorted/descending/class_methods/reverse_spec.rb +11 -0
- data/spec/unit/axiom/relation/operation/{order/ascending → sorted/descending}/reverse_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/attribute_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/call_spec.rb +7 -7
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/class_methods/coerce_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/eql_predicate_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/name_spec.rb +4 -4
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/rename_spec.rb +5 -5
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction/reverse_spec.rb +9 -9
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/attributes_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/class_methods/coerce_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/class_methods/new_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/eql_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/equality_operator_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/project_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/rename_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/reverse_spec.rb +2 -2
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/sort_tuples_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/direction_set/to_ary_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/directions_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/each_spec.rb +3 -3
- data/spec/unit/axiom/relation/operation/{order → sorted}/eql_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/header_spec.rb +1 -1
- data/spec/unit/axiom/relation/operation/{order → sorted}/insert_spec.rb +12 -6
- data/spec/unit/axiom/relation/operation/{order → sorted}/methods/sort_by_spec.rb +24 -24
- data/spec/unit/axiom/relation/operation/sorted/methods/sort_spec.rb +19 -0
- data/spec/unit/axiom/relation/operation/ungroup/each_spec.rb +33 -0
- data/spec/unit/axiom/relation/operation/ungroup/header_spec.rb +19 -0
- data/spec/unit/axiom/relation/operation/ungroup/methods/ungroup_spec.rb +21 -0
- data/spec/unit/axiom/relation/operation/unwrap/each_spec.rb +33 -0
- data/spec/unit/axiom/relation/operation/unwrap/header_spec.rb +19 -0
- data/spec/unit/axiom/relation/operation/unwrap/methods/unwrap_spec.rb +21 -0
- data/spec/unit/axiom/relation/operation/wrap/each_spec.rb +33 -0
- data/spec/unit/axiom/relation/operation/wrap/header_spec.rb +22 -0
- data/spec/unit/axiom/relation/operation/wrap/methods/wrap_spec.rb +25 -0
- data/spec/unit/axiom/relation/proxy/each_spec.rb +2 -2
- data/spec/unit/axiom/relation/proxy/respond_to_predicate_spec.rb +48 -12
- data/spec/unit/axiom/relation/replace_spec.rb +8 -8
- data/spec/unit/axiom/tuple/class_methods/coerce_spec.rb +7 -1
- data/spec/unit/axiom/tuple/{call_spec.rb → fetch_spec.rb} +1 -1
- data/spec/unit/axiom/tuple/inspect_spec.rb +14 -0
- data/spec/unit/axiom/tuple/rename_spec.rb +17 -0
- data/spec/unit/axiom/tuple/size_spec.rb +14 -0
- data/spec/unit/axiom/tuple/to_ary_spec.rb +22 -5
- data/spec/unit/axiom/tuple/to_hash_spec.rb +14 -0
- data/spec/unit/axiom/types/relation/class_methods/primitive_spec.rb +13 -0
- data/spec/unit/axiom/types/tuple/class_methods/primitive_spec.rb +13 -0
- data/spec/unit/axiom/visitable/accept_spec.rb +1 -1
- data/spec/unit/date/pred_spec.rb +1 -1
- data/spec/unit/time/pred_spec.rb +1 -1
- metadata +631 -107
- data/spec/unit/axiom/aggregate/hash_spec.rb +0 -15
- data/spec/unit/axiom/algebra/extension/hash_spec.rb +0 -15
- data/spec/unit/axiom/algebra/projection/hash_spec.rb +0 -16
- data/spec/unit/axiom/algebra/rename/aliases/hash_spec.rb +0 -15
- data/spec/unit/axiom/algebra/rename/hash_spec.rb +0 -15
- data/spec/unit/axiom/algebra/restriction/hash_spec.rb +0 -15
- data/spec/unit/axiom/algebra/summarization/hash_spec.rb +0 -16
- data/spec/unit/axiom/attribute/hash_spec.rb +0 -21
- data/spec/unit/axiom/attribute/numeric/hash_spec.rb +0 -17
- data/spec/unit/axiom/attribute/string/hash_spec.rb +0 -25
- data/spec/unit/axiom/equalizer/methods/eql_spec.rb +0 -49
- data/spec/unit/axiom/equalizer/methods/equality_operator_spec.rb +0 -85
- data/spec/unit/axiom/function/binary/invertible/class_methods/included_spec.rb +0 -29
- data/spec/unit/axiom/function/predicate/hash_spec.rb +0 -16
- data/spec/unit/axiom/function/predicate/inverse_spec.rb +0 -17
- data/spec/unit/axiom/function/proposition/hash_spec.rb +0 -14
- data/spec/unit/axiom/function/unary/hash_spec.rb +0 -18
- data/spec/unit/axiom/function/unary/invertible/class_methods/included_spec.rb +0 -29
- data/spec/unit/axiom/operation/binary/hash_spec.rb +0 -16
- data/spec/unit/axiom/operation/unary/hash_spec.rb +0 -15
- data/spec/unit/axiom/relation/base/hash_spec.rb +0 -16
- data/spec/unit/axiom/relation/hash_spec.rb +0 -19
- data/spec/unit/axiom/relation/header/hash_spec.rb +0 -15
- data/spec/unit/axiom/relation/operation/limit/hash_spec.rb +0 -16
- data/spec/unit/axiom/relation/operation/offset/hash_spec.rb +0 -16
- data/spec/unit/axiom/relation/operation/order/ascending/class_methods/reverse_spec.rb +0 -11
- data/spec/unit/axiom/relation/operation/order/descending/class_methods/reverse_spec.rb +0 -11
- data/spec/unit/axiom/relation/operation/order/direction/hash_spec.rb +0 -15
- data/spec/unit/axiom/relation/operation/order/direction_set/hash_spec.rb +0 -15
- data/spec/unit/axiom/relation/operation/order/hash_spec.rb +0 -15
- data/spec/unit/axiom/relation/operation/order/methods/sort_spec.rb +0 -19
- data/spec/unit/axiom/relation/proxy/hash_spec.rb +0 -26
- data/spec/unit/axiom/relation/proxy/method_missing_spec.rb +0 -24
- data/spec/unit/axiom/tuple/hash_spec.rb +0 -15
data/config/flay.yml
CHANGED
data/config/reek.yml
CHANGED
@@ -19,8 +19,8 @@ Attribute:
|
|
19
19
|
- Axiom::Relation::Materialized
|
20
20
|
- Axiom::Relation::Operation::Limit
|
21
21
|
- Axiom::Relation::Operation::Offset
|
22
|
-
- Axiom::Relation::Operation::
|
23
|
-
- Axiom::Relation::Operation::
|
22
|
+
- Axiom::Relation::Operation::Sorted
|
23
|
+
- Axiom::Relation::Operation::Sorted::Direction
|
24
24
|
- Axiom::Relation::Proxy
|
25
25
|
- Axiom::Tuple
|
26
26
|
BooleanParameter:
|
@@ -31,7 +31,12 @@ ClassVariable:
|
|
31
31
|
exclude: []
|
32
32
|
ControlParameter:
|
33
33
|
enabled: true
|
34
|
-
exclude:
|
34
|
+
exclude:
|
35
|
+
- Axiom::Aggregate::Count#self.call
|
36
|
+
- Axiom::Function::Connective::Conjunction#self.call
|
37
|
+
- Axiom::Function::Connective::Disjunction#self.call
|
38
|
+
- Axiom::Function::Predicate::Enumerable#self.compare_method
|
39
|
+
- Axiom::Relation::Operation::Limit::Methods#assert_no_more_than_one_tuple
|
35
40
|
DataClump:
|
36
41
|
enabled: true
|
37
42
|
exclude:
|
@@ -57,9 +62,9 @@ DuplicateMethodCall:
|
|
57
62
|
- Axiom::Algebra::Restriction::Methods#coerce_to_predicate
|
58
63
|
- Axiom::Function::Binary#rename
|
59
64
|
- Axiom::Function::Unary#rename
|
60
|
-
- Axiom::Relation::Operation::
|
61
|
-
- Axiom::Relation::Operation::
|
62
|
-
- Axiom::Relation::Operation::
|
65
|
+
- Axiom::Relation::Operation::Sorted::Direction#call
|
66
|
+
- Axiom::Relation::Operation::Sorted::Direction#rename
|
67
|
+
- Axiom::Relation::Operation::Sorted::Methods#coerce_to_directions
|
63
68
|
- Axiom::Relation::Proxy#forward
|
64
69
|
- Axiom::Relation::Proxy#method_missing
|
65
70
|
max_calls: 1
|
@@ -92,6 +97,7 @@ NestedIterators:
|
|
92
97
|
- Axiom::Equalizer#define_cmp_method
|
93
98
|
- Axiom::Equalizer#define_hash_method
|
94
99
|
- Axiom::Equalizer#define_inspect_method
|
100
|
+
- Axiom::Relation::Operation::Ungroup#each
|
95
101
|
max_allowed_nesting: 1
|
96
102
|
ignore_iterators: []
|
97
103
|
NilCheck:
|
@@ -105,11 +111,15 @@ NilCheck:
|
|
105
111
|
- Axiom::Aggregate::Variance#self.call
|
106
112
|
- Axiom::Attribute#valid_or_optional?
|
107
113
|
- Axiom::Relation#self.materialized?
|
114
|
+
- Axiom::Relation::Materialized#self.empty?
|
108
115
|
- Axiom::Relation::Operation::Limit#self.assert_valid_limit
|
109
116
|
- Axiom::Relation::Operation::Offset#self.assert_valid_offset
|
117
|
+
- Axiom::Relation::Operation::Sorted::Ascending#self.call
|
118
|
+
- Axiom::Relation::Operation::Sorted::Descending#self.call
|
110
119
|
RepeatedConditional:
|
111
120
|
enabled: true
|
112
|
-
exclude:
|
121
|
+
exclude:
|
122
|
+
- Axiom::Aggregate::Mean
|
113
123
|
max_ifs: 1
|
114
124
|
TooManyInstanceVariables:
|
115
125
|
enabled: true
|
@@ -122,6 +132,7 @@ TooManyMethods:
|
|
122
132
|
- Axiom::Relation
|
123
133
|
- Axiom::Relation::Header
|
124
134
|
- Axiom::Relation::Keys
|
135
|
+
- Axiom::Tuple
|
125
136
|
max_methods: 10
|
126
137
|
TooManyStatements:
|
127
138
|
enabled: true
|
@@ -129,6 +140,7 @@ TooManyStatements:
|
|
129
140
|
- Axiom::Aggregate::Variance#self.call
|
130
141
|
- Axiom::Algebra::Rename::Aliases#union
|
131
142
|
- Axiom::Attribute#self.coerce
|
143
|
+
- Axiom::Equalizer#initialize
|
132
144
|
- each
|
133
145
|
max_statements: 5
|
134
146
|
UncommunicativeMethodName:
|
data/config/rubocop.yml
CHANGED
@@ -1,11 +1,4 @@
|
|
1
|
-
|
2
|
-
Includes:
|
3
|
-
- '../**/*.rake'
|
4
|
-
- 'Gemfile'
|
5
|
-
- 'Gemfile.devtools'
|
6
|
-
Excludes:
|
7
|
-
- '**/vendor/**'
|
8
|
-
- '**/benchmarks/**'
|
1
|
+
inherit_from: ../.rubocop.yml
|
9
2
|
|
10
3
|
# Avoid parameter lists longer than five parameters.
|
11
4
|
ParameterLists:
|
@@ -30,7 +23,7 @@ CollectionMethods:
|
|
30
23
|
# sections of code and visually separate them. When the keyword is at the same
|
31
24
|
# level I think it sort of blends in with the def keywords and makes it harder
|
32
25
|
# to scan the code and see where the sections are.
|
33
|
-
|
26
|
+
AccessModifierIndentation:
|
34
27
|
Enabled: false
|
35
28
|
|
36
29
|
# Limit line length
|
@@ -60,3 +53,7 @@ ConstantName:
|
|
60
53
|
# Not all trivial readers/writers can be defined with attr_* methods
|
61
54
|
TrivialAccessors:
|
62
55
|
Enabled: false
|
56
|
+
|
57
|
+
# Allow empty lines around body
|
58
|
+
EmptyLinesAroundBody:
|
59
|
+
Enabled: false
|
data/lib/axiom.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'bigdecimal'
|
4
|
+
require 'bigdecimal/util'
|
4
5
|
require 'date'
|
5
6
|
require 'set'
|
6
7
|
require 'singleton'
|
@@ -24,10 +25,10 @@ module Axiom
|
|
24
25
|
# Raised when the offset is not a positive integer
|
25
26
|
class InvalidOffsetError < ArgumentError; end
|
26
27
|
|
27
|
-
# Raised when a method requiring ordering is called on an
|
28
|
-
class
|
28
|
+
# Raised when a method requiring ordering is called on an unsorted relation
|
29
|
+
class SortededRelationRequiredError < StandardError; end
|
29
30
|
|
30
|
-
# Raised when a binary operation mixes
|
31
|
+
# Raised when a binary operation mixes sorted and unsorted relations
|
31
32
|
class RelationMismatchError < StandardError; end
|
32
33
|
|
33
34
|
# Raised when a name is a duplicate of another name in a set
|
@@ -49,7 +50,7 @@ module Axiom
|
|
49
50
|
class ExtensionMismatchError < WriteError; end
|
50
51
|
|
51
52
|
# Raised when inserting into an order with a mismatching relation
|
52
|
-
class
|
53
|
+
class SortedMismatchError < WriteError; end
|
53
54
|
|
54
55
|
# Raised when inserting into an immutable relation
|
55
56
|
class ImmutableRelationError < WriteError; end
|
@@ -128,13 +129,11 @@ require 'axiom/aggregate/standard_deviation'
|
|
128
129
|
|
129
130
|
require 'axiom/relation'
|
130
131
|
|
131
|
-
require 'axiom/relation/proxy'
|
132
|
-
|
133
132
|
require 'axiom/relation/keys'
|
134
133
|
require 'axiom/relation/header'
|
134
|
+
require 'axiom/relation/index'
|
135
135
|
|
136
136
|
require 'axiom/relation/base'
|
137
|
-
require 'axiom/relation/variable'
|
138
137
|
|
139
138
|
require 'axiom/relation/materialized'
|
140
139
|
require 'axiom/relation/empty'
|
@@ -142,13 +141,18 @@ require 'axiom/relation/empty'
|
|
142
141
|
require 'axiom/relation/operation/unary'
|
143
142
|
require 'axiom/relation/operation/binary'
|
144
143
|
require 'axiom/relation/operation/combination'
|
145
|
-
|
146
|
-
require 'axiom/relation/operation/
|
147
|
-
require 'axiom/relation/operation/order'
|
148
|
-
require 'axiom/relation/operation/order/direction'
|
149
|
-
require 'axiom/relation/operation/order/direction_set'
|
144
|
+
|
145
|
+
require 'axiom/relation/operation/group'
|
150
146
|
require 'axiom/relation/operation/limit'
|
147
|
+
require 'axiom/relation/operation/offset'
|
148
|
+
require 'axiom/relation/operation/sorted'
|
149
|
+
require 'axiom/relation/operation/sorted/direction'
|
150
|
+
require 'axiom/relation/operation/sorted/direction_set'
|
151
151
|
require 'axiom/relation/operation/reverse'
|
152
|
+
require 'axiom/relation/operation/set'
|
153
|
+
require 'axiom/relation/operation/ungroup'
|
154
|
+
require 'axiom/relation/operation/unwrap'
|
155
|
+
require 'axiom/relation/operation/wrap'
|
152
156
|
|
153
157
|
require 'axiom/algebra/difference'
|
154
158
|
require 'axiom/algebra/extension'
|
@@ -164,14 +168,19 @@ require 'axiom/algebra/summarization/summaries'
|
|
164
168
|
require 'axiom/algebra/summarization/summary'
|
165
169
|
require 'axiom/algebra/union'
|
166
170
|
|
171
|
+
require 'axiom/relation/proxy'
|
172
|
+
require 'axiom/relation/variable'
|
167
173
|
require 'axiom/relation/operation/deletion'
|
168
174
|
require 'axiom/relation/operation/insertion'
|
169
175
|
|
170
176
|
require 'axiom/attribute/comparable'
|
177
|
+
require 'axiom/attribute/length_comparable'
|
178
|
+
require 'axiom/attribute/value_comparable'
|
171
179
|
|
172
180
|
require 'axiom/attribute'
|
173
181
|
require 'axiom/attribute/object'
|
174
182
|
require 'axiom/attribute/numeric'
|
183
|
+
|
175
184
|
require 'axiom/attribute/boolean'
|
176
185
|
require 'axiom/attribute/class'
|
177
186
|
require 'axiom/attribute/date'
|
@@ -179,8 +188,8 @@ require 'axiom/attribute/date_time'
|
|
179
188
|
require 'axiom/attribute/decimal'
|
180
189
|
require 'axiom/attribute/float'
|
181
190
|
require 'axiom/attribute/integer'
|
182
|
-
require 'axiom/attribute/time'
|
183
191
|
require 'axiom/attribute/string'
|
192
|
+
require 'axiom/attribute/time'
|
184
193
|
|
185
194
|
require 'axiom/function/numeric'
|
186
195
|
|
@@ -202,6 +211,12 @@ require 'axiom/version'
|
|
202
211
|
|
203
212
|
require 'axiom-types'
|
204
213
|
|
214
|
+
require 'axiom/types/relation'
|
215
|
+
require 'axiom/types/tuple'
|
216
|
+
|
217
|
+
require 'axiom/attribute/relation'
|
218
|
+
require 'axiom/attribute/tuple'
|
219
|
+
|
205
220
|
module Axiom
|
206
221
|
|
207
222
|
# Represent a relation with an empty header and no tuples
|
data/lib/axiom/aggregate/mean.rb
CHANGED
@@ -17,14 +17,14 @@ module Axiom
|
|
17
17
|
#
|
18
18
|
# @param [Numeric] value
|
19
19
|
#
|
20
|
-
# @return [Array(Integer,
|
20
|
+
# @return [Array(Integer, Rational)]
|
21
21
|
#
|
22
22
|
# @api public
|
23
23
|
def self.call(accumulator, value)
|
24
24
|
return accumulator if value.nil?
|
25
25
|
count, mean = accumulator
|
26
26
|
count = Count.call(count, value)
|
27
|
-
[count, mean ? Rational(value - mean, count) + mean :
|
27
|
+
[count, mean ? Rational(value - mean, count) + mean : value.to_r]
|
28
28
|
end
|
29
29
|
|
30
30
|
# Extract the mean from the accumulator
|
@@ -41,7 +41,8 @@ module Axiom
|
|
41
41
|
#
|
42
42
|
# @api public
|
43
43
|
def self.finalize(accumulator)
|
44
|
-
accumulator.last
|
44
|
+
mean = accumulator.last
|
45
|
+
mean.to_f if mean
|
45
46
|
end
|
46
47
|
|
47
48
|
# Return the type returned from #call
|
data/lib/axiom/aggregate/sum.rb
CHANGED
@@ -109,7 +109,7 @@ module Axiom
|
|
109
109
|
# @api private
|
110
110
|
def assert_matching_extensions(other, event)
|
111
111
|
unless other.kind_of?(self.class) && extensions.eql?(other.extensions)
|
112
|
-
|
112
|
+
fail ExtensionMismatchError, "other relation must have matching extensions to be #{event}"
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
data/lib/axiom/algebra/join.rb
CHANGED
@@ -47,12 +47,9 @@ module Axiom
|
|
47
47
|
return to_enum unless block_given?
|
48
48
|
util = Relation::Operation::Combination
|
49
49
|
index = build_index
|
50
|
-
|
51
50
|
left.each do |left_tuple|
|
52
|
-
|
53
|
-
util.combine_tuples(header, left_tuple, right_tuples, &block)
|
51
|
+
util.combine_tuples(header, left_tuple, index[left_tuple], &block)
|
54
52
|
end
|
55
|
-
|
56
53
|
self
|
57
54
|
end
|
58
55
|
|
@@ -94,27 +91,7 @@ module Axiom
|
|
94
91
|
#
|
95
92
|
# @api private
|
96
93
|
def build_index
|
97
|
-
|
98
|
-
right.each { |tuple| index[join_tuple(tuple)] << disjoint_tuple(tuple) }
|
99
|
-
index
|
100
|
-
end
|
101
|
-
|
102
|
-
# Generate a tuple with the join attributes between relations
|
103
|
-
#
|
104
|
-
# @return [Tuple]
|
105
|
-
#
|
106
|
-
# @api private
|
107
|
-
def join_tuple(tuple)
|
108
|
-
tuple.project(join_header)
|
109
|
-
end
|
110
|
-
|
111
|
-
# Generate a tuple with the disjoint attributes between relations
|
112
|
-
#
|
113
|
-
# @return [Tuple]
|
114
|
-
#
|
115
|
-
# @api private
|
116
|
-
def disjoint_tuple(tuple)
|
117
|
-
tuple.project(@disjoint_header)
|
94
|
+
Index.new(join_header, @disjoint_header).merge(right)
|
118
95
|
end
|
119
96
|
|
120
97
|
# Insert the other relation into the left operand
|
@@ -189,9 +166,9 @@ module Axiom
|
|
189
166
|
# @return [Join, Restriction]
|
190
167
|
#
|
191
168
|
# @api public
|
192
|
-
def join(other)
|
169
|
+
def join(other, &block)
|
193
170
|
relation = Join.new(self, other)
|
194
|
-
relation = relation.restrict
|
171
|
+
relation = relation.restrict(&block) if block
|
195
172
|
relation
|
196
173
|
end
|
197
174
|
|
@@ -36,7 +36,7 @@ module Axiom
|
|
36
36
|
# @api private
|
37
37
|
def self.assert_disjointed_headers(left, right)
|
38
38
|
if (left.header & right.header).any?
|
39
|
-
|
39
|
+
fail InvalidHeaderError, 'the headers must be disjointed'
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -77,7 +77,7 @@ module Axiom
|
|
77
77
|
#
|
78
78
|
# @api public
|
79
79
|
def insert(*)
|
80
|
-
|
80
|
+
fail ImmutableRelationError, 'inserting into a product is impossible'
|
81
81
|
end
|
82
82
|
|
83
83
|
# Raise an exception when deleting from the Product
|
@@ -92,7 +92,7 @@ module Axiom
|
|
92
92
|
#
|
93
93
|
# @api public
|
94
94
|
def delete(*)
|
95
|
-
|
95
|
+
fail ImmutableRelationError, 'deleting from a product is impossible'
|
96
96
|
end
|
97
97
|
|
98
98
|
module Methods
|
@@ -102,7 +102,7 @@ module Axiom
|
|
102
102
|
def assert_removed_attributes_optional
|
103
103
|
names = required_attribute_names
|
104
104
|
if names.any?
|
105
|
-
|
105
|
+
fail RequiredAttributesError, "required attributes #{names} have been removed"
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -118,7 +118,7 @@ module Axiom
|
|
118
118
|
# @api private
|
119
119
|
def assert_equivalent_headers(other)
|
120
120
|
if header != other.header
|
121
|
-
|
121
|
+
fail InvalidHeaderError, 'the headers must be equivalent'
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
data/lib/axiom/algebra/rename.rb
CHANGED
@@ -17,7 +17,7 @@ module Axiom
|
|
17
17
|
|
18
18
|
# The relation sort order
|
19
19
|
#
|
20
|
-
# @return [Operation::
|
20
|
+
# @return [Operation::Sorted::DirectionSet]
|
21
21
|
#
|
22
22
|
# @api private
|
23
23
|
attr_reader :directions
|
@@ -55,7 +55,7 @@ module Axiom
|
|
55
55
|
# @api public
|
56
56
|
def each
|
57
57
|
return to_enum unless block_given?
|
58
|
-
operand.each { |
|
58
|
+
operand.each { |tuple| yield tuple.rename(header) }
|
59
59
|
self
|
60
60
|
end
|
61
61
|
|
@@ -39,7 +39,7 @@ module Axiom
|
|
39
39
|
# @api private
|
40
40
|
def self.assert_unique_aliases(aliases)
|
41
41
|
if aliases.values.uniq!
|
42
|
-
|
42
|
+
fail DuplicateAliasError, 'the aliases must be unique'
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -54,7 +54,7 @@ module Axiom
|
|
54
54
|
#
|
55
55
|
# @api public
|
56
56
|
def initialize(aliases)
|
57
|
-
@aliases =
|
57
|
+
@aliases = self.class.freezer.call(aliases)
|
58
58
|
end
|
59
59
|
|
60
60
|
# Lookup the new attribute given the old attribute
|
@@ -144,7 +144,7 @@ module Axiom
|
|
144
144
|
# @api public
|
145
145
|
def inverse
|
146
146
|
self.class.new(@aliases.invert)
|
147
|
-
.memoize(:
|
147
|
+
.memoize(inverse: self)
|
148
148
|
end
|
149
149
|
|
150
150
|
# Compare the aliases with other aliases for equivalency
|
@@ -55,7 +55,7 @@ module Axiom
|
|
55
55
|
# @api private
|
56
56
|
def self.assert_subset_headers(operand, summarize_per)
|
57
57
|
unless summarize_per.header.to_set.proper_subset?(operand.header.to_set)
|
58
|
-
|
58
|
+
fail InvalidHeaderError, 'the summarize_per header must be a proper subset of the operand header'
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -112,7 +112,7 @@ module Axiom
|
|
112
112
|
#
|
113
113
|
# @api public
|
114
114
|
def insert(*)
|
115
|
-
|
115
|
+
fail ImmutableRelationError, 'inserting into a summarization is impossible'
|
116
116
|
end
|
117
117
|
|
118
118
|
# Raise an exception when deleting from a Summarization
|
@@ -127,7 +127,7 @@ module Axiom
|
|
127
127
|
#
|
128
128
|
# @api public
|
129
129
|
def delete(*)
|
130
|
-
|
130
|
+
fail ImmutableRelationError, 'deleting from a summarization is impossible'
|
131
131
|
end
|
132
132
|
|
133
133
|
private
|
data/lib/axiom/attribute.rb
CHANGED
@@ -35,10 +35,11 @@ module Axiom
|
|
35
35
|
def self.coerce(object)
|
36
36
|
if object.kind_of?(Attribute)
|
37
37
|
object
|
38
|
+
elsif equal?(Attribute)
|
39
|
+
Object.coerce(object)
|
38
40
|
else
|
39
41
|
name, type, options = object
|
40
|
-
klass =
|
41
|
-
klass = const_get(type.name) if type
|
42
|
+
klass = type ? const_get(type.name) : self
|
42
43
|
klass.new(name, options || EMPTY_HASH)
|
43
44
|
end
|
44
45
|
end
|
@@ -104,7 +105,7 @@ module Axiom
|
|
104
105
|
#
|
105
106
|
# @api public
|
106
107
|
def call(tuple)
|
107
|
-
tuple
|
108
|
+
tuple[self]
|
108
109
|
end
|
109
110
|
|
110
111
|
# Rename an attribute
|
@@ -149,7 +150,7 @@ module Axiom
|
|
149
150
|
#
|
150
151
|
# @api public
|
151
152
|
def optional?
|
152
|
-
!
|
153
|
+
!required?
|
153
154
|
end
|
154
155
|
|
155
156
|
# Test if the value matches the attribute constraints
|