axiom 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0a046d8b1a86773086ceafa33a98e3452cb18d8c
|
4
|
+
data.tar.gz: d6c790c41ba483ddbc51d84ab134e2779b0fd649
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3a05d7872883d188be08181ea674b519e325ac044d9fc5ba83709830c07e1a50d6f4bf5752cee6df795a0b7eab941ca8ca95d4e538728529ef7d964229ff1230
|
7
|
+
data.tar.gz: afa76b69d11b0a9e52b856a3818ad3538bfd2575a548ab8a22ad7be4abe4c3114f290b4ffd78e51938d631a7222d71d3017cbd442f6fcbb8890eb4392b695f58
|
data/.rspec
CHANGED
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
@@ -5,19 +5,22 @@ script: "bundle exec rake ci:metrics"
|
|
5
5
|
rvm:
|
6
6
|
- 1.9.3
|
7
7
|
- 2.0.0
|
8
|
+
- 2.1.0
|
8
9
|
- ruby-head
|
9
|
-
- rbx
|
10
|
+
- rbx
|
10
11
|
matrix:
|
11
12
|
include:
|
12
13
|
- rvm: jruby-19mode
|
13
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
14
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov
|
15
|
+
- rvm: jruby-20mode
|
16
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov
|
17
|
+
- rvm: jruby-21mode
|
18
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov
|
14
19
|
- rvm: jruby-head
|
15
|
-
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
20
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov
|
16
21
|
allow_failures:
|
17
|
-
- rvm: 1.
|
18
|
-
|
19
|
-
- rvm: ruby-head # travis broken
|
20
|
-
- rvm: rbx-19mode # mutant fails
|
22
|
+
- rvm: 2.1.0 # buggy runtime
|
23
|
+
fast_finish: true
|
21
24
|
notifications:
|
22
25
|
irc:
|
23
26
|
channels:
|
data/Gemfile
CHANGED
data/Gemfile.devtools
CHANGED
@@ -4,21 +4,24 @@ group :development do
|
|
4
4
|
gem 'rake', '~> 10.1.0'
|
5
5
|
gem 'rspec', '~> 2.14.1'
|
6
6
|
gem 'yard', '~> 0.8.7'
|
7
|
+
|
8
|
+
platform :rbx do
|
9
|
+
gem 'rubysl-singleton', '~> 2.0.0'
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
13
|
group :yard do
|
10
|
-
gem 'kramdown', '~> 1.
|
14
|
+
gem 'kramdown', '~> 1.3.0'
|
11
15
|
end
|
12
16
|
|
13
17
|
group :guard do
|
14
|
-
gem 'guard', '~>
|
15
|
-
gem 'guard-bundler', '~>
|
16
|
-
gem 'guard-rspec', '~>
|
17
|
-
gem 'guard-rubocop', '~> 0.
|
18
|
-
gem 'guard-mutant', '~> 0.0.1'
|
18
|
+
gem 'guard', '~> 2.3.0'
|
19
|
+
gem 'guard-bundler', '~> 2.0.0'
|
20
|
+
gem 'guard-rspec', '~> 4.2.0'
|
21
|
+
gem 'guard-rubocop', '~> 1.0.0'
|
19
22
|
|
20
23
|
# file system change event handling
|
21
|
-
gem 'listen', '~>
|
24
|
+
gem 'listen', '~> 2.4.0'
|
22
25
|
gem 'rb-fchange', '~> 0.0.6', require: false
|
23
26
|
gem 'rb-fsevent', '~> 0.9.3', require: false
|
24
27
|
gem 'rb-inotify', '~> 0.9.0', require: false
|
@@ -30,18 +33,29 @@ group :guard do
|
|
30
33
|
end
|
31
34
|
|
32
35
|
group :metrics do
|
33
|
-
gem 'coveralls', '~> 0.
|
36
|
+
gem 'coveralls', '~> 0.7.0'
|
34
37
|
gem 'flay', '~> 2.4.0'
|
35
|
-
gem 'flog', '~> 4.
|
38
|
+
gem 'flog', '~> 4.2.0'
|
36
39
|
gem 'reek', '~> 1.3.2'
|
37
|
-
gem 'rubocop', '~> 0.
|
38
|
-
gem 'simplecov', '~> 0.
|
39
|
-
gem 'yardstick', '~> 0.9.
|
40
|
+
gem 'rubocop', '~> 0.16.0'
|
41
|
+
gem 'simplecov', '~> 0.8.2'
|
42
|
+
gem 'yardstick', '~> 0.9.9'
|
43
|
+
|
44
|
+
platforms :mri do
|
45
|
+
gem 'mutant', '~> 0.3.4'
|
46
|
+
end
|
40
47
|
|
41
48
|
platforms :ruby_19, :ruby_20 do
|
42
|
-
gem 'mutant', git: 'https://github.com/mbj/mutant.git'
|
43
49
|
gem 'yard-spellcheck', '~> 0.1.5'
|
44
50
|
end
|
51
|
+
|
52
|
+
platform :rbx do
|
53
|
+
gem 'json', '~> 1.8.1'
|
54
|
+
gem 'racc', '~> 1.4'
|
55
|
+
gem 'rubysl-logger', '~> 2.0.0'
|
56
|
+
gem 'rubysl-open-uri', '~> 2.0.0'
|
57
|
+
gem 'rubysl-prettyprint', '~> 2.0.2'
|
58
|
+
end
|
45
59
|
end
|
46
60
|
|
47
61
|
group :benchmarks do
|
data/Guardfile
CHANGED
@@ -6,14 +6,14 @@ guard :bundler do
|
|
6
6
|
watch(%w{.+.gemspec\z})
|
7
7
|
end
|
8
8
|
|
9
|
-
guard :rspec, cli: File.read('.rspec').split.join(' '), keep_failed: false do
|
9
|
+
guard :rspec, cli: File.read('.rspec').split.push('--fail-fast').join(' '), keep_failed: false do
|
10
10
|
# Run all specs if configuration is modified
|
11
11
|
watch('.rspec') { 'spec' }
|
12
12
|
watch('Guardfile') { 'spec' }
|
13
13
|
watch('Gemfile.lock') { 'spec' }
|
14
14
|
watch('spec/spec_helper.rb') { 'spec' }
|
15
15
|
|
16
|
-
# Run all specs if supporting files are modified
|
16
|
+
# Run all specs if supporting files files are modified
|
17
17
|
watch(%r{\Aspec/(?:fixtures|lib|support|shared)/.+\.rb\z}) { 'spec' }
|
18
18
|
|
19
19
|
# Run unit specs if associated lib code is modified
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
axiom
|
2
|
-
=====
|
1
|
+
# axiom
|
3
2
|
|
4
3
|
Simplifies querying of structured data using relational algebra.
|
5
4
|
|
@@ -15,8 +14,7 @@ Simplifies querying of structured data using relational algebra.
|
|
15
14
|
[codeclimate]: https://codeclimate.com/github/dkubb/axiom
|
16
15
|
[coveralls]: https://coveralls.io/r/dkubb/axiom
|
17
16
|
|
18
|
-
Examples
|
19
|
-
--------
|
17
|
+
## Examples
|
20
18
|
|
21
19
|
```ruby
|
22
20
|
relation = Axiom::Relation.new(
|
@@ -65,9 +63,21 @@ new_relation = relation.union(other) # OR relation | other
|
|
65
63
|
new_relation = relation.difference(other) # OR relation - other
|
66
64
|
|
67
65
|
# theta-join
|
66
|
+
#
|
67
|
+
# NOTE: theta-join is effectively restricting a product of the relations
|
68
68
|
new_relation = relation.join(other) { |r| r.id.gte(r.other_id) }
|
69
69
|
|
70
|
-
#
|
70
|
+
# group
|
71
|
+
grouped = relation.group(products: [:product_name])
|
72
|
+
|
73
|
+
# ungroup
|
74
|
+
ungrouped = relation.ungroup(:products)
|
75
|
+
|
76
|
+
# wrap
|
77
|
+
wrapped = relation.wrap(address: [:street, :city, :state, :zip, :country])
|
78
|
+
|
79
|
+
# unwrap
|
80
|
+
unwrapped = relation.unwrap(:address)
|
71
81
|
|
72
82
|
# extend
|
73
83
|
new_relation = relation.extend { |r| r.add(:pounds, r.weight * 2.2) }
|
@@ -83,31 +93,34 @@ new_relation = relation.summarize(relation.project([:city])) { |r| r.add(:count)
|
|
83
93
|
# returns a set that represents the relation header
|
84
94
|
header = relation.header
|
85
95
|
|
96
|
+
# each subset of unique keys as header objects
|
97
|
+
key_headers = header.keys
|
98
|
+
|
86
99
|
# a relation is Enumerable
|
87
100
|
relation = relation.each { |tuple| ... }
|
88
101
|
|
89
102
|
# order by attributes in the header
|
90
|
-
|
103
|
+
sorted = relation.sort
|
91
104
|
|
92
105
|
# order by attribute and direction
|
93
|
-
|
106
|
+
sorted = relation.sort_by { |r| [r.city.desc, r.name, r.color, r.id, r.weight] }
|
94
107
|
|
95
|
-
# reverse the relation (only allowed if
|
96
|
-
new_relation =
|
108
|
+
# reverse the relation (only allowed if sorted)
|
109
|
+
new_relation = sorted.reverse
|
97
110
|
|
98
|
-
# offset (only allowed if
|
99
|
-
new_relation =
|
111
|
+
# offset (only allowed if sorted)
|
112
|
+
new_relation = sorted.drop(5)
|
100
113
|
|
101
|
-
# limiting (only allowed if
|
102
|
-
new_relation =
|
114
|
+
# limiting (only allowed if sorted)
|
115
|
+
new_relation = sorted.take(10)
|
103
116
|
|
104
|
-
# get the first n tuples (only allowed if
|
105
|
-
new_relation =
|
106
|
-
new_relation =
|
117
|
+
# get the first n tuples (only allowed if sorted)
|
118
|
+
new_relation = sorted.first # default is 1
|
119
|
+
new_relation = sorted.first(5)
|
107
120
|
|
108
|
-
# get the last n tuples (only allowed if
|
109
|
-
new_relation =
|
110
|
-
new_relation =
|
121
|
+
# get the last n tuples (only allowed if sorted)
|
122
|
+
new_relation = sorted.last # default is 1
|
123
|
+
new_relation = sorted.last(5)
|
111
124
|
|
112
125
|
# get a tuple from a relation containing exactly one tuple
|
113
126
|
tuple = relation.one
|
@@ -124,13 +137,9 @@ new_relation = relation.delete(other)
|
|
124
137
|
|
125
138
|
# replace a relation variable with another set
|
126
139
|
new_relation = relation.replace(other)
|
127
|
-
|
128
|
-
# each subset of unique keys as header objects
|
129
|
-
keys = header.keys
|
130
140
|
```
|
131
141
|
|
132
|
-
Goals
|
133
|
-
-----
|
142
|
+
## Goals
|
134
143
|
|
135
144
|
The purpose of this project is to expand my knowledge of relational algebra by attempting to implement a simple query system using the primitive operations defined in relational algebra.
|
136
145
|
|
@@ -142,8 +151,7 @@ The ability to join data from multiple datastores and have it presented in a con
|
|
142
151
|
|
143
152
|
Not only does this work nicely with associations, but it will allow DataMapper to perform mapping in a more powerful way. You'll be able to construct a join from multiple datastores, and set that as the base for your model. Each DM Resource would work as normal, but again writes could be propagated back to the appropriate datastore. You'd be able to split your data up between different datastores, but assemble it into one coherent view.
|
144
153
|
|
145
|
-
Related Projects
|
146
|
-
----------------
|
154
|
+
## Related Projects
|
147
155
|
|
148
156
|
* [axiom-optimizer](https://github.com/dkubb/axiom-optimizer)
|
149
157
|
|
@@ -157,12 +165,10 @@ This is a visitor class that takes a Axiom relation and generates valid SQL from
|
|
157
165
|
|
158
166
|
This is a system that manages the database connections and executes the SQL generated from the relations.
|
159
167
|
|
160
|
-
Contributing
|
161
|
-
------------
|
168
|
+
## Contributing
|
162
169
|
|
163
170
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
164
171
|
|
165
|
-
Copyright
|
166
|
-
---------
|
172
|
+
## Copyright
|
167
173
|
|
168
174
|
Copyright © 2009-2013 Dan Kubb. See LICENSE for details.
|
data/TODO
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
* TODO:
|
2
2
|
|
3
|
+
* Create a module to allow methods to be added to existing Attribute objects
|
4
|
+
in such a way that the same methods can be easily mixed into other
|
5
|
+
things, like functions or relations.
|
6
|
+
* Replace the explicit mix-into-relation with something that adds the
|
7
|
+
methods to Axiom::Attribute::Relation, and then have Axiom::Relation
|
8
|
+
"inherit" those by declaring it's own relation methods as being of that
|
9
|
+
type.
|
10
|
+
|
11
|
+
* Move all Axiom::Algebra classes under Axiom::Relation::Operation
|
12
|
+
|
3
13
|
* Change Algebra::Extension#extensions to be a non-primtive
|
4
14
|
* May also change EvaluationContext#functions to return a set of functions.
|
5
15
|
|
@@ -7,10 +17,6 @@
|
|
7
17
|
* When unioning two keys together it is really simple to end up
|
8
18
|
with indexes that overlap and cause an exception.
|
9
19
|
|
10
|
-
* Add Header#size
|
11
|
-
* Replace code that coerces the Header to an Array in order to get the size
|
12
|
-
with Header#size.
|
13
|
-
|
14
20
|
* Make Equalizer handle subclasses without having to specify the attribtues
|
15
21
|
again in each descendant.
|
16
22
|
|
@@ -34,11 +40,7 @@
|
|
34
40
|
* Use a class variable to store each "Tuple class" so that anything with a
|
35
41
|
similar header will be reused.
|
36
42
|
|
37
|
-
* Remove
|
38
|
-
* It makes no sense for comparable objects to be "averaged", what would it
|
39
|
-
mean to get the average string?
|
40
|
-
|
41
|
-
* Remove Order, Reverse, Limit and Offset from the Relation inheritance chain
|
43
|
+
* Remove Sorted, Reverse, Limit and Offset from the Relation inheritance chain
|
42
44
|
* Instead make it so they are proxy classes that wrap Relations, but
|
43
45
|
proxy method calls to the Relation methods, and then wrap the return
|
44
46
|
value (assuming it's a Relation) in a copy of itself.
|
@@ -46,14 +48,12 @@
|
|
46
48
|
all the Relation classes. Only the Ranking classes will need to know
|
47
49
|
about directions.
|
48
50
|
* The Reverse class will probably not be needed either. All we need is
|
49
|
-
for the #reverse method to create a new
|
51
|
+
for the #reverse method to create a new Sorted with the directions
|
50
52
|
reversed.
|
51
53
|
* Remove the knowledge of directions from materialized relations
|
52
|
-
and instead wrap materialized relations in the
|
54
|
+
and instead wrap materialized relations in the Sorted object
|
53
55
|
if any.
|
54
56
|
|
55
|
-
* Add Relation#group and Relation#ungroup
|
56
|
-
|
57
57
|
* Update Attributes so that constraints are modelled using predicates,
|
58
58
|
so that when "join-ability" is tested, the predicates can just be
|
59
59
|
compared for equality.
|
@@ -62,13 +62,6 @@
|
|
62
62
|
caller. This will allow a "complex" predicate to set the errors
|
63
63
|
on tuples, while still allowing all the same objects to be used.
|
64
64
|
|
65
|
-
* Update memoization to take into account the arguments passed into
|
66
|
-
the method. It should memoize differently for different
|
67
|
-
methods. Perhaps it could have a special case for methods
|
68
|
-
with a 0-arity vs n-arity methods, but it needs to handle cases
|
69
|
-
like with #hash that accept no args, and #optimize that accepts
|
70
|
-
1 arg.
|
71
|
-
|
72
65
|
* Within the restriction context, make sure the attributes have aliases for:
|
73
66
|
* Alias #== to #eq (may break alot)
|
74
67
|
* Alias #!= to #ne (in 1.9 only)
|
@@ -101,7 +94,12 @@
|
|
101
94
|
* include? / member?
|
102
95
|
* min / max / minmax (when the tuples are sorted)
|
103
96
|
|
104
|
-
*
|
105
|
-
*
|
106
|
-
|
107
|
-
|
97
|
+
* Add Axiom::Relation aggregate methods:
|
98
|
+
* count
|
99
|
+
* count(attribute)
|
100
|
+
* sum(attribute)
|
101
|
+
* minimum(attribute)
|
102
|
+
* maximum(attribute)
|
103
|
+
* mean(attribute)
|
104
|
+
* standard_deviation(attribute)
|
105
|
+
* variance(attribute)
|
data/axiom.gemspec
CHANGED
@@ -10,18 +10,18 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.description = 'Simplifies querying of structured data using relational algebra'
|
11
11
|
gem.summary = 'Ruby Relational Algebra'
|
12
12
|
gem.homepage = 'https://github.com/dkubb/axiom'
|
13
|
-
gem.
|
13
|
+
gem.license = 'MIT'
|
14
14
|
|
15
15
|
gem.require_paths = %w[lib]
|
16
|
-
gem.files = `git ls-files`.split(
|
17
|
-
gem.test_files = `git ls-files -- spec/{unit,integration}`.split(
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.test_files = `git ls-files -- spec/{unit,integration}`.split($/)
|
18
18
|
gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md TODO]
|
19
19
|
|
20
|
-
gem.
|
21
|
-
gem.
|
22
|
-
gem.
|
23
|
-
gem.
|
24
|
-
gem.
|
20
|
+
gem.add_runtime_dependency('abstract_type', '~> 0.0.7')
|
21
|
+
gem.add_runtime_dependency('adamantium', '~> 0.2.0')
|
22
|
+
gem.add_runtime_dependency('axiom-types', '~> 0.1.0')
|
23
|
+
gem.add_runtime_dependency('descendants_tracker', '~> 0.0.3')
|
24
|
+
gem.add_runtime_dependency('equalizer', '~> 0.0.9')
|
25
25
|
|
26
|
-
gem.add_development_dependency('bundler', '~> 1.
|
26
|
+
gem.add_development_dependency('bundler', '~> 1.5', '>= 1.5.2')
|
27
27
|
end
|
data/benchmarks/memory.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby -Ku
|
2
|
-
|
3
2
|
# encoding: utf-8
|
4
3
|
|
5
4
|
# benchmark memory usage of lib, core object init and relation operations
|
@@ -127,7 +126,7 @@ each_count do |array, relation, count|
|
|
127
126
|
end
|
128
127
|
|
129
128
|
each_count do |array, relation, count|
|
130
|
-
gc_statistics "
|
129
|
+
gc_statistics "sort_by (#{count} tuples)" do
|
131
130
|
relation.sort_by { |r| [r.id.desc, r.name] }.each {}
|
132
131
|
end
|
133
132
|
end
|
data/benchmarks/speed.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby -Ku
|
2
|
-
|
3
2
|
# encoding: utf-8
|
4
3
|
|
5
4
|
# benchmark speed of relation operations
|
@@ -17,7 +16,7 @@ array = (1..100).map { |n| Tuple.new(header, [n, 'Dan Kubb']) }
|
|
17
16
|
relation = Relation.new(header, array)
|
18
17
|
join = Relation.new([[:id, Integer], [:age, Integer]], [[1, 35]])
|
19
18
|
product = Relation.new([[:age, Integer]], [[35]])
|
20
|
-
|
19
|
+
sorted = relation.sort_by { |r| [r.id, r.name] }
|
21
20
|
|
22
21
|
RBench.run(TIMES) do
|
23
22
|
column :ruby, title: 'Ruby'
|
@@ -68,33 +67,33 @@ RBench.run(TIMES) do
|
|
68
67
|
axiom { relation.difference(relation).each {} }
|
69
68
|
end
|
70
69
|
|
71
|
-
report '
|
70
|
+
report 'sort_by' do
|
72
71
|
ruby { array.sort_by { |tuple| [-tuple[:id], tuple[:name]] }.each {} }
|
73
72
|
axiom { relation.sort_by { |r| [r.id.desc, r.name] }.each {} }
|
74
73
|
end
|
75
74
|
|
76
75
|
report 'take' do
|
77
76
|
ruby { array.take(1).each {} }
|
78
|
-
axiom {
|
77
|
+
axiom { sorted.take(1).each {} }
|
79
78
|
end
|
80
79
|
|
81
80
|
report 'drop' do
|
82
81
|
ruby { array.drop(1).each {} }
|
83
|
-
axiom {
|
82
|
+
axiom { sorted.drop(1).each {} }
|
84
83
|
end
|
85
84
|
|
86
85
|
report 'first' do
|
87
86
|
ruby { array.first(1).each {} }
|
88
|
-
axiom {
|
87
|
+
axiom { sorted.first(1).each {} }
|
89
88
|
end
|
90
89
|
|
91
90
|
report 'last' do
|
92
91
|
ruby { array.last(1).each {} }
|
93
|
-
axiom {
|
92
|
+
axiom { sorted.last(1).each {} }
|
94
93
|
end
|
95
94
|
|
96
95
|
report 'reverse' do
|
97
96
|
ruby { array.reverse.each {} }
|
98
|
-
axiom {
|
97
|
+
axiom { sorted.reverse.each {} }
|
99
98
|
end
|
100
99
|
end
|