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
@@ -3,28 +3,23 @@
|
|
3
3
|
module Axiom
|
4
4
|
class Attribute
|
5
5
|
|
6
|
-
# A mixin for attributes that have comparable
|
6
|
+
# A mixin for attributes that have comparable objects
|
7
7
|
module Comparable
|
8
8
|
include Function::Predicate::GreaterThan::Methods,
|
9
9
|
Function::Predicate::GreaterThanOrEqualTo::Methods,
|
10
10
|
Function::Predicate::LessThan::Methods,
|
11
|
-
Function::Predicate::LessThanOrEqualTo::Methods
|
12
|
-
Aggregate::Minimum::Methods,
|
13
|
-
Aggregate::Maximum::Methods,
|
14
|
-
Aggregate::Mean::Methods,
|
15
|
-
Aggregate::Variance::Methods,
|
16
|
-
Aggregate::StandardDeviation::Methods
|
11
|
+
Function::Predicate::LessThanOrEqualTo::Methods
|
17
12
|
|
18
13
|
# Sort the attribute in ascending order
|
19
14
|
#
|
20
15
|
# @example
|
21
16
|
# ascending = attribute.asc
|
22
17
|
#
|
23
|
-
# @return [Relation::Operation::
|
18
|
+
# @return [Axiom::Relation::Operation::Sorted::Ascending]
|
24
19
|
#
|
25
20
|
# @api public
|
26
21
|
def asc
|
27
|
-
Relation::Operation::
|
22
|
+
Axiom::Relation::Operation::Sorted::Ascending.new(self)
|
28
23
|
end
|
29
24
|
|
30
25
|
# Sort the attribute in descending order
|
@@ -32,11 +27,20 @@ module Axiom
|
|
32
27
|
# @example
|
33
28
|
# descending = attribute.desc
|
34
29
|
#
|
35
|
-
# @return [Relation::Operation::
|
30
|
+
# @return [Axiom::Relation::Operation::Sorted::Descending]
|
36
31
|
#
|
37
32
|
# @api public
|
38
33
|
def desc
|
39
|
-
Relation::Operation::
|
34
|
+
Axiom::Relation::Operation::Sorted::Descending.new(self)
|
35
|
+
end
|
36
|
+
|
37
|
+
# The range for the objects
|
38
|
+
#
|
39
|
+
# @return [Range]
|
40
|
+
#
|
41
|
+
# @api public
|
42
|
+
def range
|
43
|
+
type.range
|
40
44
|
end
|
41
45
|
|
42
46
|
end # module Comparable
|
data/lib/axiom/attribute/date.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Axiom
|
4
|
+
class Attribute
|
5
|
+
|
6
|
+
# A mixin for attributes that have comparable lengths
|
7
|
+
module LengthComparable
|
8
|
+
include Comparable
|
9
|
+
|
10
|
+
# Initialize a length comparable attribute
|
11
|
+
#
|
12
|
+
# @param [#to_sym] _name
|
13
|
+
# the attribute name
|
14
|
+
# @param [#to_hash] options
|
15
|
+
# the options for the attribute
|
16
|
+
# @option options [Boolean] :required (true)
|
17
|
+
# if true, then the value cannot be nil
|
18
|
+
# @option options [::Integer] :minimum_length
|
19
|
+
# The minimum string length for a valid value
|
20
|
+
# @option options [::Integer] :maximum_length
|
21
|
+
# The maximum string length for a valid value
|
22
|
+
#
|
23
|
+
# @return [undefined]
|
24
|
+
#
|
25
|
+
# @api private
|
26
|
+
def initialize(_name, options = EMPTY_HASH)
|
27
|
+
super
|
28
|
+
min, max = options.values_at(:minimum_length, :maximum_length)
|
29
|
+
if min || max
|
30
|
+
@type = type.new do
|
31
|
+
minimum_length(min) if min
|
32
|
+
maximum_length(max) if max
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end # module LengthComparable
|
38
|
+
end # class Attribute
|
39
|
+
end # module Axiom
|
@@ -5,7 +5,7 @@ module Axiom
|
|
5
5
|
|
6
6
|
# Represents a Numeric value in a relation tuple
|
7
7
|
class Numeric < Object
|
8
|
-
include
|
8
|
+
include ValueComparable,
|
9
9
|
Aggregate::Sum::Methods
|
10
10
|
|
11
11
|
# The attribute type
|
@@ -20,31 +20,6 @@ module Axiom
|
|
20
20
|
Types::Numeric
|
21
21
|
end
|
22
22
|
|
23
|
-
# Initialize a Numeric Attribute
|
24
|
-
#
|
25
|
-
# @param [#to_sym] _name
|
26
|
-
# the attribute name
|
27
|
-
# @param [#to_hash] options
|
28
|
-
# the options for the attribute
|
29
|
-
# @option options [Boolean] :required (true)
|
30
|
-
# if true, then the value cannot be nil
|
31
|
-
# @option options [Range<::Numeric>] :size
|
32
|
-
# The numeric range for a valid value
|
33
|
-
#
|
34
|
-
# @return [undefined]
|
35
|
-
#
|
36
|
-
# @api private
|
37
|
-
def initialize(_name, options = EMPTY_HASH)
|
38
|
-
super
|
39
|
-
size = options[:size]
|
40
|
-
if size
|
41
|
-
@type = type.new do
|
42
|
-
minimum(size.first)
|
43
|
-
maximum(size.last)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
23
|
end # class Numeric
|
49
24
|
end # class Attribute
|
50
25
|
end # module Axiom
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Axiom
|
4
|
+
class Attribute
|
5
|
+
|
6
|
+
# Represents a Relation value in a relation tuple
|
7
|
+
class Relation < Object
|
8
|
+
include Equalizer.new(:name, :header)
|
9
|
+
|
10
|
+
# The tuple header
|
11
|
+
#
|
12
|
+
# @return [Header]
|
13
|
+
#
|
14
|
+
# @api private
|
15
|
+
attr_reader :header
|
16
|
+
|
17
|
+
# Initialize a Relation Attribute
|
18
|
+
#
|
19
|
+
# @param [#to_sym] _name
|
20
|
+
# the attribute name
|
21
|
+
# @param [Hash] options
|
22
|
+
# the options for the attribute
|
23
|
+
# @option options [Boolean] :required (true)
|
24
|
+
# if true, then the value cannot be nil
|
25
|
+
# @option options [Header] :header
|
26
|
+
# the header for the relation
|
27
|
+
#
|
28
|
+
# @return [undefined]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def initialize(_name, options)
|
32
|
+
super
|
33
|
+
@header = Axiom::Relation::Header.coerce(options.fetch(:header))
|
34
|
+
end
|
35
|
+
|
36
|
+
# The attribute type
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# type = Axiom::Attribute::Relation.type # => Axiom::Types::Relation
|
40
|
+
#
|
41
|
+
# @return [Class<Types::Relation>]
|
42
|
+
#
|
43
|
+
# @api public
|
44
|
+
def self.type
|
45
|
+
Types::Relation
|
46
|
+
end
|
47
|
+
|
48
|
+
# Initialize a new relation with the tuples provided
|
49
|
+
#
|
50
|
+
# @example
|
51
|
+
# relation = attribute.new_relation(tuples)
|
52
|
+
#
|
53
|
+
# @param [Enumerable] tuples
|
54
|
+
#
|
55
|
+
# @return [Relation]
|
56
|
+
#
|
57
|
+
# @api public
|
58
|
+
def new_relation(tuples)
|
59
|
+
type.primitive.new(@header, tuples)
|
60
|
+
end
|
61
|
+
|
62
|
+
end # class Relation
|
63
|
+
end # class Attribute
|
64
|
+
end # module Axiom
|
@@ -5,7 +5,7 @@ module Axiom
|
|
5
5
|
|
6
6
|
# Represents a String value in a relation tuple
|
7
7
|
class String < Object
|
8
|
-
include
|
8
|
+
include LengthComparable,
|
9
9
|
Function::Predicate::Match::Methods,
|
10
10
|
Function::Predicate::NoMatch::Methods
|
11
11
|
|
@@ -21,33 +21,6 @@ module Axiom
|
|
21
21
|
Types::String
|
22
22
|
end
|
23
23
|
|
24
|
-
# Initialize a String Attribute
|
25
|
-
#
|
26
|
-
# @param [#to_sym] _name
|
27
|
-
# the attribute name
|
28
|
-
# @param [#to_hash] options
|
29
|
-
# the options for the attribute
|
30
|
-
# @option options [Boolean] :required (true)
|
31
|
-
# if true, then the value cannot be nil
|
32
|
-
# @option options [::Integer] :minimum_length
|
33
|
-
# The minimum string length for a valid value
|
34
|
-
# @option options [::Integer] :maximum_length
|
35
|
-
# The maximum string length for a valid value
|
36
|
-
#
|
37
|
-
# @return [undefined]
|
38
|
-
#
|
39
|
-
# @api private
|
40
|
-
def initialize(_name, options = EMPTY_HASH)
|
41
|
-
super
|
42
|
-
min, max = options.values_at(:minimum_length, :maximum_length)
|
43
|
-
if min || max
|
44
|
-
@type = type.new do
|
45
|
-
minimum_length(min) if min
|
46
|
-
maximum_length(max) if max
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
24
|
end # class String
|
52
25
|
end # class Attribute
|
53
26
|
end # module Axiom
|
data/lib/axiom/attribute/time.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Axiom
|
4
|
+
class Attribute
|
5
|
+
|
6
|
+
# Represents a tuple value in a relation tuple
|
7
|
+
class Tuple < Object
|
8
|
+
include Equalizer.new(:name, :header)
|
9
|
+
|
10
|
+
# The header
|
11
|
+
#
|
12
|
+
# @return [Header]
|
13
|
+
#
|
14
|
+
# @api private
|
15
|
+
attr_reader :header
|
16
|
+
|
17
|
+
# Initialize a Tuple Attribute
|
18
|
+
#
|
19
|
+
# @param [#to_sym] _name
|
20
|
+
# the attribute name
|
21
|
+
# @param [Hash] options
|
22
|
+
# the options for the attribute
|
23
|
+
# @option options [Boolean] :required (true)
|
24
|
+
# if true, then the value cannot be nil
|
25
|
+
# @option options [Header] :header
|
26
|
+
# the header for the tuple
|
27
|
+
#
|
28
|
+
# @return [undefined]
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
def initialize(_name, options)
|
32
|
+
super
|
33
|
+
@header = Axiom::Relation::Header.coerce(options.fetch(:header))
|
34
|
+
end
|
35
|
+
|
36
|
+
# The attribute type
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# type = Axiom::Attribute::Tuple.type # => Axiom::Types::Tuple
|
40
|
+
#
|
41
|
+
# @return [Class<Types::Tuple>]
|
42
|
+
#
|
43
|
+
# @api public
|
44
|
+
def self.type
|
45
|
+
Types::Tuple
|
46
|
+
end
|
47
|
+
|
48
|
+
end # class Tuple
|
49
|
+
end # class Attribute
|
50
|
+
end # module Axiom
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Axiom
|
4
|
+
class Attribute
|
5
|
+
|
6
|
+
# A mixin for attributes that have comparable values
|
7
|
+
module ValueComparable
|
8
|
+
include Comparable,
|
9
|
+
Aggregate::Minimum::Methods,
|
10
|
+
Aggregate::Maximum::Methods,
|
11
|
+
Aggregate::Mean::Methods,
|
12
|
+
Aggregate::Variance::Methods,
|
13
|
+
Aggregate::StandardDeviation::Methods
|
14
|
+
|
15
|
+
# Initialize a value comparable attribute
|
16
|
+
#
|
17
|
+
# @param [#to_sym] _name
|
18
|
+
# the attribute name
|
19
|
+
# @param [#to_hash] options
|
20
|
+
# the options for the attribute
|
21
|
+
# @option options [Boolean] :required (true)
|
22
|
+
# if true, then the value cannot be nil
|
23
|
+
# @option options [Range<::Numeric>] :size
|
24
|
+
# The numeric range for a valid value
|
25
|
+
#
|
26
|
+
# @return [undefined]
|
27
|
+
#
|
28
|
+
# @api private
|
29
|
+
def initialize(_name, options = EMPTY_HASH)
|
30
|
+
super
|
31
|
+
size = options[:size]
|
32
|
+
if size
|
33
|
+
@type = type.new do
|
34
|
+
minimum(size.first)
|
35
|
+
maximum(size.last)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end # module ValueComparable
|
41
|
+
end # class Attribute
|
42
|
+
end # module Axiom
|
data/lib/axiom/function.rb
CHANGED
@@ -21,7 +21,7 @@ module Axiom
|
|
21
21
|
#
|
22
22
|
# @api private
|
23
23
|
def self.rename_attributes(operand, aliases)
|
24
|
-
if operand.respond_to?(:rename) && !
|
24
|
+
if operand.respond_to?(:rename) && !operand.kind_of?(Attribute)
|
25
25
|
operand.rename(aliases)
|
26
26
|
else
|
27
27
|
aliases[operand]
|
@@ -73,21 +73,7 @@ module Axiom
|
|
73
73
|
|
74
74
|
# Mixin for invertable binary functions
|
75
75
|
module Invertible
|
76
|
-
|
77
|
-
# Hook called when module is included
|
78
|
-
#
|
79
|
-
# @param [Module] descendant
|
80
|
-
# the module or class including Invertible
|
81
|
-
#
|
82
|
-
# @return [undefined]
|
83
|
-
#
|
84
|
-
# @api private
|
85
|
-
def self.included(descendant)
|
86
|
-
super
|
87
|
-
descendant.memoize :inverse
|
88
|
-
end
|
89
|
-
|
90
|
-
private_class_method :included
|
76
|
+
include Adamantium
|
91
77
|
|
92
78
|
# Return the inverse function
|
93
79
|
#
|
@@ -98,9 +84,11 @@ module Axiom
|
|
98
84
|
#
|
99
85
|
# @api public
|
100
86
|
def inverse
|
101
|
-
self.class.inverse.new(left, right).memoize(:
|
87
|
+
self.class.inverse.new(left, right).memoize(inverse: self)
|
102
88
|
end
|
103
89
|
|
90
|
+
memoize :inverse
|
91
|
+
|
104
92
|
end # module Invertible
|
105
93
|
end # module Binary
|
106
94
|
end # class Function
|